From ccf08b8ea35134b738549010da3d19f6deeed80d Mon Sep 17 00:00:00 2001 From: Hengye Date: Thu, 5 Dec 2019 15:01:58 +0800 Subject: change HealthCheckReport URL from self to hostName Issue-ID: POLICY-1689 Consolidate Policy Health Check into PAP Change-Id: I00e17610d3e4788008649791c684c0af415863ee Signed-off-by: Hengye --- .../onap/policy/distribution/main/rest/HealthCheckProvider.java | 4 +++- .../policy/distribution/main/rest/TestDistributionRestServer.java | 8 +++++--- .../distribution/main/rest/TestHttpsDistributionRestServer.java | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java index a22d0857..2fe46b22 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java +++ b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.policy.distribution.main.rest; import org.onap.policy.common.endpoints.report.HealthCheckReport; +import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.distribution.main.startstop.DistributionActivator; /** @@ -32,7 +34,7 @@ public class HealthCheckProvider { private static final String NOT_ALIVE = "not alive"; private static final String ALIVE = "alive"; - private static final String URL = "self"; + private static final String URL = NetworkUtil.getHostname(); private static final String NAME = "Policy SSD"; /** diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java index 3644864e..008a1104 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java @@ -3,6 +3,7 @@ * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,12 +58,12 @@ public class TestDistributionRestServer { private static final Logger LOGGER = LoggerFactory.getLogger(TestDistributionRestServer.class); private static final String NOT_ALIVE = "not alive"; private static final String ALIVE = "alive"; - private static final String SELF = "self"; + private static final String SELF = NetworkUtil.getHostname(); private static final String NAME = "Policy SSD"; @Test public void testHealthCheckSuccess() { - final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]"; + final String reportString = "Report [name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive]"; try { final Main main = startDistributionService(); final HealthCheckReport report = performHealthCheck(); @@ -76,7 +77,8 @@ public class TestDistributionRestServer { @Test public void testHealthCheckFailure() { - final String reportString = "Report [name=Policy SSD, url=self, healthy=false, code=500, message=not alive]"; + final String reportString = + "Report [name=Policy SSD, url=" + SELF + ", healthy=false, code=500, message=not alive]"; final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false); restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME); final RestServer restServer = new RestServer(restServerParams, null, DistributionRestController.class); diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java index f3046c29..7a9835cb 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. - * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,13 +55,13 @@ public class TestHttpsDistributionRestServer { private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsDistributionRestServer.class); private static final String ALIVE = "alive"; - private static final String SELF = "self"; + private static final String SELF = NetworkUtil.getHostname(); private static final String NAME = "Policy SSD"; private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore"; @Test public void testHttpsHealthCheckSuccess() { - final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]"; + final String reportString = "Report [name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive]"; try { final Main main = startDistributionService(); final HealthCheckReport report = performHealthCheck(); -- cgit 1.2.3-korg