diff options
Diffstat (limited to 'controlloop/common/feature-controlloop-management/src')
3 files changed, 53 insertions, 94 deletions
diff --git a/controlloop/common/feature-controlloop-management/src/main/feature/config/controlloop.properties.environment b/controlloop/common/feature-controlloop-management/src/main/feature/config/controlloop.properties.environment index 4a0916895..f76e5f45c 100644 --- a/controlloop/common/feature-controlloop-management/src/main/feature/config/controlloop.properties.environment +++ b/controlloop/common/feature-controlloop-management/src/main/feature/config/controlloop.properties.environment @@ -51,8 +51,6 @@ sdnc.url=${env:SDNC_URL} sdnc.username=${env:SDNC_USERNAME} sdnc.password=${env:SDNC_PASSWORD} -aai.customQuery=true - cds.grpcHost=${env:CDS_GRPC_HOST} cds.grpcPort=${env:CDS_GRPC_PORT} cds.grpcUsername=${env:CDS_GRPC_USERNAME} diff --git a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java index 08b218dd6..563cac049 100644 --- a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java +++ b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java @@ -252,28 +252,4 @@ public class RestControlLoopManager { .build(); } - /** - * AAI Named Query. - * - * @param vserverId vServer identifier. - * @return query results. - */ - @GET - @Path("engine/tools/controlloops/aai/namedQuery/{vserverId}") - @ApiOperation(value = "AAI Custom Query") - public Response aaiNamedQuery(@ApiParam(value = "vserver Identifier") String vserverId) { - return Response - .status(Status.OK) - .entity(new AaiManager(new RestManager()) - .postQuery( - PolicyEngineConstants.getManager() - .getEnvironmentProperty(ControlLoopEventManager.AAI_URL), - PolicyEngineConstants.getManager().getEnvironmentProperty( - ControlLoopEventManager.AAI_USERNAME_PROPERTY), - PolicyEngineConstants.getManager().getEnvironmentProperty( - ControlLoopEventManager.AAI_PASS_PROPERTY), - ControlLoopEventManager.getAaiNqRequest(vserverId), - UUID.randomUUID())) - .build(); - } } diff --git a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java index 833adfb69..c2a9e536f 100644 --- a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java +++ b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java @@ -8,7 +8,7 @@ * 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 + * 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, @@ -23,7 +23,6 @@ package org.onap.policy.drools.server.restful; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import java.io.IOException; import java.nio.file.Files; @@ -39,11 +38,8 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.kie.api.builder.ReleaseId; -import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiNqResponseWrapper; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager; import org.onap.policy.drools.persistence.SystemPersistenceConstants; @@ -63,25 +59,31 @@ public class RestControlLoopManagerTest { private static final String KMODULE_DRL_PATH = "src/test/resources/op.drl"; private static final String KMODULE_POM_PATH = "src/test/resources/op.pom"; private static final String KMODULE_PATH = "src/test/resources/op.kmodule"; - private static final String KJAR_DRL_PATH = "src/main/resources/kbop/org/onap/policy/drools/test/op.drl"; + private static final String KJAR_DRL_PATH = + "src/main/resources/kbop/org/onap/policy/drools/test/op.drl"; private static final String CONTROLLER = KSESSION; - private static final String CONTROLOOP_NAME = "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e"; + private static final String CONTROLOOP_NAME = + "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e"; private static final String CLIENT_CONFIG = "op-http"; private static final String URL_CONTEXT_PATH_CONTROLLERS = "controllers/"; - private static final String URL_CONTEXT_PATH_CONTROLLER = URL_CONTEXT_PATH_CONTROLLERS + CONTROLLER; - private static final String URL_CONTEXT_PATH_KSESSION = URL_CONTEXT_PATH_CONTROLLER + "/drools/facts/" + KSESSION; - private static final String URL_CONTEXT_PATH_CONTROLLOOPS = URL_CONTEXT_PATH_KSESSION + "/controlloops/"; - private static final String URL_CONTEXT_PATH_CONTROLLOOP = URL_CONTEXT_PATH_CONTROLLOOPS + CONTROLOOP_NAME; - private static final String URL_CONTEXT_PATH_CONTROLLOOP_POLICY = URL_CONTEXT_PATH_CONTROLLOOP + "/policy"; + private static final String URL_CONTEXT_PATH_CONTROLLER = + URL_CONTEXT_PATH_CONTROLLERS + CONTROLLER; + private static final String URL_CONTEXT_PATH_KSESSION = + URL_CONTEXT_PATH_CONTROLLER + "/drools/facts/" + KSESSION; + private static final String URL_CONTEXT_PATH_CONTROLLOOPS = + URL_CONTEXT_PATH_KSESSION + "/controlloops/"; + private static final String URL_CONTEXT_PATH_CONTROLLOOP = + URL_CONTEXT_PATH_CONTROLLOOPS + CONTROLOOP_NAME; + private static final String URL_CONTEXT_PATH_CONTROLLOOP_POLICY = + URL_CONTEXT_PATH_CONTROLLOOP + "/policy"; private static final String URL_CONTEXT_PATH_TOOLS = "tools/controlloops/"; private static final String URL_CONTEXT_PATH_TOOLS_AAI = URL_CONTEXT_PATH_TOOLS + "aai/"; - private static final String URL_CONTEXT_PATH_TOOLS_AAI_NQ = URL_CONTEXT_PATH_TOOLS_AAI + "namedQuery/"; - private static final String URL_CONTEXT_PATH_TOOLS_AAI_CQ = URL_CONTEXT_PATH_TOOLS_AAI + "customQuery/"; - + private static final String URL_CONTEXT_PATH_TOOLS_AAI_CQ = + URL_CONTEXT_PATH_TOOLS_AAI + "customQuery/"; private static final String POLICY = "src/test/resources/vCPE.yaml"; private static final String CONTROLLER_FILE = "op-controller.properties"; @@ -98,22 +100,24 @@ public class RestControlLoopManagerTest { LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "WARN"); SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources"); - PolicyEngineConstants.getManager().configure(PolicyEngineConstants.getManager().defaultTelemetryConfig()); + PolicyEngineConstants.getManager() + .configure(PolicyEngineConstants.getManager().defaultTelemetryConfig()); - ReleaseId releaseId = - KieUtils.installArtifact(Paths.get(KMODULE_PATH).toFile(), Paths.get(KMODULE_POM_PATH).toFile(), - KJAR_DRL_PATH, Paths.get(KMODULE_DRL_PATH).toFile()); + ReleaseId releaseId = KieUtils.installArtifact(Paths.get(KMODULE_PATH).toFile(), + Paths.get(KMODULE_POM_PATH).toFile(), KJAR_DRL_PATH, + Paths.get(KMODULE_DRL_PATH).toFile()); Properties controllerProperties = new Properties(); controllerProperties.put(DroolsPropertyConstants.RULES_GROUPID, releaseId.getGroupId()); - controllerProperties.put(DroolsPropertyConstants.RULES_ARTIFACTID, releaseId.getArtifactId()); + controllerProperties.put(DroolsPropertyConstants.RULES_ARTIFACTID, + releaseId.getArtifactId()); controllerProperties.put(DroolsPropertyConstants.RULES_VERSION, releaseId.getVersion()); PolicyEngineConstants.getManager().createPolicyController(CONTROLLER, controllerProperties); PolicyEngineConstants.getManager().start(); HttpClientFactoryInstance.getClientFactory() - .build(SystemPersistenceConstants.getManager().getProperties(CLIENT_CONFIG)); + .build(SystemPersistenceConstants.getManager().getProperties(CLIENT_CONFIG)); if (!NetworkUtil.isTcpPortOpen("localhost", 9696, 6, 10000L)) { throw new IllegalStateException("cannot connect to port 9696"); @@ -121,9 +125,12 @@ public class RestControlLoopManagerTest { await().atMost(1, TimeUnit.MINUTES).until(isContainerAlive()); - PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_URL, "http://localhost:6666"); - PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY, "AAI"); - PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY, "AAI"); + PolicyEngineConstants.getManager().setEnvironmentProperty(ControlLoopEventManager.AAI_URL, + "http://localhost:6666"); + PolicyEngineConstants.getManager() + .setEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY, "AAI"); + PolicyEngineConstants.getManager() + .setEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY, "AAI"); Util.buildAaiSim(); } @@ -140,7 +147,8 @@ public class RestControlLoopManagerTest { PolicyEngineConstants.getManager().stop(); final Path controllerPath = - Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), CONTROLLER_FILE); + Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), + CONTROLLER_FILE); try { Files.deleteIfExists(controllerPath); } catch (Exception ignored) { @@ -148,7 +156,8 @@ public class RestControlLoopManagerTest { } Path controllerBakPath = - Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), CONTROLLER_FILE_BAK); + Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(), + CONTROLLER_FILE_BAK); try { Files.deleteIfExists(controllerBakPath); @@ -162,49 +171,33 @@ public class RestControlLoopManagerTest { */ @Test public void testOperationalPolicy() throws IOException { - assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_CONTROLLOOPS).getStatus()); + assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory() + .get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOPS).getStatus()); - assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_CONTROLLOOP).getStatus()); + assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory() + .get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOP).getStatus()); - assertEquals(Status.NOT_FOUND.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus()); + assertEquals(Status.NOT_FOUND.getStatusCode(), HttpClientFactoryInstance.getClientFactory() + .get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus()); String policyFromFile = new String(Files.readAllBytes(Paths.get(POLICY))); - HttpClientFactoryInstance.getClientFactory().get(CONTROLLER).put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY, - Entity.text(policyFromFile), Collections.emptyMap()); + HttpClientFactoryInstance.getClientFactory().get(CONTROLLER).put( + URL_CONTEXT_PATH_CONTROLLOOP_POLICY, Entity.text(policyFromFile), + Collections.emptyMap()); - assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus()); + assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory() + .get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus()); String policyFromPdpD = HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY) - .readEntity(String.class); + .get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).readEntity(String.class); assertEquals(policyFromFile, policyFromPdpD); assertEquals(Status.CONFLICT.getStatusCode(), - HttpClientFactoryInstance.getClientFactory().get(CONTROLLER).put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY, - Entity.text(policyFromFile), Collections.emptyMap()).getStatus()); - } - - /** - * Test AAI Named Query. - */ - @Test - public void testAaiNq() throws CoderException { - assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_TOOLS_AAI_NQ + "dummy") + .put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY, Entity.text(policyFromFile), + Collections.emptyMap()) .getStatus()); - - String nqResponse = - HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_TOOLS_AAI_NQ + "dummy") - .readEntity(String.class); - - assertNotNull(new StandardCoder().decode(nqResponse, AaiNqResponseWrapper.class)); } /** @@ -212,17 +205,8 @@ public class RestControlLoopManagerTest { */ @Test public void testAaiCq() throws CoderException { - assertEquals(Status.OK.getStatusCode(), - HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_TOOLS_AAI_CQ + "dummy") - .getStatus()); - - String cqResponse = - HttpClientFactoryInstance.getClientFactory().get(CONTROLLER) - .get(URL_CONTEXT_PATH_TOOLS_AAI_CQ + "dummy") - .readEntity(String.class); - - assertNotNull(new StandardCoder().decode(cqResponse, AaiCqResponse.class)); + assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory() + .get(CONTROLLER).get(URL_CONTEXT_PATH_TOOLS_AAI_CQ + "dummy").getStatus()); } /** @@ -231,6 +215,7 @@ public class RestControlLoopManagerTest { * @return if the container is alive. */ private static Callable<Boolean> isContainerAlive() { - return () -> PolicyControllerConstants.getFactory().get(CONTROLLER).getDrools().getContainer().isAlive(); + return () -> PolicyControllerConstants.getFactory().get(CONTROLLER).getDrools() + .getContainer().isAlive(); } } |