aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java10
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java50
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java46
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java129
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java117
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestStatisticsReport.java46
-rw-r--r--testsuites/stability/src/main/resources/setup/config/papParameters.yaml1
7 files changed, 1 insertions, 398 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
index 1b87fb51..702f8a2a 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,13 +57,4 @@ public class DistributionRestController {
return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
}
- @GET
- @Path("statistics")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Fetch current statistics",
- notes = "Provides current statistics of the Policy Distribution component",
- response = StatisticsReport.class)
- public Response statistics() {
- return Response.status(Response.Status.OK).entity(new StatisticsProvider().fetchCurrentStatistics()).build();
- }
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java
deleted file mode 100644
index 426436fb..00000000
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.distribution.main.rest;
-
-import org.onap.policy.distribution.main.startstop.DistributionActivator;
-import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
-
-/**
- * Class to fetch statistics of distribution service.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
- */
-public class StatisticsProvider {
-
- /**
- * Returns the current statistics of distribution service.
- *
- * @return Report containing statistics of distribution service
- */
- public StatisticsReport fetchCurrentStatistics() {
- final var report = new StatisticsReport();
- report.setCode(DistributionActivator.isAlive() ? 200 : 500);
- report.setTotalDistributionCount(DistributionStatisticsManager.getTotalDistributionCount());
- report.setDistributionSuccessCount(DistributionStatisticsManager.getDistributionSuccessCount());
- report.setDistributionFailureCount(DistributionStatisticsManager.getDistributionFailureCount());
- report.setTotalDownloadCount(DistributionStatisticsManager.getTotalDownloadCount());
- report.setDownloadSuccessCount(DistributionStatisticsManager.getDownloadSuccessCount());
- report.setDownloadFailureCount(DistributionStatisticsManager.getDownloadFailureCount());
- return report;
- }
-}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java
deleted file mode 100644
index 107d7803..00000000
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
- * ================================================================================
- * 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.distribution.main.rest;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent statistics report of distribution service.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
- */
-@ToString
-@Getter
-@Setter
-public class StatisticsReport {
-
- private int code;
- private long totalDistributionCount;
- private long distributionSuccessCount;
- private long distributionFailureCount;
- private long totalDownloadCount;
- private long downloadSuccessCount;
- private long downloadFailureCount;
-}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
deleted file mode 100644
index 0c732571..00000000
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 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.distribution.main.rest;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.junit.Test;
-import org.mockito.internal.util.reflection.Whitebox;
-import org.onap.policy.common.endpoints.http.server.RestServer;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.distribution.main.PolicyDistributionException;
-import org.onap.policy.distribution.main.parameters.CommonTestData;
-import org.onap.policy.distribution.main.startstop.Main;
-import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
-
-/**
- * Class to perform unit test of {@link DistributionRestController}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
- */
-public class TestDistributionStatistics {
-
- private int port;
-
- @Test
- public void testDistributionStatistics_200() {
- assertThatCode(() -> {
- final Main main = startDistributionService();
- StatisticsReport report = getDistributionStatistics();
- validateReport(report, 0, 200);
- updateDistributionStatistics();
- report = getDistributionStatistics();
- validateReport(report, 1, 200);
- stopDistributionService(main);
- DistributionStatisticsManager.resetAllStatistics();
- }).doesNotThrowAnyException();
- }
-
- @Test
- public void testDistributionStatistics_500() throws InterruptedException, IOException {
- port = NetworkUtil.allocPort();
- final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
- Whitebox.setInternalState(restServerParams, "port", port);
- restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
- final RestServer restServer = new RestServer(restServerParams, null, DistributionRestController.class);
- assertThatCode(() -> {
- restServer.start();
- final StatisticsReport report = getDistributionStatistics();
- validateReport(report, 0, 500);
- restServer.shutdown();
- DistributionStatisticsManager.resetAllStatistics();
- }).doesNotThrowAnyException();
- }
-
- private Main startDistributionService() throws IOException {
- port = CommonTestData.makeConfigFile("parameters/DistributionConfigParameters.json");
- final String[] distributionConfigParameters = { "-c", CommonTestData.CONFIG_FILE };
- return new Main(distributionConfigParameters);
- }
-
- private void stopDistributionService(final Main main) throws PolicyDistributionException {
- main.shutdown();
- }
-
- private StatisticsReport getDistributionStatistics() throws InterruptedException, IOException {
- final ClientConfig clientConfig = new ClientConfig();
-
- final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
- clientConfig.register(feature);
-
- final Client client = ClientBuilder.newClient(clientConfig);
- final WebTarget webTarget = client.target("http://localhost:" + port + "/statistics");
-
- final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
-
- CommonTestData.awaitServer(port);
- return invocationBuilder.get(StatisticsReport.class);
- }
-
- private void updateDistributionStatistics() {
- DistributionStatisticsManager.updateTotalDistributionCount();
- DistributionStatisticsManager.updateDistributionSuccessCount();
- DistributionStatisticsManager.updateDistributionFailureCount();
- DistributionStatisticsManager.updateTotalDownloadCount();
- DistributionStatisticsManager.updateDownloadSuccessCount();
- DistributionStatisticsManager.updateDownloadFailureCount();
- }
-
- private void validateReport(final StatisticsReport report, final int count, final int code) {
- assertEquals(code, report.getCode());
- assertEquals(count, report.getTotalDistributionCount());
- assertEquals(count, report.getDistributionSuccessCount());
- assertEquals(count, report.getDistributionFailureCount());
- assertEquals(count, report.getTotalDownloadCount());
- assertEquals(count, report.getDownloadSuccessCount());
- assertEquals(count, report.getDownloadFailureCount());
- }
-}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
deleted file mode 100644
index d47cb52d..00000000
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Intel. All rights reserved.
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 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.distribution.main.rest;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.Properties;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ParameterService;
-import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.common.utils.security.SelfSignedKeyStore;
-import org.onap.policy.distribution.main.PolicyDistributionException;
-import org.onap.policy.distribution.main.parameters.CommonTestData;
-import org.onap.policy.distribution.main.startstop.Main;
-
-/**
- * Class to perform unit test of HealthCheckMonitor.
- *
- * @author Libo Zhu (libo.zhu@intel.com)
- */
-public class TestHttpsStatisticDistributionRestServer {
-
- private int port;
-
- @Before
- public void setUp() {
- ParameterService.clear();
- }
-
- @Test
- public void testHttpsDistributionStatistic() {
- assertThatCode(() -> {
- final Main main = startDistributionService();
- final StatisticsReport report = performStatisticCheck();
- validateReport(200, 0, 0, 0, 0, 0, 0, report);
- stopDistributionService(main);
- }).doesNotThrowAnyException();
- }
-
- private Main startDistributionService() throws IOException, InterruptedException {
- final Properties systemProps = System.getProperties();
- systemProps.put("javax.net.ssl.keyStore", new SelfSignedKeyStore().getKeystoreName());
- systemProps.put("javax.net.ssl.keyStorePassword", SelfSignedKeyStore.KEYSTORE_PASSWORD);
- System.setProperties(systemProps);
-
- port = CommonTestData.makeConfigFile("parameters/DistributionConfigParameters_Https.json");
- final String[] distributionConfigParameters = { "-c", CommonTestData.CONFIG_FILE };
- return new Main(distributionConfigParameters);
- }
-
- private void stopDistributionService(final Main main) throws PolicyDistributionException {
- main.shutdown();
- }
-
- private StatisticsReport performStatisticCheck() throws Exception {
- final TrustManager[] noopTrustManager = NetworkUtil.getAlwaysTrustingManager();
-
- final SSLContext sc = SSLContext.getInstance("TLSv1.2");
- sc.init(null, noopTrustManager, new SecureRandom());
- final ClientBuilder clientBuilder =
- ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
- final Client client = clientBuilder.build();
- final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
- client.register(feature);
-
- final WebTarget webTarget = client.target("https://localhost:" + port + "/statistics");
-
- final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
-
- CommonTestData.awaitServer(port);
- return invocationBuilder.get(StatisticsReport.class);
- }
-
- private void validateReport(final int code, final int total, final int successCount, final int failureCount,
- final int download, final int downloadSuccess, final int downloadFailure, final StatisticsReport report) {
- assertEquals(code, report.getCode());
- assertEquals(total, report.getTotalDistributionCount());
- assertEquals(successCount, report.getDistributionSuccessCount());
- assertEquals(failureCount, report.getDistributionFailureCount());
- assertEquals(download, report.getTotalDownloadCount());
- assertEquals(downloadSuccess, report.getDownloadSuccessCount());
- assertEquals(downloadFailure, report.getDownloadFailureCount());
- }
-}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestStatisticsReport.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestStatisticsReport.java
deleted file mode 100644
index 299c5e3d..00000000
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestStatisticsReport.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.distribution.main.rest;
-
-import com.openpojo.reflection.filters.FilterClassName;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit testing of {@link StatisticsReport}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
- */
-public class TestStatisticsReport {
-
- @Test
- public void testStatisticsReport() {
- final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterMustExistRule())
- .with(new SetterTester()).with(new GetterTester()).build();
- validator.validate(StatisticsReport.class.getPackage().getName(),
- new FilterClassName(StatisticsReport.class.getName()));
- }
-}
diff --git a/testsuites/stability/src/main/resources/setup/config/papParameters.yaml b/testsuites/stability/src/main/resources/setup/config/papParameters.yaml
index bb050205..8249edd7 100644
--- a/testsuites/stability/src/main/resources/setup/config/papParameters.yaml
+++ b/testsuites/stability/src/main/resources/setup/config/papParameters.yaml
@@ -37,7 +37,6 @@ pap:
stateChangeParameters:
maxRetryCount: 1
maxWaitMs: 30000
- savePdpStatisticsInDb: true
topicParameterGroup:
topicSources:
- topic: POLICY-PDP-PAP