diff options
71 files changed, 380 insertions, 374 deletions
diff --git a/common/pom.xml b/common/pom.xml index 478d122b6..b5ff9e247 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-common</artifactId> diff --git a/examples/pom.xml b/examples/pom.xml index 6fec30015..33a0173fb 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/models/pom.xml b/models/pom.xml index b833277b9..9ff408551 100644 --- a/models/pom.xml +++ b/models/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-models</artifactId> diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java index 0bf6a9e1a..355fcaff0 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -202,6 +202,22 @@ public class JpaAutomationComposition extends Validated @Override public void fromAuthorative(@NonNull final AutomationComposition automationComposition) { + this.fromAuthorativeBase(automationComposition); + this.elements = new ArrayList<>(automationComposition.getElements().size()); + for (var elementEntry : automationComposition.getElements().entrySet()) { + var jpaAutomationCompositionElement = + new JpaAutomationCompositionElement(elementEntry.getKey().toString(), this.instanceId); + jpaAutomationCompositionElement.fromAuthorative(elementEntry.getValue()); + this.elements.add(jpaAutomationCompositionElement); + } + } + + /** + * Set an instance of the persist concept to the equivalent values as the other concept without copy the elements. + * + * @param automationComposition the authorative concept + */ + public void fromAuthorativeBase(@NonNull final AutomationComposition automationComposition) { this.instanceId = automationComposition.getInstanceId().toString(); this.name = automationComposition.getName(); this.version = automationComposition.getVersion(); @@ -216,13 +232,6 @@ public class JpaAutomationComposition extends Validated this.phase = automationComposition.getPhase(); this.description = automationComposition.getDescription(); this.stateChangeResult = automationComposition.getStateChangeResult(); - this.elements = new ArrayList<>(automationComposition.getElements().size()); - for (var elementEntry : automationComposition.getElements().entrySet()) { - var jpaAutomationCompositionElement = - new JpaAutomationCompositionElement(elementEntry.getKey().toString(), this.instanceId); - jpaAutomationCompositionElement.fromAuthorative(elementEntry.getValue()); - this.elements.add(jpaAutomationCompositionElement); - } } @Override diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java index 8be12960b..ce258094a 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java @@ -117,6 +117,23 @@ public class AutomationCompositionProvider { return result.toAuthorative(); } + + /** + * Update automation composition state. + * + * @param acSource the automation composition to update + * @return the updated automation composition + */ + public AutomationComposition updateAcState(final AutomationComposition acSource) { + var automationComposition = automationCompositionRepository + .getReferenceById(acSource.getInstanceId().toString()); + automationComposition.fromAuthorativeBase(acSource); + var result = automationCompositionRepository.save(automationComposition); + automationCompositionRepository.flush(); + // Return the saved automation composition + return result.toAuthorative(); + } + /** * Update automation composition. * @@ -232,12 +249,17 @@ public class AutomationCompositionProvider { * Update AutomationCompositionElement. * * @param element the AutomationCompositionElement - * @param instanceId the instance Id */ - public void updateAutomationCompositionElement(@NonNull final AutomationCompositionElement element, - @NonNull final UUID instanceId) { - var jpaAcElement = new JpaAutomationCompositionElement(element.getId().toString(), instanceId.toString()); - jpaAcElement.fromAuthorative(element); + public void updateAutomationCompositionElement(@NonNull final AutomationCompositionElement element) { + var jpaAcElement = acElementRepository.getReferenceById(element.getId().toString()); + jpaAcElement.setMessage(element.getMessage()); + jpaAcElement.setOutProperties(element.getOutProperties()); + jpaAcElement.setOperationalState(element.getOperationalState()); + jpaAcElement.setUseState(element.getUseState()); + jpaAcElement.setDeployState(element.getDeployState()); + jpaAcElement.setLockState(element.getLockState()); + jpaAcElement.setRestarting(element.getRestarting()); + ProviderUtils.validate(element, jpaAcElement, "AutomationCompositionElement"); acElementRepository.save(jpaAcElement); } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/StateDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/StateDefinition.java index b7c6a31ac..491ae101e 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/StateDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/StateDefinition.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class StateDefinition<V> { if (key == null || key.contains(separator)) { throw new PfModelRuntimeException(Status.INTERNAL_SERVER_ERROR, "wrong key " + key); } - sb.append(key + separator); + sb.append(key).append(separator); } return sb.toString(); } diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java index 8e7e50de7..515dfaa83 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java @@ -225,12 +225,18 @@ class AutomationCompositionProviderTest { var automationCompositionProvider = new AutomationCompositionProvider( mock(AutomationCompositionRepository.class), acElementRepository); - assertThatThrownBy(() -> automationCompositionProvider.updateAutomationCompositionElement(null, null)) + assertThatThrownBy(() -> automationCompositionProvider.updateAutomationCompositionElement(null)) .hasMessageMatching(ACELEMENT_IS_NULL); var acElement = inputAutomationCompositions.getAutomationCompositionList().get(0).getElements().values() .iterator().next(); - automationCompositionProvider.updateAutomationCompositionElement(acElement, UUID.randomUUID()); + var jpa = new JpaAutomationCompositionElement(); + jpa.setElementId(acElement.getId().toString()); + jpa.setInstanceId(UUID.randomUUID().toString()); + jpa.fromAuthorative(acElement); + when(acElementRepository.getReferenceById(acElement.getId().toString())).thenReturn(jpa); + + automationCompositionProvider.updateAutomationCompositionElement(acElement); verify(acElementRepository).save(any()); } diff --git a/packages/policy-clamp-docker/pom.xml b/packages/policy-clamp-docker/pom.xml index 01fba5cd6..d2deb4bfc 100644 --- a/packages/policy-clamp-docker/pom.xml +++ b/packages/policy-clamp-docker/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>clamp-packages</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <packaging>pom</packaging> diff --git a/packages/policy-clamp-docker/src/main/docker/A1pmsParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/A1pmsParticipant.Dockerfile index 24de4135e..7bd8b2b00 100644 --- a/packages/policy-clamp-docker/src/main/docker/A1pmsParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/A1pmsParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/a1pms-participant.tar.gz /packages/ RUN tar xvzf /packages/a1pms-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM A1 PMS Participant" diff --git a/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile b/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile index accc1ff89..4cb4ad9ea 100644 --- a/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/policy-clamp-runtime-acm.tar.gz /packages/ RUN tar xvzf /packages/policy-clamp-runtime-acm.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM runtime" diff --git a/packages/policy-clamp-docker/src/main/docker/ElementParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/ElementParticipant.Dockerfile index 6aa5448ea..6b32330b3 100644 --- a/packages/policy-clamp-docker/src/main/docker/ElementParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/ElementParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/element-participant.tar.gz /packages RUN tar xvfz /packages/element-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM Element" diff --git a/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile index e83321969..68e5ac955 100644 --- a/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/http-participant.tar.gz /packages/ RUN tar xvzf /packages/http-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM HTTP Participant" diff --git a/packages/policy-clamp-docker/src/main/docker/KserveParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/KserveParticipant.Dockerfile index eeb7938a6..a020d99df 100644 --- a/packages/policy-clamp-docker/src/main/docker/KserveParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/KserveParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/kserve-participant.tar.gz /packages/ RUN tar xvzf /packages/kserve-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM KSERVE Participant" diff --git a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile index 3ea2e9ed6..0d5b721d6 100644 --- a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/kubernetes-participant.tar.gz /packages/ RUN tar xvzf /packages/kubernetes-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM K8S Participant" diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile index 60debf2cb..f19f44f51 100644 --- a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/policy-participant.tar.gz /packages/ RUN tar xvzf /packages/policy-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM Policy Framework Participant" diff --git a/packages/policy-clamp-docker/src/main/docker/SimParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/SimParticipant.Dockerfile index 931c05669..3ee6e3192 100644 --- a/packages/policy-clamp-docker/src/main/docker/SimParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/SimParticipant.Dockerfile @@ -23,7 +23,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/sim-participant.tar.gz /packages/ RUN tar xvzf /packages/sim-participant.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:4.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:4.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy CLAMP ACM Simulator Participant" diff --git a/packages/policy-clamp-tarball/pom.xml b/packages/policy-clamp-tarball/pom.xml index 37dcd2dd4..a5d2ab908 100644 --- a/packages/policy-clamp-tarball/pom.xml +++ b/packages/policy-clamp-tarball/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>clamp-packages</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-tarball</artifactId> diff --git a/packages/pom.xml b/packages/pom.xml index 583832eb5..e1e89e94e 100644 --- a/packages/pom.xml +++ b/packages/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>clamp-packages</artifactId> diff --git a/participant/participant-impl/participant-impl-a1pms/pom.xml b/participant/participant-impl/participant-impl-a1pms/pom.xml index 189d201a6..f4a72e59c 100644 --- a/participant/participant-impl/participant-impl-a1pms/pom.xml +++ b/participant/participant-impl/participant-impl-a1pms/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-a1pms</artifactId> diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java index 5e3441d82..e599b7c43 100644 --- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.a1pms.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-acelement/pom.xml b/participant/participant-impl/participant-impl-acelement/pom.xml index 4bea98171..64f5653f5 100644 --- a/participant/participant-impl/participant-impl-acelement/pom.xml +++ b/participant/participant-impl/participant-impl-acelement/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-acm-element-impl</artifactId> diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java index d34b34add..5621587a2 100644 --- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.element.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-cds/pom.xml b/participant/participant-impl/participant-impl-cds/pom.xml index 38ed06919..86d9ee6d2 100644 --- a/participant/participant-impl/participant-impl-cds/pom.xml +++ b/participant/participant-impl/participant-impl-cds/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-cds</artifactId> diff --git a/participant/participant-impl/participant-impl-http/pom.xml b/participant/participant-impl/participant-impl-http/pom.xml index 5d9d7a0df..0f094db47 100644 --- a/participant/participant-impl/participant-impl-http/pom.xml +++ b/participant/participant-impl/participant-impl-http/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-http</artifactId> diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java index 06cecc6f5..ec9c95a19 100644 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.http.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-kserve/pom.xml b/participant/participant-impl/participant-impl-kserve/pom.xml index 2f6272b52..05cc2dcd2 100644 --- a/participant/participant-impl/participant-impl-kserve/pom.xml +++ b/participant/participant-impl/participant-impl-kserve/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-kserve</artifactId> @@ -52,7 +52,7 @@ <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> - <version>2022.0.5</version> + <version>2023.0.3</version> <type>pom</type> <scope>import</scope> </dependency> diff --git a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java index 92dc5d3d6..1192f7703 100644 --- a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.kserve.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-kubernetes/pom.xml b/participant/participant-impl/participant-impl-kubernetes/pom.xml index 1fe1c1bc5..fff3bd130 100644 --- a/participant/participant-impl/participant-impl-kubernetes/pom.xml +++ b/participant/participant-impl/participant-impl-kubernetes/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-kubernetes</artifactId> diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java index 0532dc97d..b4afe5e89 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.kubernetes.configurations; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-policy/pom.xml b/participant/participant-impl/participant-impl-policy/pom.xml index 41685817e..f01ce0565 100644 --- a/participant/participant-impl/participant-impl-policy/pom.xml +++ b/participant/participant-impl/participant-impl-policy/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-policy</artifactId> diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java index 2f942eaa8..de1242b9e 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.policy.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java index 34c195501..5a3bc6328 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java @@ -182,7 +182,7 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 { createPolicyResp = response.getStatus(); } } - if (createPolicyTypeResp == HttpStatus.SC_OK && createPolicyResp == HttpStatus.SC_OK) { + if (isSuccess(createPolicyTypeResp) && isSuccess(createPolicyResp)) { LOGGER.info( "PolicyTypes/Policies for the automation composition element : {} are created " + "successfully", instanceElement.elementId()); @@ -195,6 +195,10 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 { } } + private boolean isSuccess(int status) { + return status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED; + } + private List<ToscaConceptIdentifier> getPolicyTypeList(ToscaServiceTemplate serviceTemplate) { List<ToscaConceptIdentifier> policyTypeList = new ArrayList<>(); if (serviceTemplate.getPolicyTypes() != null) { diff --git a/participant/participant-impl/participant-impl-simulator/pom.xml b/participant/participant-impl/participant-impl-simulator/pom.xml index 49988df0b..26341e5f0 100644 --- a/participant/participant-impl/participant-impl-simulator/pom.xml +++ b/participant/participant-impl/participant-impl-simulator/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant-impl</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl-simulator</artifactId> diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java index 2a319c3bd..4ddec02e5 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.sim.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MicrometerConfig { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java index 4c7845143..4157bfd88 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,5 +41,5 @@ public class ParticipantSimParameters implements ParticipantParameters { @NotNull @Valid - private ParticipantIntermediaryParameters intermediaryParameters; + private ParticipantIntermediaryParameters intermediaryParameters = new ParticipantIntermediaryParameters(); } diff --git a/participant/participant-impl/pom.xml b/participant/participant-impl/pom.xml index 5961b90cd..3ee6db78e 100644 --- a/participant/participant-impl/pom.xml +++ b/participant/participant-impl/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-impl</artifactId> diff --git a/participant/participant-intermediary/pom.xml b/participant/participant-intermediary/pom.xml index 97c98f6dd..d16e17a86 100644 --- a/participant/participant-intermediary/pom.xml +++ b/participant/participant-intermediary/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.clamp.participant</groupId> <artifactId>policy-clamp-participant</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-participant-intermediary</artifactId> diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java index 1c36ad17f..47fa7754e 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java @@ -62,6 +62,6 @@ public class ParticipantIntermediaryParameters { @NotNull @Valid - private Topics topics; + private Topics topics = new Topics(); } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/Topics.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/Topics.java index ddf72052f..7a93255b0 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/Topics.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/Topics.java @@ -24,6 +24,7 @@ import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; /** @@ -32,6 +33,7 @@ import lombok.Setter; @Getter @Setter @AllArgsConstructor +@NoArgsConstructor public class Topics { @NotNull diff --git a/participant/pom.xml b/participant/pom.xml index 63c4826a4..fdbd154b8 100644 --- a/participant/pom.xml +++ b/participant/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <groupId>org.onap.policy.clamp.participant</groupId> @@ -23,12 +23,12 @@ <parent> <groupId>org.onap.policy.parent</groupId> <artifactId>integration</artifactId> - <version>5.0.0-SNAPSHOT</version> + <version>5.0.1-SNAPSHOT</version> <relativePath /> </parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> <name>${project.artifactId}</name> <packaging>pom</packaging> <description> @@ -50,8 +50,8 @@ o policy-clamp-participant-impl-kserve: A standard participant for Kserve </description> <properties> - <policy.common.version>3.0.0-SNAPSHOT</policy.common.version> - <policy.models.version>4.0.0-SNAPSHOT</policy.models.version> + <policy.common.version>3.0.1-SNAPSHOT</policy.common.version> + <policy.models.version>4.0.1-SNAPSHOT</policy.models.version> </properties> <modules> <module>common</module> diff --git a/releases/8.0.0-container.yaml b/releases/8.0.0-container.yaml new file mode 100644 index 000000000..3a16df393 --- /dev/null +++ b/releases/8.0.0-container.yaml @@ -0,0 +1,22 @@ +distribution_type: 'container' +container_release_tag: '8.0.0' +project: 'policy-clamp' +log_dir: 'policy-clamp-maven-docker-stage-master/878' +ref: e197a0b95b5df5c0a37f7f420be8851920ca204b +containers: + - name: 'policy-clamp-ac-pf-ppnt' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-ac-k8s-ppnt' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-ac-http-ppnt' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-ac-a1pms-ppnt' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-runtime-acm' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-acm-element-impl' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-ac-kserve-ppnt' + version: '8.0.0-20240712T1140' + - name: 'policy-clamp-ac-sim-ppnt' + version: '8.0.0-20240712T1140' diff --git a/releases/8.0.0.yaml b/releases/8.0.0.yaml new file mode 100644 index 000000000..0573c08eb --- /dev/null +++ b/releases/8.0.0.yaml @@ -0,0 +1,5 @@ +distribution_type: 'maven' +version: '8.0.0' +project: 'policy-clamp' +tag_release: false +log_dir: 'policy-clamp-maven-stage-master/884/' diff --git a/runtime-acm/pom.xml b/runtime-acm/pom.xml index 1110b3a6c..82283eaf7 100644 --- a/runtime-acm/pom.xml +++ b/runtime-acm/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.policy.clamp</groupId> <artifactId>policy-clamp</artifactId> - <version>8.0.0-SNAPSHOT</version> + <version>8.0.1-SNAPSHOT</version> </parent> <artifactId>policy-clamp-runtime-acm</artifactId> @@ -139,7 +139,6 @@ <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> - <version>${version.jupiter}</version> <scope>test</scope> </dependency> <dependency> diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java index 084f7c774..f5c8368e2 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.config; import io.micrometer.core.aop.TimedAspect; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,8 +35,9 @@ public class MetricsConfiguration { * Load up the metrics registry. */ @Bean - public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, - MeterRegistry registry) { + public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor") + BeanPostProcessor meterRegistryPostProcessor, + MeterRegistry registry) { return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, ""); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/OpenTelConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/OpenTelConfiguration.java index 3727333a4..05d47d4f7 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/OpenTelConfiguration.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/OpenTelConfiguration.java @@ -35,7 +35,7 @@ import org.springframework.context.annotation.Configuration; public class OpenTelConfiguration { @Bean - @ConditionalOnProperty(prefix = "tracing", name = "enabled", havingValue = "true", matchIfMissing = false) + @ConditionalOnProperty(prefix = "tracing", name = "enabled", havingValue = "true") @ConditionalOnExpression("'http'.equals('${tracing.exporter.protocol}')") OtlpHttpSpanExporter otlpHttpSpanExporter(@Value("${tracing.exporter.endpoint:http://jaeger:4318/v1/traces}") String url) { return OtlpHttpSpanExporter.builder() @@ -44,7 +44,7 @@ public class OpenTelConfiguration { } @Bean - @ConditionalOnProperty(prefix = "tracing", name = "enabled", havingValue = "true", matchIfMissing = false) + @ConditionalOnProperty(prefix = "tracing", name = "enabled", havingValue = "true") @ConditionalOnExpression("'grpc'.equals('${tracing.exporter.protocol}')") OtlpGrpcSpanExporter otlpGrpcSpanExporter(@Value("${tracing.exporter.endpoint:http://jaeger:4317}") String url) { return OtlpGrpcSpanExporter.builder() @@ -53,7 +53,7 @@ public class OpenTelConfiguration { } @Bean - @ConditionalOnProperty(prefix = "tracing", name = "enabled", havingValue = "true", matchIfMissing = false) + @ConditionalOnProperty(prefix = "tracing", name = "enabled", havingValue = "true") JaegerRemoteSampler jaegerRemoteSampler( @Value("${tracing.sampler.jaeger-remote.endpoint:http://jaeger:14250}") String url, @Value("${SERVICE_ID:unknown_service}") String serviceId) { diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java index a3e55c3f7..ff1f60b69 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivator.java @@ -22,7 +22,6 @@ package org.onap.policy.clamp.acm.runtime.config.messaging; import java.io.Closeable; -import java.io.IOException; import java.util.List; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -139,7 +138,7 @@ public class MessageDispatcherActivator extends ServiceManagerContainer implemen } @Override - public void close() throws IOException { + public void close() { if (isAlive()) { super.shutdown(); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java index a0b6fe13e..e6ce61438 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java @@ -53,5 +53,5 @@ public class AcRuntimeParameterGroup { @Valid @NotNull - private Topics topics; + private Topics topics = new Topics(); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/Topics.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/Topics.java index d485a24ba..6e230d3df 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/Topics.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/Topics.java @@ -20,6 +20,7 @@ package org.onap.policy.clamp.acm.runtime.main.parameters; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.springframework.validation.annotation.Validated; @@ -27,6 +28,7 @@ import org.springframework.validation.annotation.Validated; @Setter @Validated @AllArgsConstructor +@NoArgsConstructor public class Topics { private String operationTopic; diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java index 3e2057ed5..75477866a 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java @@ -247,8 +247,7 @@ public class SupervisionAcHandler { for (var element : automationComposition.getElements().values()) { if (element.getParticipantId().equals(automationCompositionAckMessage.getParticipantId())) { element.setDeployState(DeployState.DELETED); - automationCompositionProvider.updateAutomationCompositionElement(element, - automationComposition.getInstanceId()); + automationCompositionProvider.updateAutomationCompositionElement(element); } } } else { @@ -263,7 +262,7 @@ public class SupervisionAcHandler { automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet(), automationCompositionAckMessage.getStateChangeResult()); if (updated) { - automationCompositionProvider.updateAutomationComposition(automationComposition); + automationComposition = automationCompositionProvider.updateAcState(automationComposition); var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()); participantSyncPublisher.sendSync(acDefinition.getServiceTemplate(), automationComposition); } @@ -289,8 +288,7 @@ public class SupervisionAcHandler { element.setDeployState(acElementAck.getValue().getDeployState()); element.setLockState(acElementAck.getValue().getLockState()); element.setRestarting(null); - automationCompositionProvider.updateAutomationCompositionElement(element, - automationComposition.getInstanceId()); + automationCompositionProvider.updateAutomationCompositionElement(element); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java index 75a2f0540..d1aa6c239 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java @@ -201,12 +201,13 @@ public class SupervisionScanner { if (StateChangeResult.TIMEOUT.equals(automationComposition.getStateChangeResult())) { automationComposition.setStateChangeResult(StateChangeResult.NO_ERROR); } + var acToUpdate = automationComposition; if (DeployState.DELETED.equals(automationComposition.getDeployState())) { automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId()); } else { - automationCompositionProvider.updateAutomationComposition(automationComposition); + acToUpdate = automationCompositionProvider.updateAcState(acToUpdate); } - participantSyncPublisher.sendSync(serviceTemplate, automationComposition); + participantSyncPublisher.sendSync(serviceTemplate, acToUpdate); } private void handleTimeout(AutomationCompositionDefinition acDefinition) { diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java index 338f2960d..cc5d1461f 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java @@ -56,7 +56,7 @@ public class AcElementPropertiesPublisher extends AbstractParticipantPublisher<P propertiesUpdate.setParticipantUpdatesList( AcmUtils.createParticipantDeployList(automationComposition, DeployOrder.UPDATE)); - LOGGER.debug("AC Element properties update sent {}", propertiesUpdate); + LOGGER.debug("AC Element properties update sent {}", propertiesUpdate.getMessageId()); super.send(propertiesUpdate); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java index 2b6435e67..7fe63a7c5 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java @@ -87,7 +87,7 @@ public class AutomationCompositionDeployPublisher extends AbstractParticipantPub acDeployMsg.setTimestamp(Instant.now()); acDeployMsg.setParticipantUpdatesList(participantDeploys); - LOGGER.debug("AutomationCompositionDeploy message sent {}", acDeployMsg); + LOGGER.debug("AutomationCompositionDeploy message sent {}", acDeployMsg.getMessageId()); super.send(acDeployMsg); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java index b0848bd51..360e526cc 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java @@ -72,7 +72,7 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part message.setParticipantId(participantId); message.setTimestamp(Instant.now()); message.setParticipantDefinitionUpdates(participantDefinitions); - LOGGER.debug("Participant Update sent {}", message); + LOGGER.debug("Participant Update sent {}", message.getMessageId()); super.send(message); } @@ -127,7 +127,7 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part // DeCommission the automation composition but deleting participantdefinitions on participants message.setParticipantDefinitionUpdates(null); - LOGGER.debug("Participant Update sent {}", message); + LOGGER.debug("Participant Update sent {}", message.getMessageId()); super.send(message); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java index 96d6338f1..540cf62be 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java @@ -69,7 +69,7 @@ public class ParticipantRestartPublisher extends AbstractParticipantPublisher<Pa message.getAutomationcompositionList().add(restartAc); } - LOGGER.debug("Participant Restart sent {}", message); + LOGGER.debug("Participant Restart sent {}", message.getMessageId()); super.send(message); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java index 1f6b7c8a5..96abac494 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java @@ -44,7 +44,7 @@ public class ParticipantStatusReqPublisher extends AbstractParticipantPublisher< message.setParticipantId(participantId); message.setTimestamp(Instant.now()); - LOGGER.debug("Participant StatusReq sent {}", message); + LOGGER.debug("Participant StatusReq sent {}", message.getMessageId()); super.send(message); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java index b63bc0a6b..eb1db6f0e 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java @@ -144,7 +144,7 @@ public class ParticipantSyncPublisher extends AbstractParticipantPublisher<Parti } message.getAutomationcompositionList().add(syncAc); - LOGGER.debug("Participant AutomationComposition Sync sent {}", message); + LOGGER.debug("Participant AutomationComposition Sync sent {}", message.getMessageId()); super.send(message); } } diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml index 0e2585dba..bca01ace8 100644 --- a/runtime-acm/src/main/resources/application.yaml +++ b/runtime-acm/src/main/resources/application.yaml @@ -44,21 +44,18 @@ runtime: maxStatusWaitMs: 200000 topicParameterGroup: topicSources: - - - topic: ${runtime.topics.operationTopic} + - topic: ${runtime.topics.operationTopic} servers: - ${topicServer:kafka:9092} topicCommInfrastructure: NOOP fetchTimeout: 15000 topicSinks: - - - topic: ${runtime.topics.operationTopic} + - topic: ${runtime.topics.operationTopic} servers: - ${topicServer:kafka:9092} topicCommInfrastructure: NOOP - - - topic: ${runtime.topics.syncTopic} + - topic: ${runtime.topics.syncTopic} servers: - ${topicServer:kafka:9092} topicCommInfrastructure: NOOP diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java index 413719110..e001d91bc 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.commissioning; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; @@ -53,8 +54,6 @@ class CommissioningProviderTest { /** * Test the fetching of automation composition definitions (ToscaServiceTemplates). - * - * @throws Exception . */ @Test void testGetAutomationCompositionDefinitions() { @@ -63,7 +62,7 @@ class CommissioningProviderTest { var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class); var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, - acRuntimeParameterGroup); + acRuntimeParameterGroup); var serviceTemplates = provider.getAutomationCompositionDefinitions(null, null); assertThat(serviceTemplates.getServiceTemplates()).isEmpty(); @@ -75,12 +74,11 @@ class CommissioningProviderTest { /** * Test the creation of automation composition definitions (ToscaServiceTemplates). - * - * @throws Exception . */ @Test void testCreateAutomationCompositionDefinitions() { var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + assertNotNull(serviceTemplate); serviceTemplate.setName("Name"); serviceTemplate.setVersion("1.0.0"); var acmDefinition = new AutomationCompositionDefinition(); @@ -88,15 +86,15 @@ class CommissioningProviderTest { acmDefinition.setServiceTemplate(serviceTemplate); var acDefinitionProvider = mock(AcDefinitionProvider.class); when(acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate, - CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME)).thenReturn(acmDefinition); + CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME)).thenReturn(acmDefinition); var acProvider = mock(AutomationCompositionProvider.class); var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, - CommonTestData.getTestParamaterGroup()); + CommonTestData.getTestParamaterGroup()); var affectedDefinitions = provider.createAutomationCompositionDefinition(serviceTemplate) - .getAffectedAutomationCompositionDefinitions(); + .getAffectedAutomationCompositionDefinitions(); verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate, - CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME); + CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME); // Response should return the number of node templates present in the service template assertThat(affectedDefinitions).hasSize(7); } @@ -104,7 +102,6 @@ class CommissioningProviderTest { /** * Test the fetching of a full ToscaServiceTemplate object - as opposed to the reduced template that is being * tested in the testGetToscaServiceTemplateReduced() test. - * */ @Test void testGetToscaServiceTemplateList() { @@ -113,6 +110,7 @@ class CommissioningProviderTest { var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null); var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + assertNotNull(serviceTemplate); when(acDefinitionProvider.getServiceTemplateList(null, null)).thenReturn(List.of(serviceTemplate)); var returnedServiceTemplate = provider.getAutomationCompositionDefinitions(null, null); @@ -121,7 +119,7 @@ class CommissioningProviderTest { } @Test - void testDeletecDefinitionDabRequest() { + void testDeleteAcDefinitionDabRequest() { var acDefinitionProvider = mock(AcDefinitionProvider.class); var acProvider = mock(AutomationCompositionProvider.class); @@ -131,7 +129,7 @@ class CommissioningProviderTest { var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null); assertThatThrownBy(() -> provider.deleteAutomationCompositionDefinition(compositionId)) - .hasMessageMatching("Delete instances, to commission automation composition definitions"); + .hasMessageMatching("Delete instances, to commission automation composition definitions"); } @Test @@ -139,6 +137,7 @@ class CommissioningProviderTest { var acDefinitionProvider = mock(AcDefinitionProvider.class); var compositionId = UUID.randomUUID(); var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + assertNotNull(serviceTemplate); when(acDefinitionProvider.deleteAcDefintion(compositionId)).thenReturn(serviceTemplate); var acmDefinition = new AutomationCompositionDefinition(); @@ -159,14 +158,14 @@ class CommissioningProviderTest { void testPriming() { var acDefinitionProvider = mock(AcDefinitionProvider.class); var acmDefinition = CommonTestData.createAcDefinition( - InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML), AcTypeState.COMMISSIONED); + InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML), AcTypeState.COMMISSIONED); var compositionId = acmDefinition.getCompositionId(); when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var participantPrimePublisher = mock(ParticipantPrimePublisher.class); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(ParticipantProvider.class), new AcTypeStateResolver(), participantPrimePublisher, - CommonTestData.getTestParamaterGroup()); + mock(ParticipantProvider.class), new AcTypeStateResolver(), participantPrimePublisher, + CommonTestData.getTestParamaterGroup()); var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.PRIME); @@ -179,15 +178,15 @@ class CommissioningProviderTest { void testDepriming() { var acDefinitionProvider = mock(AcDefinitionProvider.class); var acmDefinition = CommonTestData.createAcDefinition( - InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML), AcTypeState.PRIMED); + InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML), AcTypeState.PRIMED); var compositionId = acmDefinition.getCompositionId(); when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var participantPrimePublisher = mock(ParticipantPrimePublisher.class); var participantProvider = mock(ParticipantProvider.class); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - participantProvider, new AcTypeStateResolver(), participantPrimePublisher, - CommonTestData.getTestParamaterGroup()); + participantProvider, new AcTypeStateResolver(), participantPrimePublisher, + CommonTestData.getTestParamaterGroup()); var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.DEPRIME); @@ -201,19 +200,19 @@ class CommissioningProviderTest { void testBadRequest() { var acProvider = mock(AutomationCompositionProvider.class); var provider = new CommissioningProvider(mock(AcDefinitionProvider.class), acProvider, - mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), - mock(AcRuntimeParameterGroup.class)); + mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), + mock(AcRuntimeParameterGroup.class)); var compositionId = UUID.randomUUID(); when(acProvider.getAcInstancesByCompositionId(compositionId)).thenReturn(List.of(new AutomationComposition())); var toscaServiceTemplate = new ToscaServiceTemplate(); assertThatThrownBy(() -> provider.updateCompositionDefinition(compositionId, toscaServiceTemplate)) - .hasMessageMatching("There are ACM instances, Update of ACM Definition not allowed"); + .hasMessageMatching("There are ACM instances, Update of ACM Definition not allowed"); var acTypeStateUpdate = new AcTypeStateUpdate(); assertThatThrownBy(() -> provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate)) - .hasMessageMatching("There are instances, Priming/Depriming not allowed"); + .hasMessageMatching("There are instances, Priming/Depriming not allowed"); } @Test @@ -225,14 +224,14 @@ class CommissioningProviderTest { when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), - mock(AcRuntimeParameterGroup.class)); + mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), + mock(AcRuntimeParameterGroup.class)); assertThatThrownBy(() -> provider.updateCompositionDefinition(compositionId, toscaServiceTemplate)) - .hasMessageMatching("ACM not in COMMISSIONED state, Update of ACM Definition not allowed"); + .hasMessageMatching("ACM not in COMMISSIONED state, Update of ACM Definition not allowed"); assertThatThrownBy(() -> provider.deleteAutomationCompositionDefinition(compositionId)) - .hasMessageMatching("ACM not in COMMISSIONED state, Delete of ACM Definition not allowed"); + .hasMessageMatching("ACM not in COMMISSIONED state, Delete of ACM Definition not allowed"); } @Test @@ -245,11 +244,11 @@ class CommissioningProviderTest { when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), - mock(AcRuntimeParameterGroup.class)); + mock(ParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), + mock(AcRuntimeParameterGroup.class)); var acTypeStateUpdate = new AcTypeStateUpdate(); assertThatThrownBy(() -> provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate)) - .hasMessageMatching("There is a restarting process, Priming/Depriming not allowed"); + .hasMessageMatching("There is a restarting process, Priming/Depriming not allowed"); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java index ed8badf8b..16de37e7f 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ import jakarta.ws.rs.core.Response; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -61,7 +62,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ActiveProfiles({ "test", "default" }) +@ActiveProfiles({"test", "default"}) class CommissioningControllerTest extends CommonRestController { private static final String COMMISSIONING_ENDPOINT = "compositions"; @@ -72,6 +73,7 @@ class CommissioningControllerTest extends CommonRestController { @Autowired private ParticipantProvider participantProvider; + @LocalServerPort private int randomServerPort; @@ -88,6 +90,11 @@ class CommissioningControllerTest extends CommonRestController { super.setHttpPrefix(randomServerPort); } + @AfterEach + void after() { + super.client.close(); + } + @Test void testSwagger() { super.testSwagger(COMMISSIONING_ENDPOINT); @@ -111,15 +118,16 @@ class CommissioningControllerTest extends CommonRestController { @Test void testCreateBadRequest() { var invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); - var resp = invocationBuilder.post(Entity.json("NotToscaServiceTempalte")); + var resp = invocationBuilder.post(Entity.json("NotToscaServiceTemplate")); assertThat(Response.Status.BAD_REQUEST.getStatusCode()).isEqualTo(resp.getStatus()); var commissioningResponse = resp.readEntity(CommissioningResponse.class); assertThat(commissioningResponse.getErrorDetails()) .isEqualTo("org.springframework.http.converter.HttpMessageNotReadableException " - + "Bad Request Could not read JSON: java.lang.IllegalStateException: " + + "Could not read JSON: java.lang.IllegalStateException: " + "Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $"); assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).isNull(); + resp.close(); } @Test @@ -132,7 +140,7 @@ class CommissioningControllerTest extends CommonRestController { var commissioningResponse = createServiceTemplate(serviceTemplateCreate, Response.Status.INTERNAL_SERVER_ERROR); assertThat(commissioningResponse.getErrorDetails()) - .isEqualTo("java.lang.IllegalArgumentException Internal Server Error parameter " + .isEqualTo("java.lang.IllegalArgumentException parameter " + "\"version\": value \"1.0.wrong\", does not match regular expression \"" + PfKey.VERSION_REGEXP + "\""); assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).isNull(); @@ -149,7 +157,7 @@ class CommissioningControllerTest extends CommonRestController { assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).hasSize(7); for (var nodeTemplateName : serviceTemplateCreate.getToscaTopologyTemplate().getNodeTemplates().keySet()) { assertTrue(commissioningResponse.getAffectedAutomationCompositionDefinitions().stream() - .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); + .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); } } @@ -161,6 +169,7 @@ class CommissioningControllerTest extends CommonRestController { assertNull(commissioningResponse.getErrorDetails()); // Response should return the number of node templates present in the service template assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).hasSize(11); + assertNotNull(serviceTemplateCreate); for (var nodeTemplateName : serviceTemplateCreate.getToscaTopologyTemplate().getNodeTemplates().keySet()) { assertTrue(commissioningResponse.getAffectedAutomationCompositionDefinitions().stream() .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); @@ -168,7 +177,7 @@ class CommissioningControllerTest extends CommonRestController { } private CommissioningResponse createServiceTemplate(ToscaServiceTemplate serviceTemplateCreate, - Response.Status statusExpected) { + Response.Status statusExpected) { var invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT); try (var resp = invocationBuilder.post(Entity.json(serviceTemplateCreate))) { assertEquals(statusExpected.getStatusCode(), resp.getStatus()); @@ -199,17 +208,17 @@ class CommissioningControllerTest extends CommonRestController { assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).hasSize(7); for (var nodeTemplateName : serviceTemplateUpdate.getToscaTopologyTemplate().getNodeTemplates().keySet()) { assertTrue(commissioningResponse.getAffectedAutomationCompositionDefinitions().stream() - .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); + .anyMatch(ac -> ac.getName().equals(nodeTemplateName))); } - var entity = getServiceTemplate(COMMISSIONING_ENDPOINT + "/" + compositionId, Response.Status.OK); + var entity = getServiceTemplate(COMMISSIONING_ENDPOINT + "/" + compositionId); assertThat(entity.getServiceTemplate().getDataTypes()).containsKey(toscaDataType.getName()); } - private AutomationCompositionDefinition getServiceTemplate(String url, Response.Status statusExpected) { + private AutomationCompositionDefinition getServiceTemplate(String url) { var invocationBuilder = super.sendRequest(url); try (var resp = invocationBuilder.buildGet().invoke()) { - assertEquals(statusExpected.getStatusCode(), resp.getStatus()); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); return resp.readEntity(AutomationCompositionDefinition.class); } } @@ -221,6 +230,7 @@ class CommissioningControllerTest extends CommonRestController { assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); var entityList = rawresp.readEntity(ToscaServiceTemplate.class); assertThat(entityList.getNodeTypes()).isNull(); + rawresp.close(); } @Test @@ -232,6 +242,7 @@ class CommissioningControllerTest extends CommonRestController { assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); var entityList = rawresp.readEntity(ToscaServiceTemplate.class); assertNotNull(entityList); + rawresp.close(); } @Test @@ -264,14 +275,15 @@ class CommissioningControllerTest extends CommonRestController { body.setPrimeOrder(PrimeOrder.PRIME); var resp = invocationBuilder.put(Entity.json(body)); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); + resp.close(); } private UUID createEntryInDB(String name) { var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate); serviceTemplateCreate.setName(name); var acmDefinition = acDefinitionProvider - .createAutomationCompositionDefinition(serviceTemplateCreate, CommonTestData.TOSCA_ELEMENT_NAME, - CommonTestData.TOSCA_COMP_NAME); + .createAutomationCompositionDefinition(serviceTemplateCreate, CommonTestData.TOSCA_ELEMENT_NAME, + CommonTestData.TOSCA_COMP_NAME); return acmDefinition.getCompositionId(); } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/TestOpenTelemetry.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/TestOpenTelemetry.java new file mode 100644 index 000000000..8996d77cd --- /dev/null +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/TestOpenTelemetry.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START=============================================== + * Copyright (C) 2024 Nordix Foundation. + * ======================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END================================================= + */ + +package org.onap.policy.clamp.acm.runtime.config; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ActiveProfiles; + +@ActiveProfiles("tracing") +@SpringBootTest(classes = OpenTelConfiguration.class) +class TestOpenTelemetry { + + @Autowired + ApplicationContext context; + + @Test + void testOpenTelemetry() { + assertThat(context).isNotNull(); + assertTrue(context.containsBean("otlpGrpcSpanExporter")); + assertTrue(context.containsBean("jaegerRemoteSampler")); + assertFalse(context.containsBean("otlpHttpSpanExporter")); + } +} diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java index bdfaedc04..18911f461 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,84 +20,62 @@ package org.onap.policy.clamp.acm.runtime.main.rest; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.TEXT_PLAIN; -import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.web.reactive.function.client.ExchangeFilterFunctions; -@AutoConfigureObservability(tracing = false) -@ExtendWith(SpringExtension.class) +@AutoConfigureObservability +@AutoConfigureWebTestClient @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ActiveProfiles({ "test", "default" }) -class ActuatorControllerTest extends CommonRestController { +@ActiveProfiles("test") +class ActuatorControllerTest { - private static final String HEALTH_ENDPOINT = "health"; - private static final String METRICS_ENDPOINT = "metrics"; - private static final String PROMETHEUS_ENDPOINT = "prometheus"; - private static final String SWAGGER_ENDPOINT = "v3/api-docs"; + @Autowired + WebTestClient webClient; - @LocalServerPort - private int randomServerPort; + @Value("${spring.security.user.name}") + String username; + @Value("${spring.security.user.password}") + String password; @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } - - @Test - void testGetHealth_Unauthorized() { - assertUnauthorizedActGet(HEALTH_ENDPOINT); - } - - @Test - void testGetMetrics_Unauthorized() { - assertUnauthorizedActGet(METRICS_ENDPOINT); - } - - @Test - void testGetPrometheus_Unauthorized() { - assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); - } - - @Test - void testGetSwagger_Unauthorized() { - assertUnauthorizedActGet(SWAGGER_ENDPOINT); + void beforeEach() { + var filter = ExchangeFilterFunctions.basicAuthentication(username, password); + webClient = webClient.mutate().filter(filter).build(); } @Test void testGetHealth() { - var invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + webClient.get().uri("/health").accept(APPLICATION_JSON) + .exchange().expectStatus().isOk(); } @Test void testGetMetrics() { - var invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + webClient.get().uri("/metrics").accept(APPLICATION_JSON) + .exchange().expectStatus().isOk(); } @Test void testGetPrometheus() { - var invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + webClient.get().uri("/prometheus").accept(TEXT_PLAIN) + .exchange().expectStatus().isOk(); } @Test void testGetSwagger() { - var invocationBuilder = super.sendActRequest(SWAGGER_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + webClient.get().uri("/v3/api-docs").accept(APPLICATION_JSON) + .exchange().expectStatus().isOk(); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/PrometheusNoAuthTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/PrometheusNoAuthTest.java index 5b94814fb..87e43ea8c 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/PrometheusNoAuthTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/PrometheusNoAuthTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,39 +20,29 @@ package org.onap.policy.clamp.acm.runtime.main.rest; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.http.MediaType.TEXT_PLAIN; -import jakarta.ws.rs.client.Invocation; -import jakarta.ws.rs.core.Response; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.reactive.server.WebTestClient; @AutoConfigureObservability(tracing = false) @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles({ "prometheus-noauth", "default" }) -class PrometheusNoAuthTest extends CommonRestController { - private static final String PROMETHEUS_ENDPOINT = "prometheus"; +@ActiveProfiles({"prometheus-noauth", "default"}) +class PrometheusNoAuthTest { - @LocalServerPort - private int randomServerPort; - - @BeforeEach - public void setUpPort() { - super.setHttpPrefix(randomServerPort); - } + @Autowired + WebTestClient webClient; @Test - void testGetPrometheusNoAuth() { - Invocation.Builder invocationBuilder = super.sendNoAuthActRequest(PROMETHEUS_ENDPOINT); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + void testGetPrometheus() { + webClient.get().uri("/prometheus").accept(TEXT_PLAIN) + .exchange().expectStatus().isOk(); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java index 0bec9d0ce..e895401a4 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java @@ -66,6 +66,8 @@ class SupervisionAcHandlerTest { var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.findAutomationComposition(IDENTIFIER)) .thenReturn(Optional.of(automationComposition)); + when(automationCompositionProvider.updateAcState(any(AutomationComposition.class))) + .thenReturn(automationComposition); var acDefinitionProvider = mock(AcDefinitionProvider.class); when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())) @@ -82,7 +84,7 @@ class SupervisionAcHandlerTest { handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage); verify(automationCompositionProvider, times(3)) - .updateAutomationCompositionElement(any(AutomationCompositionElement.class), any()); + .updateAutomationCompositionElement(any(AutomationCompositionElement.class)); } private AutomationCompositionDeployAck getAutomationCompositionDeployAck(ParticipantMessageType messageType, @@ -107,6 +109,8 @@ class SupervisionAcHandlerTest { var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.findAutomationComposition(IDENTIFIER)) .thenReturn(Optional.of(automationComposition)); + when(automationCompositionProvider.updateAcState(any(AutomationComposition.class))) + .thenReturn(automationComposition); var acDefinitionProvider = mock(AcDefinitionProvider.class); when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())) @@ -124,7 +128,7 @@ class SupervisionAcHandlerTest { handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage); - verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class)); + verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class)); } @Test @@ -162,7 +166,7 @@ class SupervisionAcHandlerTest { handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage); verify(automationCompositionProvider) - .updateAutomationCompositionElement(any(AutomationCompositionElement.class), any()); + .updateAutomationCompositionElement(any(AutomationCompositionElement.class)); } @Test @@ -322,7 +326,7 @@ class SupervisionAcHandlerTest { handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage); verify(automationCompositionProvider) - .updateAutomationCompositionElement(any(AutomationCompositionElement.class), any()); + .updateAutomationCompositionElement(any(AutomationCompositionElement.class)); } @Test diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java index fa5929f0b..6bdab706c 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java @@ -186,6 +186,7 @@ class SupervisionScannerTest { automationComposition.setCompositionId(compositionId); var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.getAcInstancesInTransition()).thenReturn(List.of(automationComposition)); + when(automationCompositionProvider.updateAcState(any())).thenReturn(automationComposition); var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); @@ -196,7 +197,7 @@ class SupervisionScannerTest { mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup); supervisionScanner.run(); - verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class)); + verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class)); } @Test @@ -255,7 +256,7 @@ class SupervisionScannerTest { var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.getAcInstancesInTransition()).thenReturn(List.of(automationComposition)); - + when(automationCompositionProvider.updateAcState(any())).thenReturn(automationComposition); var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); @@ -282,7 +283,7 @@ class SupervisionScannerTest { entry.getValue().setDeployState(DeployState.DEPLOYED); } scannerObj2.run(); - verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class)); + verify(automationCompositionProvider, times(1)).updateAcState(any(AutomationComposition.class)); assertEquals(StateChangeResult.NO_ERROR, automationComposition.getStateChangeResult()); } @@ -341,6 +342,7 @@ class SupervisionScannerTest { var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.getAcInstancesInTransition()).thenReturn(List.of(automationComposition)); + when(automationCompositionProvider.updateAcState(any())).thenReturn(automationComposition); var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); @@ -358,7 +360,7 @@ class SupervisionScannerTest { automationComposition.getElements().entrySet().iterator().next().getValue() .setDeployState(DeployState.DEPLOYED); supervisionScanner.run(); - verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class)); + verify(automationCompositionProvider, times(1)).updateAcState(any(AutomationComposition.class)); assertEquals(DeployState.DEPLOYED, automationComposition.getDeployState()); assertEquals(compositionTargetId, automationComposition.getCompositionId()); diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java index 0df9719c2..9c765e1b3 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.util.rest; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.ClientBuilder; import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.Invocation; @@ -45,6 +46,7 @@ public class CommonRestController { public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/"; private static String httpPrefix; + protected Client client; /** * Verifies that an endpoint appears within the swagger response. @@ -52,7 +54,7 @@ public class CommonRestController { * @param endpoint the endpoint of interest */ protected void testSwagger(final String endpoint) { - final var invocationBuilder = sendActRequest("v3/api-docs"); + final var invocationBuilder = sendActRequest(); final var resp = invocationBuilder.get(String.class); assertThat(resp).contains(endpoint); @@ -71,15 +73,14 @@ public class CommonRestController { /** * Sends a request to an actuator endpoint. * - * @param endpoint the target endpoint * @return a request builder */ - protected Invocation.Builder sendActRequest(final String endpoint) { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true); + protected Invocation.Builder sendActRequest() { + return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + "v3/api-docs", true); } /** - * Sends a request to an Rest Api endpoint, without any authorization header. + * Sends a request to a Rest Api endpoint, without any authorization header. * * @param endpoint the target endpoint * @return a request builder @@ -89,16 +90,6 @@ public class CommonRestController { } /** - * Sends a request to an actuator endpoint, without any authorization header. - * - * @param endpoint the target endpoint - * @return a request builder - */ - protected Invocation.Builder sendNoAuthActRequest(final String endpoint) { - return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false); - } - - /** * Sends a request to a fully qualified endpoint. * * @param fullyQualifiedEndpoint the fully qualified target endpoint @@ -106,7 +97,7 @@ public class CommonRestController { * @return a request builder */ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) { - final var client = ClientBuilder.newBuilder().build(); + client = ClientBuilder.newBuilder().build(); client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true"); client.register(GsonMessageBodyHandler.class); @@ -124,11 +115,12 @@ public class CommonRestController { * Assert that POST call is Unauthorized. * * @param endPoint the endpoint - * @param entity the entity ofthe body + * @param entity the entity of the body */ protected void assertUnauthorizedPost(final String endPoint, final Entity<?> entity) { var rawresp = sendNoAuthRequest(endPoint).post(entity); assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + rawresp.close(); } /** @@ -140,6 +132,7 @@ public class CommonRestController { protected void assertUnauthorizedPut(final String endPoint, final Entity<?> entity) { var rawresp = sendNoAuthRequest(endPoint).put(entity); assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + rawresp.close(); } /** @@ -150,16 +143,7 @@ public class CommonRestController { protected void assertUnauthorizedGet(final String endPoint) { var rawresp = sendNoAuthRequest(endPoint).buildGet().invoke(); assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); - } - - /** - * Assert that GET call to actuator endpoint is Unauthorized. - * - * @param endPoint the endpoint - */ - protected void assertUnauthorizedActGet(final String endPoint) { - var rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke(); - assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + rawresp.close(); } /** @@ -170,6 +154,7 @@ public class CommonRestController { protected void assertUnauthorizedDelete(final String endPoint) { var rawresp = sendNoAuthRequest(endPoint).delete(); assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus()); + rawresp.close(); } /** @@ -181,7 +166,4 @@ public class CommonRestController { httpPrefix = "http://" + SELF + ":" + port + "/"; } - protected String getHttpPrefix() { - return httpPrefix; - } } diff --git a/runtime-acm/src/test/resources/application-prometheus-noauth.yaml b/runtime-acm/src/test/resources/application-prometheus-noauth.yaml index 57da3af18..a75c5d36f 100644 --- a/runtime-acm/src/test/resources/application-prometheus-noauth.yaml +++ b/runtime-acm/src/test/resources/application-prometheus-noauth.yaml @@ -10,37 +10,6 @@ spring: ddl-auto: create open-in-view: false -server: - servlet: - context-path: /onap/policy/clamp/acm - -runtime: - topics: - operationTopic: policy-acruntime-participant - syncTopic: acm-ppnt-sync - participantParameters: - updateParameters: - maxRetryCount: 3 - topicParameterGroup: - topicSources: - - - topic: ${runtime.topics.operationTopic} - servers: - - localhost - topicCommInfrastructure: noop - fetchTimeout: 15000 - topicSinks: - - - topicCommInfrastructure: noop - servers: - - localhost - topic: ${runtime.topics.operationTopic} - - - topic: ${runtime.topics.syncTopic} - servers: - - ${topicServer:kafka:9092} - topicCommInfrastructure: noop - tracing: enabled: true exporter: diff --git a/runtime-acm/src/test/resources/application-test.yaml b/runtime-acm/src/test/resources/application-test.yaml index 31e54737e..e3d4a48df 100644 --- a/runtime-acm/src/test/resources/application-test.yaml +++ b/runtime-acm/src/test/resources/application-test.yaml @@ -7,60 +7,5 @@ spring: maximumPoolSize: 3 jpa: hibernate: - ddl-auto: create + ddl-auto: create-drop open-in-view: false - -server: - servlet: - context-path: /onap/policy/clamp/acm - -runtime: - topics: - operationTopic: policy-acruntime-participant - syncTopic: acm-ppnt-sync - participantParameters: - updateParameters: - maxRetryCount: 3 - topicParameterGroup: - topicSources: - - - topic: ${runtime.topics.operationTopic} - servers: - - kafka:9092 - topicCommInfrastructure: NOOP - fetchTimeout: 15000 - topicSinks: - - - topicCommInfrastructure: NOOP - servers: - - kafka:9092 - topic: ${runtime.topics.operationTopic} - - - topic: ${runtime.topics.syncTopic} - servers: - - ${topicServer:kafka:9092} - topicCommInfrastructure: NOOP - acmParameters: - acElementName: org.onap.policy.clamp.acm.AutomationCompositionElement - acNodeType: org.onap.policy.clamp.acm.AutomationComposition - -management: - endpoints: - web: - base-path: / - exposure: - include: health, metrics, prometheus - tracing: - propagation: - produce: b3 - sampling: - probability: 1.0 - -tracing: - enabled: true - exporter: - endpoint: http://jaeger:4317 - protocol: grpc - sampler: - jaeger-remote: - endpoint: http://jaeger:14250
\ No newline at end of file diff --git a/runtime-acm/src/test/resources/application-tracing.yaml b/runtime-acm/src/test/resources/application-tracing.yaml new file mode 100644 index 000000000..d24fe9c53 --- /dev/null +++ b/runtime-acm/src/test/resources/application-tracing.yaml @@ -0,0 +1,27 @@ +spring: + datasource: + url: jdbc:h2:mem:testdb + driverClassName: org.h2.Driver + hikari: + maxLifetime: 1800000 + maximumPoolSize: 3 + jpa: + hibernate: + ddl-auto: create-drop + open-in-view: false + +management: + tracing: + propagation: + produce: b3 + sampling: + probability: 1.0 + +tracing: + enabled: true + exporter: + endpoint: http://jaeger:4317 + protocol: grpc + sampler: + jaeger-remote: + endpoint: http://jaeger:14250
\ No newline at end of file diff --git a/runtime-acm/src/test/resources/testscripts/listenOnTopic.sh b/runtime-acm/src/test/resources/testscripts/listenOnTopic.sh deleted file mode 100755 index 5e661777b..000000000 --- a/runtime-acm/src/test/resources/testscripts/listenOnTopic.sh +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/bash -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -if [ $# -ne 1 ] -then - echo invalid parameters $*, specify a single parameter as the topic to listen on - exit 1 -fi - -while true -do - curl "http://localhost:3904/events/$1/TEST/1?timeout=60000" - echo "" -done - diff --git a/version.properties b/version.properties index d68ffcd49..8e64c4d15 100644 --- a/version.properties +++ b/version.properties @@ -27,7 +27,7 @@ major=8 minor=0 -patch=0 +patch=1 base_version=${major}.${minor}.${patch} |