From cff56489f774f937654cb6eb198d3d5ef41418a2 Mon Sep 17 00:00:00 2001 From: efiacor Date: Thu, 16 Jun 2022 09:38:26 +0100 Subject: [STRIMZI] Migrate client from cambria to kafka native Add call to sdc to get kafka and topic details Add kafka config to IConfiguration interface Signed-off-by: efiacor Change-Id: Ibec77d1ff1cd25ad4adce133ee81d66e54c7707f Issue-ID: DMAAP-1745 --- .../test/core/config/DistributionClientConfig.java | 75 +++++++++------------- .../test/core/service/ClientNotifyCallback.java | 6 +- .../org/onap/test/it/RegisterToAsdcTopicIT.java | 51 --------------- .../org/onap/test/it/RegisterToSdcTopicIT.java | 46 +++++++++++++ 4 files changed, 78 insertions(+), 100 deletions(-) delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToSdcTopicIT.java (limited to 'sdc-distribution-ci/src/main/java') diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java index ad18969..5a902c8 100644 --- a/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java @@ -26,21 +26,23 @@ import java.util.List; public class DistributionClientConfig implements IConfiguration { - public static final String DEFAULT_ASDC_ADDRESS = "localhost:30206"; + public static final String DEFAULT_SDC_ADDRESS = "localhost:30206"; public static final String DEFAULT_COMSUMER_ID = "dcae-openapi-manager"; public static final String DEFAULT_CONSUMER_GROUP = "noapp"; public static final String DEFAULT_ENVIRONMENT_NAME = "AUTO"; public static final String DEFAULT_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"; public static final int DEFAULT_POLLING_INTERVAL = 20; public static final int DEFAULT_POLLING_TIMEOUT = 20; + public static final String DEFAULT_STATUS_TOPIC = "STATUS-TOPIC"; + public static final String DEFAULT_NOTIF_TOPIC = "NOTIF-TOPIC"; public static final String DEFAULT_USER = "dcae"; - public static final String DEFAULT_KEY_STORE_PATH = "etc/asdc-client.jks"; + public static final String DEFAULT_KEY_STORE_PATH = "etc/sdc-client.jks"; public static final String DEFAULT_KEY_STORE_PASSWORD = "Aa123456"; public static final boolean DEFAULT_ACTIVATE_SERVER_TLS_AUTH = false; public static final boolean DEFAULT_IS_FILTER_IN_EMPTY_RESOURCES = true; public static final boolean DEFAULT_USE_HTTPS_WITH_SDC = false; - public static final String DEFAULT_MSG_BUS_ADDRESS = "localhost"; - private String asdcAddress; + public static final String DEFAULT_MSG_BUS_ADDRESS = "localhost:9092"; + private String sdcAddress; private String user; private String password; private int pollingInterval; @@ -53,38 +55,23 @@ public class DistributionClientConfig implements IConfiguration { private String keyStorePassword; private boolean activateServerTLSAuth; private boolean isFilterInEmptyResources; - private boolean useHttpsWithDmaap; private boolean useHttpsWithSDC; private List msgBusAddress; + private String sdcStatusTopicName; + private String sdcNotificationTopicName; + private String kafkaSecurityProtocolConfig; + private String kafkaSaslMechanism; + private String kafkaSaslJaasConfig; private String httpProxyHost; private int httpProxyPort; private String httpsProxyHost; private int httpsProxyPort; private boolean useSystemProxy; - public DistributionClientConfig(IConfiguration other) { - this.asdcAddress = other.getAsdcAddress(); - this.comsumerID = other.getConsumerID(); - this.consumerGroup = other.getConsumerGroup(); - this.environmentName = other.getEnvironmentName(); - this.password = other.getPassword(); - this.pollingInterval = other.getPollingInterval(); - this.pollingTimeout = other.getPollingTimeout(); - this.relevantArtifactTypes = other.getRelevantArtifactTypes(); - this.user = other.getUser(); - this.keyStorePath = other.getKeyStorePath(); - this.keyStorePassword = other.getKeyStorePassword(); - this.activateServerTLSAuth = other.activateServerTLSAuth(); - this.isFilterInEmptyResources = other.isFilterInEmptyResources(); - this.httpProxyHost = other.getHttpProxyHost(); - this.httpProxyPort = other.getHttpProxyPort(); - this.httpsProxyHost = other.getHttpsProxyHost(); - this.httpsProxyPort = other.getHttpsProxyPort(); - this.useSystemProxy = other.isUseSystemProxy(); - } - public DistributionClientConfig() { - this.asdcAddress = DEFAULT_ASDC_ADDRESS; + this.sdcAddress = DEFAULT_SDC_ADDRESS; + this.sdcStatusTopicName = DEFAULT_STATUS_TOPIC; + this.sdcNotificationTopicName = DEFAULT_NOTIF_TOPIC; this.comsumerID = DEFAULT_COMSUMER_ID; this.consumerGroup = DEFAULT_CONSUMER_GROUP; this.environmentName = DEFAULT_ENVIRONMENT_NAME; @@ -99,22 +86,23 @@ public class DistributionClientConfig implements IConfiguration { this.activateServerTLSAuth = DEFAULT_ACTIVATE_SERVER_TLS_AUTH; this.isFilterInEmptyResources = DEFAULT_IS_FILTER_IN_EMPTY_RESOURCES; this.useHttpsWithSDC = DEFAULT_USE_HTTPS_WITH_SDC; - msgBusAddress = new ArrayList<>(); - msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); - msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); - msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + this.msgBusAddress = new ArrayList<>(); + this.msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); } @Override - public String getAsdcAddress() { - return asdcAddress; + public String getSdcAddress() { + return sdcAddress; } - @Override public List getMsgBusAddress() { return msgBusAddress; } + public void setMsgBusAddress(List msgBusAddress) { + this.msgBusAddress = msgBusAddress; + } + @Override public String getUser() { return user; @@ -173,8 +161,8 @@ public class DistributionClientConfig implements IConfiguration { this.comsumerID = comsumerID; } - public void setAsdcAddress(String asdcAddress) { - this.asdcAddress = asdcAddress; + public void setSdcAddress(String sdcAddress) { + this.sdcAddress = sdcAddress; } public void setUser(String user) { @@ -217,7 +205,7 @@ public class DistributionClientConfig implements IConfiguration { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((asdcAddress == null) ? 0 : asdcAddress.hashCode()); + result = prime * result + ((sdcAddress == null) ? 0 : sdcAddress.hashCode()); result = prime * result + ((comsumerID == null) ? 0 : comsumerID.hashCode()); result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode()); result = prime * result + ((environmentName == null) ? 0 : environmentName.hashCode()); @@ -251,11 +239,11 @@ public class DistributionClientConfig implements IConfiguration { return false; } DistributionClientConfig other = (DistributionClientConfig) obj; - if (asdcAddress == null) { - if (other.asdcAddress != null) { + if (sdcAddress == null) { + if (other.sdcAddress != null) { return false; } - } else if (!asdcAddress.equals(other.asdcAddress)) { + } else if (!sdcAddress.equals(other.sdcAddress)) { return false; } if (comsumerID == null) { @@ -322,7 +310,7 @@ public class DistributionClientConfig implements IConfiguration { @Override public String toString() { - return "TestConfiguration [asdcAddress=" + asdcAddress + ", user=" + user + ", password=" + password + return "TestConfiguration [sdcAddress=" + sdcAddress + ", user=" + user + ", password=" + password + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", relevantArtifactTypes=" + relevantArtifactTypes + ", consumerGroup=" + consumerGroup + ", environmentName=" + environmentName + ", comsumerID=" + comsumerID + "]"; @@ -337,11 +325,6 @@ public class DistributionClientConfig implements IConfiguration { this.isFilterInEmptyResources = isFilterInEmptyResources; } - @Override - public Boolean isUseHttpsWithDmaap() { - return this.useHttpsWithDmaap; - } - public Boolean isUseHttpsWithSDC() { return this.useHttpsWithSDC; } diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java index 4dfe388..4cee4cf 100644 --- a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java @@ -23,7 +23,7 @@ import org.onap.sdc.api.consumer.IDistributionStatusMessage; import org.onap.sdc.api.consumer.INotificationCallback; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; -import org.onap.sdc.http.HttpAsdcClient; +import org.onap.sdc.http.HttpSdcClient; import org.onap.sdc.http.SdcConnectorClient; import org.onap.sdc.impl.DistributionClientDownloadResultImpl; import org.onap.sdc.impl.DistributionClientImpl; @@ -46,8 +46,8 @@ public class ClientNotifyCallback implements INotificationCallback { private final DistributionClientImpl distributionClient; private final List pulledArtifacts = new ArrayList<>(); DistributionClientConfig config = new DistributionClientConfig(); - HttpAsdcClient asdcClient = new HttpAsdcClient(config); - SdcConnectorClient sdcConnectorClient = new SdcConnectorClient(config, asdcClient); + HttpSdcClient sdcClient = new HttpSdcClient(config); + SdcConnectorClient sdcConnectorClient = new SdcConnectorClient(config, sdcClient); ArtifactsDownloader artifactsDownloader = new ArtifactsDownloader("/app/path", sdcConnectorClient); public List getPulledArtifacts() { diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java deleted file mode 100644 index 58baec7..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2020 Nokia. 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. - * ============LICENSE_END========================================================= - */ -package org.onap.test.it; - -import org.onap.sdc.impl.DistributionClientImpl; -import org.onap.test.core.config.DistributionClientConfig; -import org.onap.test.core.service.ArtifactsValidator; -import org.onap.test.core.service.ClientInitializer; -import org.onap.test.core.service.ClientNotifyCallback; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -public class RegisterToAsdcTopicIT { - - - public static void main(String[] args) { - DistributionClientConfig clientConfig = new DistributionClientConfig(); - List validators = new ArrayList<>(); - DistributionClientImpl client = new DistributionClientImpl(); - ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); - ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); - clientInitializer.initialize(); - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - client.stop(); - System.out.println("Shutdown Hook is running !"); - } - }); - - } -} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToSdcTopicIT.java b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToSdcTopicIT.java new file mode 100644 index 0000000..c89ecd4 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToSdcTopicIT.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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. + * ============LICENSE_END========================================================= + */ +package org.onap.test.it; + +import java.util.ArrayList; +import java.util.List; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.onap.test.core.service.ArtifactsValidator; +import org.onap.test.core.service.ClientInitializer; +import org.onap.test.core.service.ClientNotifyCallback; + +public class RegisterToSdcTopicIT { + + + public static void main(String[] args) { + DistributionClientConfig clientConfig = new DistributionClientConfig(); + List validators = new ArrayList<>(); + DistributionClientImpl client = new DistributionClientImpl(); + ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); + ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); + clientInitializer.initialize(); + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + client.stop(); + System.out.println("Shutdown Hook is running !"); + })); + + } +} -- cgit 1.2.3-korg