aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-distribution-ci
diff options
context:
space:
mode:
authorEdyta Krukowska <edyta.krukowska@nokia.com>2021-01-05 12:27:02 +0100
committerEdyta Krukowska <edyta.krukowska@nokia.com>2021-01-07 08:26:09 +0100
commitfe52f1b0054d4551f83d9448d894160981c4e07f (patch)
tree4d87fbc8a19d055211400b47d590e59f26eaf8eb /sdc-distribution-ci
parent2ca084cf51507724d771c15bb57997af35cbed75 (diff)
Create IT test for downloading artifacts
Issue-ID: SDC-3417 Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com> Change-Id: I8bd24c34902a2d59d0d0dd1b0c1e8c08352a4cc2
Diffstat (limited to 'sdc-distribution-ci')
-rw-r--r--sdc-distribution-ci/pom.xml14
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java2
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java11
-rw-r--r--sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java46
-rw-r--r--sdc-distribution-ci/src/test/resources/artifacts.json170
5 files changed, 237 insertions, 6 deletions
diff --git a/sdc-distribution-ci/pom.xml b/sdc-distribution-ci/pom.xml
index b1dfa86..9af54ca 100644
--- a/sdc-distribution-ci/pom.xml
+++ b/sdc-distribution-ci/pom.xml
@@ -23,6 +23,8 @@
<junit-jupiter-engine.version>5.4.2</junit-jupiter-engine.version>
<junit-jupiter-params.version>5.4.2</junit-jupiter-params.version>
<junit-jupiter-api.version>5.4.2</junit-jupiter-api.version>
+ <awaitility-proxy.version>3.0.0</awaitility-proxy.version>
+ <awaitility.version>3.0.0</awaitility.version>
</properties>
@@ -99,6 +101,18 @@
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility-proxy</artifactId>
+ <version>${awaitility-proxy.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
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 be6f6a6..8a02801 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
@@ -38,7 +38,7 @@ public class DistributionClientConfig implements IConfiguration {
public static final String DEFAULT_KEY_STORE_PATH = "etc/asdc-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 = 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;
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 7737457..4dfe388 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
@@ -25,6 +25,7 @@ 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.SdcConnectorClient;
+import org.onap.sdc.impl.DistributionClientDownloadResultImpl;
import org.onap.sdc.impl.DistributionClientImpl;
import org.onap.sdc.utils.DistributionStatusEnum;
import org.onap.test.core.config.DistributionClientConfig;
@@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -42,11 +44,16 @@ public class ClientNotifyCallback implements INotificationCallback {
private final List<ArtifactsValidator> validators;
private final DistributionClientImpl distributionClient;
+ private final List<DistributionClientDownloadResultImpl> pulledArtifacts = new ArrayList<>();
DistributionClientConfig config = new DistributionClientConfig();
HttpAsdcClient asdcClient = new HttpAsdcClient(config);
- SdcConnectorClient sdcConnectorClient = new SdcConnectorClient(config,asdcClient);
+ SdcConnectorClient sdcConnectorClient = new SdcConnectorClient(config, asdcClient);
ArtifactsDownloader artifactsDownloader = new ArtifactsDownloader("/app/path", sdcConnectorClient);
+ public List<DistributionClientDownloadResultImpl> getPulledArtifacts() {
+ return List.copyOf(pulledArtifacts);
+ }
+
public ClientNotifyCallback(List<ArtifactsValidator> validators, DistributionClientImpl distributionClient) {
this.validators = validators;
this.distributionClient = distributionClient;
@@ -55,7 +62,7 @@ public class ClientNotifyCallback implements INotificationCallback {
@Override
public void activateCallback(INotificationData inotificationData) {
logServiceInfo(inotificationData);
- artifactsDownloader.pullArtifacts(inotificationData);
+ pulledArtifacts.addAll(artifactsDownloader.pullArtifacts(inotificationData));
}
private void logServiceInfo(INotificationData service) {
diff --git a/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java
index 40278b1..797009d 100644
--- a/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java
+++ b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java
@@ -19,6 +19,8 @@
*/
package org.onap.test.core.service;
+import org.awaitility.Duration;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -26,17 +28,26 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.sdc.impl.DistributionClientDownloadResultImpl;
import org.onap.sdc.impl.DistributionClientImpl;
import org.onap.test.core.config.DistributionClientConfig;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.verify;
@Testcontainers
@@ -47,12 +58,16 @@ class ClientInitializerTest {
private static final int SUCCESSFUL_UNREGISTER_MSG_INDEX = 3;
private static final int SUCCESSFUL_INIT_MSG_INDEX = 0;
private static final int SUCCESSFUL_DIST_MSG_INDEX = 3;
+ private static final int EXPECTED_HEAT_ARTIFACTS = 4;
private ClientInitializer clientInitializer;
+ private ClientNotifyCallback clientNotifyCallback;
+ private static final Logger testLog = LoggerFactory.getLogger(ClientInitializerTest.class);
@Container
public GenericContainer mockDmaap = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dmaap:latest")
.withNetworkMode("host");
+
@Container
public GenericContainer mockSdc = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:latest")
.withNetworkMode("host");
@@ -62,13 +77,14 @@ class ClientInitializerTest {
@Mock
Logger distClientLog;
+
@BeforeEach
public void initializeClient() {
DistributionClientConfig clientConfig = new DistributionClientConfig();
List<ArtifactsValidator> validators = new ArrayList<>();
DistributionClientImpl client = new DistributionClientImpl(distClientLog);
- ClientNotifyCallback callback = new ClientNotifyCallback(validators, client);
- clientInitializer = new ClientInitializer(clientConfig, callback, client);
+ clientNotifyCallback = new ClientNotifyCallback(validators, client);
+ clientInitializer = new ClientInitializer(clientConfig, clientNotifyCallback, client);
}
@Test
@@ -98,4 +114,28 @@ class ClientInitializerTest {
assertThat(allValues.get(SUCCESSFUL_STOP_MSG_INDEX)).isEqualTo("stop DistributionClient");
assertThat(allValues.get(SUCCESSFUL_UNREGISTER_MSG_INDEX)).isEqualTo("client unregistered from topics successfully");
}
-} \ No newline at end of file
+
+ @Test
+ public void shouldDownloadArtifactsWithArtifactTypeHeat() throws IOException, InterruptedException {
+
+ //given
+ HttpRequest request = HttpRequest.newBuilder()
+ .uri(URI.create("http://localhost:3904/events/testName/add"))
+ .POST(HttpRequest.BodyPublishers.ofFile(Paths.get("src/test/resources/artifacts.json")))
+ .build();
+ HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
+ //when
+ clientInitializer.initialize();
+ waitForArtifacts();
+ List<DistributionClientDownloadResultImpl> calls = clientNotifyCallback.getPulledArtifacts();
+ //then
+ Assertions.assertEquals(EXPECTED_HEAT_ARTIFACTS, calls.size());
+ }
+
+ private void waitForArtifacts() {
+ testLog.info("Waiting for artifacts");
+ await()
+ .atMost(Duration.ONE_MINUTE)
+ .until(() -> !clientNotifyCallback.getPulledArtifacts().isEmpty());
+ }
+}
diff --git a/sdc-distribution-ci/src/test/resources/artifacts.json b/sdc-distribution-ci/src/test/resources/artifacts.json
new file mode 100644
index 0000000..4d4f45d
--- /dev/null
+++ b/sdc-distribution-ci/src/test/resources/artifacts.json
@@ -0,0 +1,170 @@
+{
+ "distributionID": "bf3df55e-cdc6-4bf7-b3b3-0fdccab91106",
+ "serviceName": "demoVLB_CDS",
+ "serviceVersion": "1.0",
+ "serviceUUID": "d2192fd5-6ba4-40d2-9078-e3642d9175ee",
+ "serviceDescription": "catalog service description",
+ "serviceInvariantUUID": "6f355230-c44b-4aca-873a-41c250b8137c",
+ "resources": [
+ {
+ "resourceInstanceName": "vLB_CDS 68b6da59-68e4 0",
+ "resourceName": "vLB_CDS 68b6da59-68e4",
+ "resourceVersion": "1.0",
+ "resoucreType": "VF",
+ "resourceUUID": "acdcb4be-7ec8-4d1f-a6ab-c225e35ee7ed",
+ "resourceInvariantUUID": "d9309314-be70-46d6-9ac3-fefb5d74fd3a",
+ "resourceCustomizationUUID": "f163654b-f172-4828-af92-04fc60eabc28",
+ "category": "Generic",
+ "subcategory": "Abstract",
+ "artifacts": [
+ {
+ "artifactName": "k8s-tca-clamp-policy-05082019.yaml",
+ "artifactType": "DCAE_INVENTORY_BLUEPRINT",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/k8s-tca-clamp-policy-05082019.yaml",
+ "artifactChecksum": "ZTIyYzkyYzgyYzBkMjc0YWJhNTIzOGI4YWE1Njg3YzA=",
+ "artifactDescription": "k8s-tca-clamp-policy-05082019.yaml",
+ "artifactTimeout": 0,
+ "artifactUUID": "560f355f-00e7-413c-bf56-025c999ae983",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "vf-license-model.yaml",
+ "artifactType": "VF_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/vf-license-model.xml",
+ "artifactChecksum": "YTc3NjEwZThhMjFjMjlmNDQ0M2FmYzExZDQ0MjQ0Yzc=",
+ "artifactDescription": "VF license file",
+ "artifactTimeout": 0,
+ "artifactUUID": "f1b25b41-334f-40db-afdb-dea1da827316",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "base_template.env",
+ "artifactType": "HEAT_ENV",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/base_template.env",
+ "artifactChecksum": "NTYzNDIzN2I5MTg1M2Y1MjgyNDdlMzc2NjNiNDVmZWM=",
+ "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+ "artifactTimeout": 0,
+ "artifactUUID": "2cf083a6-aae1-46b4-89c8-312c6d6abc29",
+ "artifactVersion": "3",
+ "generatedFromUUID": "fdfced54-8425-4c51-a913-ab9ac126cc20"
+ },
+ {
+ "artifactName": "vlb_cds68b6da5968e40_modules.json",
+ "artifactType": "VF_MODULES_METADATA",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/vlb_cds68b6da5968e40_modules.json",
+ "artifactChecksum": "YWUzODIzMjczMDAzMGNjZDlhYWIzM2FmNjE3MjY0NTk=",
+ "artifactDescription": "Auto-generated VF Modules information artifact",
+ "artifactTimeout": 30,
+ "artifactUUID": "15f20c8e-c644-4e8f-8a4b-099761e9f05d",
+ "artifactVersion": "2"
+ },
+ {
+ "artifactName": "vpkg.yaml",
+ "artifactType": "HEAT",
+ "artifactURL": "/",
+ "artifactChecksum": "MTFkMDYzMGMyZjUyM2Y2ZjA0ZGRlOWFjZmI4ODMyZmQ=",
+ "artifactDescription": "created from csar",
+ "artifactTimeout": 30,
+ "artifactUUID": "eb0c1b54-a71a-43f2-9c8c-95040365d657",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "vdns.env",
+ "artifactType": "HEAT_ENV",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/vdns.env",
+ "artifactChecksum": "YjA2OGFiN2RiYjJkZGI2YzgwNDdhNmZiNzc0MmIwODQ=",
+ "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+ "artifactTimeout": 0,
+ "artifactUUID": "1c81a0e7-06f6-49af-ae95-b6ad24e3cad9",
+ "artifactVersion": "3",
+ "generatedFromUUID": "95e8b9d6-3456-469b-be14-0904cf0de619"
+ },
+ {
+ "artifactName": "vendor-license-model.xml",
+ "artifactType": "VENDOR_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/vendor-license-model.xml",
+ "artifactChecksum": "ZTQ1N2MxNmZjMmIzMjlhMWRjNGM5MDNjMzkyYzdjMGM=",
+ "artifactDescription": " Vendor license file",
+ "artifactTimeout": 0,
+ "artifactUUID": "dee67b01-bf96-44d6-8565-e6a0cbe98528",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "vlb.yaml",
+ "artifactType": "HEAT",
+ "artifactURL": "/",
+ "artifactChecksum": "MDk5ZGUwN2M1NjAzMjY2Yjc1OGM5MGQzYjJkNGQzNTM=",
+ "artifactDescription": "created from csar",
+ "artifactTimeout": 30,
+ "artifactUUID": "6d6bf6d7-e76c-4488-85ad-a7dcc5867d8f",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "vlb.env",
+ "artifactType": "HEAT_ENV",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/vlb.env",
+ "artifactChecksum": "MzY2MGE3NGNlMjU2ZDk4OTNkNjI0MTAwZjY0ZGE0Y2U=",
+ "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+ "artifactTimeout": 0,
+ "artifactUUID": "0fe5eb8f-180c-4b50-b73d-ae404141fad1",
+ "artifactVersion": "3",
+ "generatedFromUUID": "6d6bf6d7-e76c-4488-85ad-a7dcc5867d8f"
+ },
+ {
+ "artifactName": "vpkg.env",
+ "artifactType": "HEAT_ENV",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/resourceInstances/vlb_cds68b6da5968e40/artifacts/vpkg.env",
+ "artifactChecksum": "NGRkZTVjMWRiYTkyYjM3MmY1MmIzNjAzYTRlMjdmN2I=",
+ "artifactDescription": "Auto-generated HEAT Environment deployment artifact",
+ "artifactTimeout": 0,
+ "artifactUUID": "25d6197f-b465-4ca5-a22c-5ae261c79313",
+ "artifactVersion": "3",
+ "generatedFromUUID": "eb0c1b54-a71a-43f2-9c8c-95040365d657"
+ },
+ {
+ "artifactName": "vdns.yaml",
+ "artifactType": "HEAT",
+ "artifactURL": "/",
+ "artifactChecksum": "YzM5M2M1NjY2ZWYyOGU2MTgyNmIwYmFhZjUzMzdiYzM=",
+ "artifactDescription": "created from csar",
+ "artifactTimeout": 30,
+ "artifactUUID": "95e8b9d6-3456-469b-be14-0904cf0de619",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "base_template.yaml",
+ "artifactType": "HEAT",
+ "artifactURL": "/",
+ "artifactChecksum": "MjllZGZkNTU3MTljOTVhNGMwY2FiZDk3MmFmZjAwNmE=",
+ "artifactDescription": "created from csar",
+ "artifactTimeout": 30,
+ "artifactUUID": "fdfced54-8425-4c51-a913-ab9ac126cc20",
+ "artifactVersion": "1"
+ }
+ ]
+ }
+ ],
+ "serviceArtifacts": [
+ {
+ "artifactName": "service-DemovlbCds-template.yml",
+ "artifactType": "TOSCA_TEMPLATE",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/artifacts/service-DemovlbCds-template.yml",
+ "artifactChecksum": "YWJiYWQ0MjUxMjk5ZjNmYjk2ODVhZjk3ZDI1ZmViNjk=",
+ "artifactDescription": "TOSCA representation of the asset",
+ "artifactTimeout": 0,
+ "artifactUUID": "ceeb88f4-cd35-437d-8a15-7342a18803bd",
+ "artifactVersion": "1"
+ },
+ {
+ "artifactName": "service-DemovlbCds-csar.csar",
+ "artifactType": "TOSCA_CSAR",
+ "artifactURL": "/sdc/v1/catalog/services/DemovlbCds/1.0/artifacts/service-DemovlbCds-csar.csar",
+ "artifactChecksum": "ZmI5NzQ1MWViZGFkMjRjZWEwNTQzY2U0OWQwYjlmYjQ=",
+ "artifactDescription": "TOSCA definition package of the asset",
+ "artifactTimeout": 0,
+ "artifactUUID": "f6f907f1-3f45-4fb4-8cbe-15a4c6ee16db",
+ "artifactVersion": "1"
+ }
+ ],
+ "workloadContext": "Production"
+} \ No newline at end of file