Merge "Fix typos in documentation"
diff --git a/enrichment-coordinator-service/Dockerfile b/enrichment-coordinator-service/Dockerfile
index 3479902..51d45b5 100644
--- a/enrichment-coordinator-service/Dockerfile
+++ b/enrichment-coordinator-service/Dockerfile
@@ -25,7 +25,7 @@
RUN mkdir -p /var/log/enrichment-coordinator-service
RUN mkdir -p /opt/app/enrichment-coordinator-service/etc/cert/
-EXPOSE 8081 8433
+EXPOSE 8083 8434
ADD /config/application.yaml /opt/app/enrichment-coordinator-service/config/application.yaml
ADD target/${JAR} /opt/app/enrichment-coordinator-service/enrichment-coordinator-service.jar
diff --git a/enrichment-coordinator-service/config/application.yaml b/enrichment-coordinator-service/config/application.yaml
index 8582bd9..e64db0c 100644
--- a/enrichment-coordinator-service/config/application.yaml
+++ b/enrichment-coordinator-service/config/application.yaml
@@ -22,7 +22,7 @@
name: /var/log/enrichment-coordinator-service/application.log
server:
port : 8434
- http-port: 8082
+ http-port: 8083
ssl:
key-store-type: JKS
key-store-password: policy_agent
diff --git a/enrichment-coordinator-service/docs/api.json b/enrichment-coordinator-service/docs/api.json
index e4f7660..65ff48d 100644
--- a/enrichment-coordinator-service/docs/api.json
+++ b/enrichment-coordinator-service/docs/api.json
@@ -68,10 +68,11 @@
"required": true
},
{
- "schema": {"type": "string"},
- "in": "body",
+ "in": "query",
+ "allowEmptyValue": false,
"name": "owner",
"description": "identifies the owner of the job",
+ "type": "string",
"required": false
}
],
@@ -285,6 +286,22 @@
}],
"tags": ["Enrichment Data Producer API"]
}},
+ "/status": {"get": {
+ "summary": "Returns status and statistics of this service",
+ "deprecated": false,
+ "produces": ["application/json"],
+ "operationId": "getStatusUsingGET",
+ "responses": {
+ "200": {
+ "schema": {"$ref": "#/definitions/status_info"},
+ "description": "Service is living"
+ },
+ "401": {"description": "Unauthorized"},
+ "403": {"description": "Forbidden"},
+ "404": {"description": "Not Found"}
+ },
+ "tags": ["Service status"]
+ }},
"/producer_simulator/job_created_error": {"post": {
"summary": "Callback for EI job creation, returns error",
"deprecated": false,
@@ -554,7 +571,7 @@
"consumes": ["application/json"]
}}
},
- "host": "localhost:43453",
+ "host": "localhost:45709",
"definitions": {
"EiType": {
"description": "Information for an EI type",
@@ -652,6 +669,31 @@
}
}
},
+ "status_info": {
+ "type": "object",
+ "title": "status_info",
+ "properties": {
+ "no_of_producers": {
+ "format": "int32",
+ "description": "Number of EI producers",
+ "type": "integer"
+ },
+ "no_of_jobs": {
+ "format": "int32",
+ "description": "Number of EI jobs",
+ "type": "integer"
+ },
+ "no_of_types": {
+ "format": "int32",
+ "description": "Number of EI types",
+ "type": "integer"
+ },
+ "status": {
+ "description": "status text",
+ "type": "string"
+ }
+ }
+ },
"EiJobStatus": {
"description": "Status for an EI Job",
"type": "object",
@@ -749,6 +791,10 @@
{
"name": "Producer Simulator",
"description": "Producer Simulator Controller"
+ },
+ {
+ "name": "Service status",
+ "description": "Status Controller"
}
]
}
\ No newline at end of file
diff --git a/enrichment-coordinator-service/docs/api.yaml b/enrichment-coordinator-service/docs/api.yaml
deleted file mode 100644
index f3fa767..0000000
--- a/enrichment-coordinator-service/docs/api.yaml
+++ /dev/null
@@ -1,764 +0,0 @@
-basePath: /
-paths:
- /producer_simulator/job_deleted_error:
- post:
- summary: 'Callback for EI job creation, returns error'
- deprecated: false
- produces:
- - application/json
- operationId: jobDeletedCallbackReturnErrorUsingPOST
- responses:
- '200':
- description: OK
- '201':
- description: Created
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- parameters:
- - schema:
- $ref: '#/definitions/producer_ei_job_request'
- in: body
- name: request
- description: request
- required: true
- tags:
- - Producer Simulator
- consumes:
- - application/json
- /producer_simulator/supervision:
- get:
- summary: Producer supervision
- deprecated: false
- produces:
- - application/json
- operationId: producerSupervisionUsingGET
- responses:
- '200':
- schema:
- type: string
- description: OK
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- tags:
- - Producer Simulator
- '/A1-EI/v1/eitypes/{eiTypeId}/eijobs':
- get:
- summary: EI job identifiers
- deprecated: false
- produces:
- - application/json
- operationId: getEiJobIdsUsingGET
- responses:
- '200':
- schema:
- type: array
- items:
- type: string
- description: EI job identifiers
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type is not found
- parameters:
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- - schema:
- type: string
- in: body
- name: owner
- description: identifies the owner of the job
- required: false
- tags:
- - A1-E Enrichment Data Consumer API
- '/A1-EI/v1/eitypes/{eiTypeId}':
- get:
- summary: Individual EI type
- deprecated: false
- produces:
- - application/json
- operationId: getEiTypeUsingGET
- responses:
- '200':
- schema:
- $ref: '#/definitions/EiType'
- description: EI type
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type is not found
- parameters:
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- tags:
- - A1-E Enrichment Data Consumer API
- /ei-producer/v1/eitypes:
- get:
- summary: EI type identifiers
- deprecated: false
- produces:
- - application/json
- operationId: getEiTypeIdentifiersUsingGET_1
- responses:
- '200':
- schema:
- type: array
- items:
- type: string
- description: EI type identifiers
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- tags:
- - Enrichment Data Producer API
- /A1-EI/v1/eitypes:
- get:
- summary: EI type identifiers
- deprecated: false
- produces:
- - application/json
- operationId: getEiTypeIdentifiersUsingGET
- responses:
- '200':
- schema:
- type: array
- items:
- type: string
- description: EI type identifiers
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- tags:
- - A1-E Enrichment Data Consumer API
- /producer_simulator/job_deleted:
- post:
- summary: Callback for EI job deletion
- deprecated: false
- produces:
- - application/json
- operationId: jobDeletedCallbackUsingPOST
- responses:
- '200':
- description: OK
- '201':
- description: Created
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- parameters:
- - schema:
- $ref: '#/definitions/producer_ei_job_request'
- in: body
- name: request
- description: request
- required: true
- tags:
- - Producer Simulator
- consumes:
- - application/json
- '/A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status':
- get:
- summary: EI Job status
- deprecated: false
- produces:
- - application/json
- operationId: getEiJobStatusUsingGET
- responses:
- '200':
- schema:
- $ref: '#/definitions/EiJobStatus'
- description: EI Job status
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type or job is not found
- parameters:
- - in: path
- name: eiJobId
- description: eiJobId
- type: string
- required: true
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- tags:
- - A1-E Enrichment Data Consumer API
- '/ei-producer/v1/eiproducers/{eiProducerId}/status':
- get:
- summary: EI producer status
- deprecated: false
- produces:
- - application/json
- operationId: getEiProducerStatusUsingGET
- responses:
- '200':
- schema:
- $ref: '#/definitions/producer_status'
- description: EI jobs
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information producer is not found
- parameters:
- - in: path
- name: eiProducerId
- description: eiProducerId
- type: string
- required: true
- tags:
- - Enrichment Data Producer API
- /producer_simulator/supervision_error:
- get:
- summary: Producer supervision error
- deprecated: false
- produces:
- - application/json
- operationId: producerSupervisionErrorUsingGET
- responses:
- '200':
- schema:
- type: string
- description: OK
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- tags:
- - Producer Simulator
- /ei-producer/v1/eiproducers:
- get:
- summary: EI producer identifiers
- deprecated: false
- produces:
- - application/json
- operationId: getEiProducerIdentifiersUsingGET
- responses:
- '200':
- schema:
- type: array
- items:
- type: string
- description: EI producer identifiers
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- tags:
- - Enrichment Data Producer API
- '/ei-producer/v1/eitypes/{eiTypeId}':
- get:
- summary: Individual EI Type
- deprecated: false
- produces:
- - application/json
- operationId: getEiTypeUsingGET_1
- responses:
- '200':
- schema:
- $ref: '#/definitions/producer_ei_type_info'
- description: EI type
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type is not found
- parameters:
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- tags:
- - Enrichment Data Producer API
- /producer_simulator/job_created_error:
- post:
- summary: 'Callback for EI job creation, returns error'
- deprecated: false
- produces:
- - application/json
- operationId: jobCreatedCallbackReturnErrorUsingPOST
- responses:
- '200':
- description: OK
- '201':
- description: Created
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- parameters:
- - schema:
- $ref: '#/definitions/producer_ei_job_request'
- in: body
- name: request
- description: request
- required: true
- tags:
- - Producer Simulator
- consumes:
- - application/json
- '/A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}':
- get:
- summary: Individual EI Job
- deprecated: false
- produces:
- - application/json
- operationId: getIndividualEiJobUsingGET
- responses:
- '200':
- schema:
- $ref: '#/definitions/EiJob'
- description: EI Job
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type or job is not found
- parameters:
- - in: path
- name: eiJobId
- description: eiJobId
- type: string
- required: true
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- tags:
- - A1-E Enrichment Data Consumer API
- delete:
- summary: Individual EI Job
- deprecated: false
- produces:
- - application/json
- operationId: deleteIndividualEiJobUsingDELETE
- responses:
- '200':
- description: Not used
- '204':
- description: Job deleted
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type or job is not found
- parameters:
- - in: path
- name: eiJobId
- description: eiJobId
- type: string
- required: true
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- tags:
- - A1-E Enrichment Data Consumer API
- put:
- summary: Individual EI Job
- deprecated: false
- produces:
- - application/json
- operationId: putIndividualEiJobUsingPUT
- responses:
- '200':
- description: Job updated
- '201':
- description: Job created
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information type is not found
- parameters:
- - in: path
- name: eiJobId
- description: eiJobId
- type: string
- required: true
- - schema:
- $ref: '#/definitions/EiJob'
- in: body
- name: eiJobInfo
- description: eiJobInfo
- required: true
- - in: path
- name: eiTypeId
- description: eiTypeId
- type: string
- required: true
- tags:
- - A1-E Enrichment Data Consumer API
- consumes:
- - application/json
- '/ei-producer/v1/eiproducers/{eiProducerId}':
- get:
- summary: Individual EI producer
- deprecated: false
- produces:
- - application/json
- operationId: getEiProducerUsingGET
- responses:
- '200':
- schema:
- $ref: '#/definitions/producer_registration_info'
- description: EI Jobs
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information producer is not found
- parameters:
- - in: path
- name: eiProducerId
- description: eiProducerId
- type: string
- required: true
- tags:
- - Enrichment Data Producer API
- delete:
- summary: Individual EI producer
- deprecated: false
- produces:
- - application/json
- operationId: deleteEiProducerUsingDELETE
- responses:
- '200':
- description: Not used
- '204':
- description: Producer deleted
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Producer is not found
- parameters:
- - in: path
- name: eiProducerId
- description: eiProducerId
- type: string
- required: true
- tags:
- - Enrichment Data Producer API
- put:
- summary: Individual EI producer
- deprecated: false
- produces:
- - application/json
- operationId: putEiProducerUsingPUT
- responses:
- '200':
- description: Producer updated
- '201':
- description: Producer created
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- parameters:
- - in: path
- name: eiProducerId
- description: eiProducerId
- type: string
- required: true
- - schema:
- $ref: '#/definitions/producer_registration_info'
- in: body
- name: registrationInfo
- description: registrationInfo
- required: true
- tags:
- - Enrichment Data Producer API
- consumes:
- - application/json
- '/ei-producer/v1/eiproducers/{eiProducerId}/eijobs':
- get:
- summary: EI job definitions
- deprecated: false
- produces:
- - application/json
- description: EI job definitions for one EI producer
- operationId: getEiProducerJobsUsingGET
- responses:
- '200':
- schema:
- type: array
- items:
- $ref: '#/definitions/producer_ei_job_request'
- description: EI jobs
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- schema:
- $ref: '#/definitions/error_information'
- description: Enrichment Information producer is not found
- parameters:
- - in: path
- name: eiProducerId
- description: eiProducerId
- type: string
- required: true
- tags:
- - Enrichment Data Producer API
- /producer_simulator/job_created:
- post:
- summary: Callback for EI job creation
- deprecated: false
- produces:
- - application/json
- operationId: jobCreatedCallbackUsingPOST
- responses:
- '200':
- description: OK
- '201':
- description: Created
- '401':
- description: Unauthorized
- '403':
- description: Forbidden
- '404':
- description: Not Found
- parameters:
- - schema:
- $ref: '#/definitions/producer_ei_job_request'
- in: body
- name: request
- description: request
- required: true
- tags:
- - Producer Simulator
- consumes:
- - application/json
-host: 'localhost:43453'
-definitions:
- EiType:
- description: Information for an EI type
- type: object
- title: EiType
- properties:
- eiJobParametersSchema:
- description: Json schema for the job data
- type: object
- producer_ei_job_request:
- description: The body of the EI producer callbacks for EI job creation and deletion
- type: object
- title: producer_ei_job_request
- required:
- - ei_job_identity
- properties:
- ei_job_identity:
- description: Idenitity of the EI job
- type: string
- ei_job_data:
- description: Json for the job data
- type: object
- target_uri:
- description: URI for the target of the EI
- type: string
- ei_type_identity:
- description: Type idenitity for the job
- type: string
- error_information:
- description: 'Problem as defined in https://tools.ietf.org/html/rfc7807'
- type: object
- title: error_information
- properties:
- detail:
- description: A human-readable explanation specific to this occurrence of the problem.
- type: string
- example: EI job type not found
- status:
- format: int32
- description: The HTTP status code generated by the origin server for this occurrence of the problem.
- type: integer
- example: 404
- void:
- description: Void/empty
- type: object
- title: void
- EiJob:
- description: Information for an Enrichment Information Job
- type: object
- title: EiJob
- required:
- - jobOwner
- - jobParameters
- - targetUri
- properties:
- targetUri:
- description: The target of the EI data
- type: string
- jobOwner:
- description: Identity of the owner of the job
- type: string
- jobParameters:
- description: EI Type specific job data
- type: object
- producer_ei_type_registration_info:
- description: Information for an EI type
- type: object
- title: producer_ei_type_registration_info
- required:
- - ei_type_identity
- properties:
- ei_type_identity:
- description: EI type identity
- type: string
- ei_job_data_schema:
- description: Json schema for the job data
- type: object
- EiJobStatus:
- description: Status for an EI Job
- type: object
- title: EiJobStatus
- required:
- - operationalState
- properties:
- operationalState:
- description: |-
- Operational state, values:
- ENABLED: TBD
- DISABLED: TBD.
- type: string
- enum:
- - ENABLED
- - DISABLED
- Mono«ResponseEntity«object»»:
- type: object
- title: Mono«ResponseEntity«object»»
- producer_ei_type_info:
- description: Information for an EI type
- type: object
- title: producer_ei_type_info
- properties:
- ei_producer_ids:
- description: Registered producers
- type: array
- items:
- type: string
- ei_job_data_schema:
- description: Json schema for the job data
- type: object
- producer_registration_info:
- description: Information for an EI producer
- type: object
- title: producer_registration_info
- required:
- - ei_job_creation_callback_url
- - ei_job_deletion_callback_url
- - ei_producer_supervision_callback_url
- - supported_ei_types
- properties:
- supported_ei_types:
- description: Supported EI types
- type: array
- items:
- $ref: '#/definitions/producer_ei_type_registration_info'
- ei_job_creation_callback_url:
- description: callback for job creation
- type: string
- ei_job_deletion_callback_url:
- description: callback for job deletion
- type: string
- ei_producer_supervision_callback_url:
- description: callback for producer supervision
- type: string
- producer_status:
- description: Status for an EI Producer
- type: object
- title: producer_status
- required:
- - operational_state
- properties:
- operational_state:
- description: |-
- Operational state, values:
- ENABLED: TBD
- DISABLED: TBD.
- type: string
- enum:
- - ENABLED
- - DISABLED
-swagger: '2.0'
-info:
- description: This page lists all the rest apis for the service.
- title: Enrichment Data service
- version: '1.0'
-tags:
- - name: A1-E Enrichment Data Consumer API
- description: Consumer Controller
- - name: Enrichment Data Producer API
- description: Producer Controller
- - name: Producer Simulator
- description: Producer Simulator Controller
-
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java
index 9e2142e..ce41956 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java
@@ -78,7 +78,7 @@
@Bean
public ProducerCallbacks getProducerCallbacks() {
- return new ProducerCallbacks();
+ return new ProducerCallbacks(this.applicationConfig);
}
private static Connector getHttpConnector(int httpPort) {
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
index 2782f94..76da624 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
@@ -2,7 +2,7 @@
* ========================LICENSE_START=================================
* O-RAN-SC
* %%
- * Copyright (C) 2019 Nordix Foundation
+ * 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.
@@ -22,36 +22,18 @@
import io.netty.channel.ChannelOption;
import io.netty.handler.ssl.SslContext;
-import io.netty.handler.ssl.SslContextBuilder;
-import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutHandler;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.lang.invoke.MethodHandles;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import javax.net.ssl.KeyManagerFactory;
-
-import org.oransc.enrichment.configuration.WebClientConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.lang.Nullable;
-import org.springframework.util.ResourceUtils;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec;
@@ -66,22 +48,25 @@
* Generic reactive REST client.
*/
public class AsyncRestClient {
+
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private WebClient webClient = null;
private final String baseUrl;
private static final AtomicInteger sequenceNumber = new AtomicInteger();
- private final WebClientConfig clientConfig;
- static KeyStore clientTrustStore = null;
- private boolean sslEnabled = true;
+ private final SslContext sslContext;
+ /**
+ * Note that only http (not https) will work when this constructor is used.
+ *
+ * @param baseUrl
+ */
public AsyncRestClient(String baseUrl) {
this(baseUrl, null);
- this.sslEnabled = false;
}
- public AsyncRestClient(String baseUrl, WebClientConfig config) {
+ public AsyncRestClient(String baseUrl, SslContext sslContext) {
this.baseUrl = baseUrl;
- this.clientConfig = config;
+ this.sslContext = sslContext;
}
public Mono<ResponseEntity<String>> postForEntity(String uri, @Nullable String body) {
@@ -185,10 +170,14 @@
final Class<String> clazz = String.class;
return request.retrieve() //
.toEntity(clazz) //
- .doOnNext(entity -> logger.trace("{} Received: {}", traceTag, entity.getBody())) //
+ .doOnNext(entity -> logReceivedData(traceTag, entity)) //
.doOnError(throwable -> onHttpError(traceTag, throwable));
}
+ private void logReceivedData(Object traceTag, ResponseEntity<String> entity) {
+ logger.trace("{} Received: {} {}", traceTag, entity.getBody(), entity.getHeaders().getContentType());
+ }
+
private static Object createTraceTag() {
return sequenceNumber.incrementAndGet();
}
@@ -211,65 +200,6 @@
}
}
- private boolean isCertificateEntry(KeyStore trustStore, String alias) {
- try {
- return trustStore.isCertificateEntry(alias);
- } catch (KeyStoreException e) {
- logger.error("Error reading truststore {}", e.getMessage());
- return false;
- }
- }
-
- private Certificate getCertificate(KeyStore trustStore, String alias) {
- try {
- return trustStore.getCertificate(alias);
- } catch (KeyStoreException e) {
- logger.error("Error reading truststore {}", e.getMessage());
- return null;
- }
- }
-
- private static synchronized KeyStore getTrustStore(String trustStorePath, String trustStorePass)
- throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
- if (clientTrustStore == null) {
- KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
- store.load(new FileInputStream(ResourceUtils.getFile(trustStorePath)), trustStorePass.toCharArray());
- clientTrustStore = store;
- }
- return clientTrustStore;
- }
-
- private SslContext createSslContextRejectingUntrustedPeers(String trustStorePath, String trustStorePass,
- KeyManagerFactory keyManager)
- throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
-
- final KeyStore trustStore = getTrustStore(trustStorePath, trustStorePass);
- List<Certificate> certificateList = Collections.list(trustStore.aliases()).stream() //
- .filter(alias -> isCertificateEntry(trustStore, alias)) //
- .map(alias -> getCertificate(trustStore, alias)) //
- .collect(Collectors.toList());
- final X509Certificate[] certificates = certificateList.toArray(new X509Certificate[certificateList.size()]);
-
- return SslContextBuilder.forClient() //
- .keyManager(keyManager) //
- .trustManager(certificates) //
- .build();
- }
-
- private SslContext createSslContext(KeyManagerFactory keyManager)
- throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
- if (this.clientConfig.isTrustStoreUsed()) {
- return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(),
- this.clientConfig.trustStorePassword(), keyManager);
- } else {
- // Trust anyone
- return SslContextBuilder.forClient() //
- .keyManager(keyManager) //
- .trustManager(InsecureTrustManagerFactory.INSTANCE) //
- .build();
- }
- }
-
private TcpClient createTcpClientSecure(SslContext sslContext) {
return TcpClient.create(ConnectionProvider.newConnection()) //
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
@@ -305,18 +235,7 @@
private Mono<WebClient> getWebClient() {
if (this.webClient == null) {
try {
- if (this.sslEnabled) {
- final KeyManagerFactory keyManager =
- KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType());
- final String keyStoreFile = this.clientConfig.keyStore();
- final String keyStorePassword = this.clientConfig.keyStorePassword();
- final String keyPassword = this.clientConfig.keyPassword();
- try (final InputStream inputStream = new FileInputStream(keyStoreFile)) {
- keyStore.load(inputStream, keyStorePassword.toCharArray());
- }
- keyManager.init(keyStore, keyPassword.toCharArray());
- SslContext sslContext = createSslContext(keyManager);
+ if (this.sslContext != null) {
TcpClient tcpClient = createTcpClientSecure(sslContext);
this.webClient = createWebClient(this.baseUrl, tcpClient);
} else {
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java
new file mode 100644
index 0000000..07f23e9
--- /dev/null
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java
@@ -0,0 +1,179 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * 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.
+ * ========================LICENSE_END===================================
+ */
+
+package org.oransc.enrichment.clients;
+
+import io.netty.handler.ssl.SslContext;
+import io.netty.handler.ssl.SslContextBuilder;
+import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.net.ssl.KeyManagerFactory;
+
+import org.oransc.enrichment.configuration.WebClientConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.ResourceUtils;
+
+/**
+ * Factory for a generic reactive REST client.
+ */
+public class AsyncRestClientFactory {
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final SslContextFactory sslContextFactory;
+
+ public AsyncRestClientFactory(WebClientConfig clientConfig) {
+ if (clientConfig != null) {
+ this.sslContextFactory = new CachingSslContextFactory(clientConfig);
+ } else {
+ this.sslContextFactory = null;
+ }
+ }
+
+ public AsyncRestClient createRestClient(String baseUrl) {
+ if (this.sslContextFactory != null) {
+ try {
+ return new AsyncRestClient(baseUrl, this.sslContextFactory.createSslContext());
+ } catch (Exception e) {
+ String exceptionString = e.toString();
+ logger.error("Could not init SSL context, reason: {}", exceptionString);
+ }
+ }
+ return new AsyncRestClient(baseUrl);
+ }
+
+ private class SslContextFactory {
+ private final WebClientConfig clientConfig;
+
+ public SslContextFactory(WebClientConfig clientConfig) {
+ this.clientConfig = clientConfig;
+ }
+
+ public SslContext createSslContext() throws UnrecoverableKeyException, NoSuchAlgorithmException,
+ CertificateException, KeyStoreException, IOException {
+ return this.createSslContext(createKeyManager());
+ }
+
+ private SslContext createSslContext(KeyManagerFactory keyManager)
+ throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
+ if (this.clientConfig.isTrustStoreUsed()) {
+ return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(),
+ this.clientConfig.trustStorePassword(), keyManager);
+ } else {
+ // Trust anyone
+ return SslContextBuilder.forClient() //
+ .keyManager(keyManager) //
+ .trustManager(InsecureTrustManagerFactory.INSTANCE) //
+ .build();
+ }
+ }
+
+ private SslContext createSslContextRejectingUntrustedPeers(String trustStorePath, String trustStorePass,
+ KeyManagerFactory keyManager)
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
+
+ final KeyStore trustStore = getTrustStore(trustStorePath, trustStorePass);
+ List<Certificate> certificateList = Collections.list(trustStore.aliases()).stream() //
+ .filter(alias -> isCertificateEntry(trustStore, alias)) //
+ .map(alias -> getCertificate(trustStore, alias)) //
+ .collect(Collectors.toList());
+ final X509Certificate[] certificates = certificateList.toArray(new X509Certificate[certificateList.size()]);
+
+ return SslContextBuilder.forClient() //
+ .keyManager(keyManager) //
+ .trustManager(certificates) //
+ .build();
+ }
+
+ private boolean isCertificateEntry(KeyStore trustStore, String alias) {
+ try {
+ return trustStore.isCertificateEntry(alias);
+ } catch (KeyStoreException e) {
+ logger.error("Error reading truststore {}", e.getMessage());
+ return false;
+ }
+ }
+
+ private Certificate getCertificate(KeyStore trustStore, String alias) {
+ try {
+ return trustStore.getCertificate(alias);
+ } catch (KeyStoreException e) {
+ logger.error("Error reading truststore {}", e.getMessage());
+ return null;
+ }
+ }
+
+ private KeyManagerFactory createKeyManager() throws NoSuchAlgorithmException, CertificateException, IOException,
+ UnrecoverableKeyException, KeyStoreException {
+ final KeyManagerFactory keyManager = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType());
+ final String keyStoreFile = this.clientConfig.keyStore();
+ final String keyStorePassword = this.clientConfig.keyStorePassword();
+ final String keyPassword = this.clientConfig.keyPassword();
+ try (final InputStream inputStream = new FileInputStream(keyStoreFile)) {
+ keyStore.load(inputStream, keyStorePassword.toCharArray());
+ }
+ keyManager.init(keyStore, keyPassword.toCharArray());
+ return keyManager;
+ }
+
+ private synchronized KeyStore getTrustStore(String trustStorePath, String trustStorePass)
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
+
+ KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
+ store.load(new FileInputStream(ResourceUtils.getFile(trustStorePath)), trustStorePass.toCharArray());
+ return store;
+ }
+ }
+
+ public class CachingSslContextFactory extends SslContextFactory {
+ private SslContext cachedContext = null;
+
+ public CachingSslContextFactory(WebClientConfig clientConfig) {
+ super(clientConfig);
+ }
+
+ @Override
+ public SslContext createSslContext() throws UnrecoverableKeyException, NoSuchAlgorithmException,
+ CertificateException, KeyStoreException, IOException {
+ if (this.cachedContext == null) {
+ this.cachedContext = super.createSslContext();
+ }
+ return this.cachedContext;
+
+ }
+ }
+
+}
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java
index 7f28a12..9b23865 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerCallbacks.java
@@ -30,7 +30,6 @@
import org.oransc.enrichment.repository.EiProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -46,11 +45,14 @@
.serializeNulls() //
.create(); //
- @Autowired
- ApplicationConfig applicationConfig;
+ private final AsyncRestClient restClient;
+
+ public ProducerCallbacks(ApplicationConfig config) {
+ AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig());
+ this.restClient = restClientFactory.createRestClient("");
+ }
public void notifyProducersJobDeleted(EiJob eiJob) {
- AsyncRestClient restClient = restClient();
ProducerJobInfo request = new ProducerJobInfo(eiJob);
String body = gson.toJson(request);
for (EiProducer producer : eiJob.type().getProducers()) {
@@ -81,7 +83,6 @@
* @return the body of the response from the REST call
*/
public Mono<String> notifyProducerJobStarted(EiProducer producer, EiJob eiJob) {
- AsyncRestClient restClient = restClient();
ProducerJobInfo request = new ProducerJobInfo(eiJob);
String body = gson.toJson(request);
@@ -93,8 +94,4 @@
});
}
- private AsyncRestClient restClient() {
- return new AsyncRestClient("", this.applicationConfig.getWebClientConfig());
- }
-
}
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java
index 164159b..ada16e2 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/ProducerJobInfo.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java
index 225b83a..2d4087f 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java
index 4e68c1a..28c40bf 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java
new file mode 100644
index 0000000..42ab7cb
--- /dev/null
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java
@@ -0,0 +1,100 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * 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.
+ * ========================LICENSE_END===================================
+ */
+
+package org.oransc.enrichment.controllers;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.annotations.SerializedName;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+import org.immutables.gson.Gson;
+import org.oransc.enrichment.repository.EiJobs;
+import org.oransc.enrichment.repository.EiProducers;
+import org.oransc.enrichment.repository.EiTypes;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+@RestController("StatusController")
+@Api(tags = "Service status")
+public class StatusController {
+
+ @Autowired
+ private EiJobs eiJobs;
+
+ @Autowired
+ private EiTypes eiTypes;
+
+ @Autowired
+ private EiProducers eiProducers;
+
+ @Gson.TypeAdapters
+ @ApiModel(value = "status_info")
+ public static class StatusInfo {
+ @ApiModelProperty(value = "status text")
+ @SerializedName("status")
+ @JsonProperty(value = "status", required = true)
+ public final String status;
+
+ @ApiModelProperty(value = "Number of EI producers")
+ @SerializedName("no_of_producers")
+ @JsonProperty(value = "no_of_producers", required = true)
+ public final int noOfProducers;
+
+ @ApiModelProperty(value = "Number of EI types")
+ @SerializedName("no_of_types")
+ @JsonProperty(value = "no_of_types", required = true)
+ public final int noOfTypes;
+
+ @ApiModelProperty(value = "Number of EI jobs")
+ @SerializedName("no_of_jobs")
+ @JsonProperty(value = "no_of_jobs", required = true)
+ public final int noOfJobs;
+
+ public StatusInfo(String status, EiProducers producers, EiTypes types, EiJobs jobs) {
+ this.status = status;
+ this.noOfJobs = jobs.size();
+ this.noOfProducers = producers.size();
+ this.noOfTypes = types.size();
+ }
+ }
+
+ @GetMapping(path = "/status", produces = MediaType.APPLICATION_JSON_VALUE)
+ @ApiOperation(value = "Returns status and statistics of this service")
+ @ApiResponses(
+ value = { //
+ @ApiResponse(code = 200, message = "Service is living", response = StatusInfo.class) //
+ })
+ public Mono<ResponseEntity<Object>> getStatus() {
+ StatusInfo info = new StatusInfo("hunky dory", this.eiProducers, this.eiTypes, this.eiJobs);
+ return Mono.just(new ResponseEntity<>(info, HttpStatus.OK));
+ }
+
+}
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java
index 1933c2b..80b6a80 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java
index dcddef3..a8e88d8 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerConsts.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java
index 288421a..39796ee 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
@@ -55,6 +55,7 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@@ -140,12 +141,20 @@
name = ConsumerConsts.OWNER_PARAM,
required = false, //
value = ConsumerConsts.OWNER_PARAM_DESCRIPTION) //
- String owner) {
+ @RequestParam(name = ConsumerConsts.OWNER_PARAM, required = false) String owner) {
try {
this.eiTypes.getType(eiTypeId); // Just to check that the type exists
List<String> result = new ArrayList<>();
- for (EiJob job : this.eiJobs.getJobsForType(eiTypeId)) {
- result.add(job.id());
+ if (owner != null) {
+ for (EiJob job : this.eiJobs.getJobsForOwner(owner)) {
+ if (eiTypeId == null || job.type().getId().equals(eiTypeId)) {
+ result.add(job.id());
+ }
+ }
+ } else {
+ for (EiJob job : this.eiJobs.getJobsForType(eiTypeId)) {
+ result.add(job.id());
+ }
}
return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
} catch (Exception e) {
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java
index 3111d10..47abcbb 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiJobInfo.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java
index 0d04115..3a2ab41 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerEiTypeInfo.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java
index 9e56197..9722594 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
index 8adff41..d67b8ed 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java
index 9a82161..f13f981 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java
index 19bb541..859443d 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java
index 606ee41..7a0dcfd 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java
@@ -34,10 +34,12 @@
private Map<String, EiJob> allEiJobs = new HashMap<>();
private MultiMap<EiJob> jobsByType = new MultiMap<>();
+ private MultiMap<EiJob> jobsByOwner = new MultiMap<>();
public synchronized void put(EiJob job) {
allEiJobs.put(job.id(), job);
jobsByType.put(job.type().getId(), job.id(), job);
+ jobsByOwner.put(job.owner(), job.id(), job);
}
public synchronized Collection<EiJob> getJobs() {
@@ -60,6 +62,10 @@
return jobsByType.get(type.getId());
}
+ public synchronized Collection<EiJob> getJobsForOwner(String owner) {
+ return jobsByOwner.get(owner);
+ }
+
public synchronized EiJob get(String id) {
return allEiJobs.get(id);
}
@@ -75,6 +81,7 @@
public synchronized void remove(EiJob job) {
this.allEiJobs.remove(job.id());
jobsByType.remove(job.type().getId(), job.id());
+ jobsByOwner.remove(job.owner(), job.id());
}
public synchronized int size() {
@@ -84,6 +91,7 @@
public synchronized void clear() {
this.allEiJobs.clear();
this.jobsByType.clear();
+ jobsByOwner.clear();
}
}
diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java
index 3b62fa7..f239a48 100644
--- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java
+++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
@@ -21,6 +21,7 @@
package org.oransc.enrichment.tasks;
import org.oransc.enrichment.clients.AsyncRestClient;
+import org.oransc.enrichment.clients.AsyncRestClientFactory;
import org.oransc.enrichment.configuration.ApplicationConfig;
import org.oransc.enrichment.repository.EiJobs;
import org.oransc.enrichment.repository.EiProducer;
@@ -45,17 +46,20 @@
public class ProducerSupervision {
private static final Logger logger = LoggerFactory.getLogger(ProducerSupervision.class);
- @Autowired
- ApplicationConfig applicationConfig;
+ private final EiProducers eiProducers;
+ private final EiJobs eiJobs;
+ private final EiTypes eiTypes;
+ private final AsyncRestClient restClient;
@Autowired
- EiProducers eiProducers;
-
- @Autowired
- EiJobs eiJobs;
-
- @Autowired
- EiTypes eiTypes;
+ public ProducerSupervision(ApplicationConfig applicationConfig, EiProducers eiProducers, EiJobs eiJobs,
+ EiTypes eiTypes) {
+ AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig());
+ this.restClient = restClientFactory.createRestClient("");
+ this.eiJobs = eiJobs;
+ this.eiProducers = eiProducers;
+ this.eiTypes = eiTypes;
+ }
@Scheduled(fixedRate = 1000 * 60 * 5)
public void checkAllProducers() {
@@ -69,7 +73,7 @@
}
private Mono<EiProducer> checkOneProducer(EiProducer producer) {
- return restClient().get(producer.getProducerSupervisionCallbackUrl()) //
+ return restClient.get(producer.getProducerSupervisionCallbackUrl()) //
.onErrorResume(throwable -> {
handleNonRespondingProducer(throwable, producer);
return Mono.empty();
@@ -91,8 +95,4 @@
producer.setAliveStatus(true);
}
- private AsyncRestClient restClient() {
- return new AsyncRestClient("", this.applicationConfig.getWebClientConfig());
- }
-
}
diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java
index 67b0d8a..e564fef 100644
--- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java
+++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
@@ -42,6 +42,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.oransc.enrichment.clients.AsyncRestClient;
+import org.oransc.enrichment.clients.AsyncRestClientFactory;
import org.oransc.enrichment.clients.ProducerJobInfo;
import org.oransc.enrichment.configuration.ApplicationConfig;
import org.oransc.enrichment.configuration.ImmutableWebClientConfig;
@@ -164,6 +165,13 @@
}
@Test
+ void testGetEiTypesEmpty() throws Exception {
+ String url = ConsumerConsts.API_ROOT + "/eitypes";
+ String rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[]");
+ }
+
+ @Test
void testGetEiType() throws Exception {
putEiProducerWithOneType(EI_PRODUCER_ID, "test");
String url = ConsumerConsts.API_ROOT + "/eitypes/test";
@@ -185,6 +193,14 @@
String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs";
String rsp = restClient().get(url).block();
assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+ url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=owner";
+ rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+ url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=JUNK";
+ rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[]");
}
@Test
@@ -474,6 +490,16 @@
assertThat(this.eiTypes.size()).isEqualTo(0);
}
+ @Test
+ void testGetStatus() throws JsonMappingException, JsonProcessingException, ServiceException {
+ putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID);
+ putEiProducerWithOneTypeRejecting("simulateProducerError2", EI_TYPE_ID);
+
+ String url = "/status";
+ ResponseEntity<String> resp = restClient().getForEntity(url).block();
+ assertThat(resp.getBody()).contains("hunky dory");
+ }
+
ProducerEiTypeRegistrationInfo producerEiTypeRegistrationInfo(String typeId)
throws JsonMappingException, JsonProcessingException {
return new ProducerEiTypeRegistrationInfo(jsonSchemaObject(), typeId);
@@ -576,7 +602,8 @@
.trustStorePassword(config.trustStorePassword()) //
.build();
- return new AsyncRestClient(baseUrl(), config);
+ AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config);
+ return restClientFactory.createRestClient(baseUrl());
}
private AsyncRestClient restClient() {
diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/MockEnrichmentService.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/MockEnrichmentService.java
index fa11044..d51007b 100644
--- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/MockEnrichmentService.java
+++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/MockEnrichmentService.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java
index e2273cf..f879c7b 100644
--- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java
+++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java
index 479c1b2..c465196 100644
--- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java
+++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java
@@ -1,9 +1,9 @@
/*-
* ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * 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
diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh
index 413b22e..e4482b6 100755
--- a/test/auto-test/FTC1.sh
+++ b/test/auto-test/FTC1.sh
@@ -20,8 +20,8 @@
TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -45,61 +45,49 @@
echo "#####################################################################"
echo "#####################################################################"
- #Local vars in test script
- ##########################
if [ $__httpx == "HTTPS" ]; then
- # Path to callback receiver
CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
+ use_simulator_https
+ use_mr_https
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_https
+ fi
+ if [[ $interface = *"DMAAP"* ]]; then
+ use_agent_dmaap_https
+ else
+ use_agent_rest_https
+ fi
else
- # Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
+ use_simulator_http
+ use_mr_http
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_http
+ fi
+ if [[ $interface = *"DMAAP"* ]]; then
+ use_agent_dmaap_http
+ else
+ use_agent_rest_http
+ fi
fi
# Clean container and start all needed containers #
clean_containers
- if [ $__httpx == "HTTPS" ]; then
- #"Using secure ports towards simulators"
- use_simulator_https
- else
- #"Using non-secure ports towards simulators"
- use_simulator_http
- fi
-
start_ric_simulators ricsim_g1 1 OSC_2.1.0
start_ric_simulators ricsim_g2 1 STD_1.1.3
start_mr
- if [ $__httpx == "HTTPS" ]; then
- #echo "Using secure ports between agent and MR"
- use_mr_https
- else
- #"Using non-secure ports between agent and MR"
- use_mr_http
- fi
-
start_cr
- if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
-
- start_sdnc
-
- if [ $__httpx == "HTTPS" ]; then
- # "Using secure ports towards SDNC"
- use_sdnc_https
- else
- #"Using non-secure ports towards SDNC"
- use_sdnc_http
- fi
- fi
-
start_consul_cbs
- if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+ if [[ $interface = *"SDNC"* ]]; then
+ start_sdnc
prepare_consul_config SDNC ".consul_config.json"
else
prepare_consul_config NOSDNC ".consul_config.json"
@@ -112,25 +100,7 @@
start_policy_agent
set_agent_debug
-
- if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards dmaap"
- use_agent_dmaap_https
- else
- echo "Using non-secure ports towards dmaap"
- use_agent_dmaap_http
- fi
- else
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards the agent"
- use_agent_rest_https
- else
- echo "Using non-secure ports towards the agent"
- use_agent_rest_http
- fi
- fi
-
+ set_agent_trace
cr_equal received_callbacks 0
mr_equal requests_submitted 0
@@ -189,7 +159,7 @@
cr_equal received_callbacks 0
- if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
+ if [[ $interface = *"DMAAP"* ]]; then
VAL=11 # Number of Agent API calls over DMAAP
mr_equal requests_fetched $VAL
mr_equal responses_submitted $VAL
@@ -200,7 +170,7 @@
mr_equal requests_submitted 0
fi
- if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+ if [[ $interface = *"SDNC"* ]]; then
sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
else
diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh
index 2e627fc..42b8f58 100755
--- a/test/auto-test/FTC10.sh
+++ b/test/auto-test/FTC10.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -34,7 +34,12 @@
##########################
# Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
use_cr_http
+use_simulator_http
+use_mr_http
+use_agent_rest_http
+
clean_containers
diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh
index 728252d..b617d3f 100755
--- a/test/auto-test/FTC100.sh
+++ b/test/auto-test/FTC100.sh
@@ -20,8 +20,8 @@
TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/without SDNC A1 Controller"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -44,61 +44,48 @@
echo "#####################################################################"
echo "#####################################################################"
- #Local vars in test script
- ##########################
-
if [ $__httpx == "HTTPS" ]; then
- # Path to callback receiver
CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
+ use_simulator_https
+ use_mr_https
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_https
+ fi
+ if [[ $interface = *"DMAAP"* ]]; then
+ use_agent_dmaap_https
+ else
+ use_agent_rest_https
+ fi
else
- # Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
+ use_simulator_http
+ use_mr_http
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_http
+ fi
+ if [[ $interface = *"DMAAP"* ]]; then
+ use_agent_dmaap_http
+ else
+ use_agent_rest_http
+ fi
fi
# Clean container and start all needed containers #
clean_containers
- if [ $__httpx == "HTTPS" ]; then
- #"Using secure ports towards simulators"
- use_simulator_https
- else
- #"Using non-secure ports towards simulators"
- use_simulator_http
- fi
-
start_ric_simulators ricsim_g1 1 OSC_2.1.0
start_ric_simulators ricsim_g2 1 STD_1.1.3
start_mr
- if [ $__httpx == "HTTPS" ]; then
- #echo "Using secure ports between agent and MR"
- use_mr_https
- else
- #"Using non-secure ports between agent and MR"
- use_mr_http
- fi
-
start_cr
- if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
-
- start_sdnc
-
- if [ $__httpx == "HTTPS" ]; then
- # "Using secure ports towards SDNC"
- use_sdnc_https
- else
- #"Using non-secure ports towards SDNC"
- use_sdnc_http
- fi
- fi
-
start_consul_cbs
- if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+ if [[ $interface = *"SDNC"* ]]; then
+ start_sdnc
prepare_consul_config SDNC ".consul_config.json"
else
prepare_consul_config NOSDNC ".consul_config.json"
@@ -112,25 +99,6 @@
set_agent_debug
- if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards dmaap"
- use_agent_dmaap_https
- else
- echo "Using non-secure ports towards dmaap"
- use_agent_dmaap_http
- fi
- else
- if [ $__httpx == "HTTPS" ]; then
- #"Using secure ports towards the agent"
- use_agent_rest_https
- else
- #"Using non-secure ports towards the agent"
- use_agent_rest_http
- fi
- fi
-
-
cr_equal received_callbacks 0
mr_equal requests_submitted 0
@@ -148,8 +116,6 @@
api_equal json:policy_ids 0
-
-
echo "############################################"
echo "############## Health check ################"
echo "############################################"
@@ -388,7 +354,7 @@
cr_equal received_callbacks 0
- if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
+ if [[ $interface = *"DMAAP"* ]]; then
mr_greater requests_submitted 0
VAL=$(mr_read requests_submitted)
mr_equal requests_fetched $VAL
@@ -400,7 +366,7 @@
mr_equal requests_submitted 0
fi
- if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+ if [[ $interface = *"SDNC"* ]]; then
sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
else
diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh
index d6894b5..c840800 100755
--- a/test/auto-test/FTC110.sh
+++ b/test/auto-test/FTC110.sh
@@ -20,8 +20,8 @@
TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDMC SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -33,7 +33,11 @@
##########################
# Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
use_cr_http
+use_simulator_http
+use_mr_http
+use_agent_rest_http
#### TEST BEGIN ####
@@ -57,8 +61,6 @@
set_agent_debug
-use_agent_rest_http
-
#Verify no callbacks or dmaap messages has been sent
cr_equal received_callbacks 0
mr_equal requests_submitted 0
@@ -187,7 +189,7 @@
api_get_service_ids 200
deviation "TR18 Agents sends callback with empty body"
-cr_equal received_callbacks 0
+cr_equal received_callbacks 4
mr_equal requests_submitted 0
check_policy_agent_logs
diff --git a/test/auto-test/FTC1100.sh b/test/auto-test/FTC1100.sh
new file mode 100755
index 0000000..a61f1bb
--- /dev/null
+++ b/test/auto-test/FTC1100.sh
@@ -0,0 +1,225 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+
+TC_ONELINE_DESCR="Experimental ECS test case"
+
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="ECS PRODSTUB"
+
+. ../common/testcase_common.sh $@
+. ../common/ecs_api_functions.sh
+. ../common/prodstub_api_functions.sh
+
+#### TEST BEGIN ####
+
+clean_containers
+
+use_ecs_rest_http
+
+use_prod_stub_http
+
+start_ecs
+
+start_prod_stub
+
+set_ecs_debug
+
+set_ecs_trace
+
+# Setup prodstub sim to accept calls for producers, types and jobs
+prodstub_arm_supervision 200 prod-a
+prodstub_arm_supervision 200 prod-b
+prodstub_arm_supervision 200 prod-c
+
+prodstub_arm_type 200 prod-a type1
+prodstub_arm_type 200 prod-b type2
+prodstub_arm_type 200 prod-b type3
+
+prodstub_disarm_type 200 prod-b type3
+prodstub_arm_type 200 prod-b type1
+prodstub_disarm_type 200 prod-b type1
+
+prodstub_arm_create 200 prod-a job1
+prodstub_arm_create 200 prod-a job2
+prodstub_arm_create 200 prod-b job3
+
+prodstub_arm_delete 200 prod-a job1
+prodstub_arm_delete 200 prod-a job2
+prodstub_arm_delete 200 prod-b job3
+
+prodstub_arm_create 200 prod-b job4
+prodstub_arm_create 200 prod-a job4
+
+prodstub_arm_create 200 prod-b job5
+prodstub_arm_create 200 prod-a job5
+prodstub_arm_delete 200 prod-a job5
+
+prodstub_arm_create 200 prod-b job6
+
+# ecs status
+ecs_api_service_status 200
+
+# Initial tests - no config made
+ecs_api_a1_get_type_ids 200 EMPTY
+ecs_api_a1_get_type 404 test-type
+
+ecs_api_edp_get_type_ids 200 EMPTY
+ecs_api_edp_get_type 404 test-type
+
+ecs_api_edp_get_producer_ids 200 EMPTY
+ecs_api_edp_get_producer 404 test-prod
+
+ecs_api_edp_get_producer_status 404 test-prod
+
+ecs_api_edp_delete_producer 404 test-prod
+
+ecs_api_a1_get_job_ids 404 test-type NOWNER
+ecs_api_a1_get_job_ids 404 test-type test-owner
+
+ecs_api_a1_get_job 404 test-type test-job
+
+ecs_api_a1_get_job_status 404 test-type test-job
+
+ecs_api_a1_delete_job 404 test-type test-job
+
+ecs_api_edp_get_producer_jobs 404 test-prod
+
+
+# Setup of producer/job and test apis
+#prod-a
+ecs_api_edp_put_producer 201 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
+ecs_api_edp_put_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
+
+ecs_api_a1_get_type_ids 200 type1
+ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json
+
+ecs_api_edp_get_type_ids 200 type1
+ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a
+
+ecs_api_edp_get_producer_ids 200 prod-a
+ecs_api_edp_get_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
+
+ecs_api_edp_get_producer_status 200 prod-a ENABLED
+
+ecs_api_a1_get_job_ids 200 type1 NOWNER EMPTY
+ecs_api_a1_get_job_ids 200 type1 test-owner EMPTY
+
+ecs_api_a1_get_job 404 type1 test-job
+
+ecs_api_a1_get_job_status 404 type1 test-job
+
+ecs_api_edp_get_producer_jobs 200 prod-a EMPTY
+
+
+#job1 - prod-a
+ecs_api_a1_put_job 201 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json
+
+prodstub_check_jobdata 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json
+
+ecs_api_a1_get_job_ids 200 type1 NOWNER job1
+ecs_api_a1_get_job_ids 200 type1 ric1 job1
+
+ecs_api_a1_get_job 200 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json
+
+ecs_api_a1_get_job_status 200 type1 job1 ENABLED
+
+ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json
+
+
+#job2 - prod-a
+ecs_api_a1_put_job 201 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json
+
+prodstub_check_jobdata 200 prod-a job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json
+
+ecs_api_a1_get_job_ids 200 type1 NOWNER job1 job2
+ecs_api_a1_get_job_ids 200 type1 ric1 job1
+ecs_api_a1_get_job_ids 200 type1 ric2 job2
+
+ecs_api_a1_get_job 200 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json
+
+ecs_api_a1_get_job_status 200 type1 job2 ENABLED
+
+ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json
+
+
+#prod-b
+ecs_api_edp_put_producer 201 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json
+
+ecs_api_a1_get_type_ids 200 type1 type2
+ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json
+ecs_api_a1_get_type 200 type2 testdata/ecs/ei-type-2.json
+
+ecs_api_edp_get_type_ids 200 type1 type2
+ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a
+ecs_api_edp_get_type 200 type2 testdata/ecs/ei-type-2.json prod-b
+
+ecs_api_edp_get_producer_ids 200 prod-a prod-b
+ecs_api_edp_get_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
+ecs_api_edp_get_producer 200 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json
+
+ecs_api_edp_get_producer_status 200 prod-b ENABLED
+
+
+#job3 - prod-b
+ecs_api_a1_put_job 201 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json
+
+prodstub_check_jobdata 200 prod-b job3 type2 http://localhost:80/target3 testdata/ecs/job-template.json
+
+ecs_api_a1_get_job_ids 200 type1 NOWNER job1 job2
+ecs_api_a1_get_job_ids 200 type2 NOWNER job3
+ecs_api_a1_get_job_ids 200 type1 ric1 job1
+ecs_api_a1_get_job_ids 200 type1 ric2 job2
+ecs_api_a1_get_job_ids 200 type2 ric3 job3
+
+ecs_api_a1_get_job 200 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json
+
+ecs_api_a1_get_job_status 200 type2 job3 ENABLED
+
+ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json
+ecs_api_edp_get_producer_jobs 200 prod-b job3 type2 http://localhost:80/target3 testdata/ecs/job-template.json
+
+
+#prod-c (no types)
+ecs_api_edp_put_producer 201 prod-c http://producer-stub:8092/callbacks/create/prod-c http://producer-stub:8092/callbacks/delete/prod-c http://producer-stub:8092/callbacks/supervision/prod-c NOTYPE
+
+ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c
+ecs_api_edp_get_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
+ecs_api_edp_get_producer 200 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json
+ecs_api_edp_get_producer 200 prod-c http://producer-stub:8092/callbacks/create/prod-c http://producer-stub:8092/callbacks/delete/prod-c http://producer-stub:8092/callbacks/supervision/prod-c EMPTY
+
+ecs_api_edp_get_producer_status 200 prod-c ENABLED
+
+ecs_api_a1_delete_job 204 type2 job3
+
+ecs_api_edp_delete_producer 204 prod-b
+
+
+check_sndc_logs
+
+check_ecs_logs
+
+store_logs END
+
+#### TEST COMPLETE ####
+
+
+print_result
+
+auto_clean_containers
diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh
index 3e13bf5..ead424c 100755
--- a/test/auto-test/FTC150.sh
+++ b/test/auto-test/FTC150.sh
@@ -20,8 +20,8 @@
TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API using http/https (no agent)"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="PA CP SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/controller_api_functions.sh
@@ -100,6 +100,8 @@
controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000
controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000
+ check_sdnc_logs
+
store_logs "NB_"$__nb_httpx"_SB_"$__sb_httpx
done
diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh
index 13647c9..fb7bc34 100755
--- a/test/auto-test/FTC300.sh
+++ b/test/auto-test/FTC300.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -43,34 +43,37 @@
echo "#####################################################################"
echo "#####################################################################"
- #Local vars in test script
- ##########################
-
if [ $__httpx == "HTTPS" ]; then
- # Path to callback receiver
CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
+ use_simulator_https
+ use_mr_https
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_https
+ fi
+ if [[ $interface = *"DMAAP"* ]]; then
+ use_agent_dmaap_https
+ else
+ use_agent_rest_https
+ fi
else
- # Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
+ use_simulator_http
+ use_mr_http
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_http
+ fi
+ if [[ $interface = *"DMAAP"* ]]; then
+ use_agent_dmaap_http
+ else
+ use_agent_rest_http
+ fi
fi
# Clean container and start all needed containers #
clean_containers
- if [ $__httpx == "HTTPS" ]; then
- #echo "Using secure ports between agent and MR"
- use_mr_https
- echo "Using secure ports towards simulators"
- use_simulator_https
- else
- #"Using non-secure ports between agent and MR"
- use_mr_http
- echo "Using non-secure ports towards simulators"
- use_simulator_http
- fi
-
start_ric_simulators ricsim_g1 4 OSC_2.1.0
start_ric_simulators ricsim_g2 4 STD_1.1.3
@@ -83,14 +86,7 @@
if [[ $interface = *"SDNC"* ]]; then
start_sdnc
- if [ $__httpx == "HTTPS" ]; then
- # "Using secure ports towards SDNC"
- use_sdnc_https
- else
- #"Using non-secure ports towards SDNC"
- use_sdnc_http
- fi
- prepare_consul_config SDNC ".consul_config.json"
+ prepare_consul_config SDNC ".consul_config.json"
else
prepare_consul_config NOSDNC ".consul_config.json"
fi
@@ -103,24 +99,6 @@
set_agent_debug
- if [[ $interface == *"DMAAP"* ]]; then
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards dmaap"
- use_agent_dmaap_https
- else
- echo "Using non-secure ports towards dmaap"
- use_agent_dmaap_http
- fi
- else
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards the agent"
- use_agent_rest_https
- else
- echo "Using non-secure ports towards the agent"
- use_agent_rest_http
- fi
- fi
-
api_get_status 200
sim_print ricsim_g1_1 interface
diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh
index 7eb3c19..856d6f5 100755
--- a/test/auto-test/FTC310.sh
+++ b/test/auto-test/FTC310.sh
@@ -20,8 +20,8 @@
TC_ONELINE_DESCR="Resync of RIC via changes in the consul config"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh
index 692d9b5..4b2e3cb 100755
--- a/test/auto-test/FTC350.sh
+++ b/test/auto-test/FTC350.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Change supported policy types and reconfigure rics"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -78,7 +78,6 @@
start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
if [[ $interface = *"SDNC"* ]]; then
- start_sdnc
prepare_consul_config SDNC ".consul_config_all.json"
else
prepare_consul_config NOSDNC ".consul_config_all.json"
@@ -87,6 +86,7 @@
start_policy_agent
set_agent_debug
+ set_agent_trace
api_get_status 200
@@ -226,13 +226,13 @@
ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? "
- sleep 120
+ sleep_wait 120
api_equal json:policy_ids 0
api_get_policy_types 404 ricsim_g1_9
- sim_equal ricsim_g1_9 num_instances 1
+ sim_equal ricsim_g1_9 num_instances 0
api_delete_policy 404 2000
@@ -264,7 +264,7 @@
ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
- sleep 120
+ sleep_wait 120
api_equal json:policy_ids 0
@@ -276,7 +276,7 @@
sim_delete_policy_type 204 ricsim_g1_6 4
sim_delete_policy_type 204 ricsim_g1_7 4
- sleep 120
+ sleep_wait 120
api_equal json:policy_types?ric=ricsim_g1_1 1 120
api_equal json:policy_types?ric=ricsim_g1_2 2 120
@@ -319,6 +319,7 @@
check_policy_agent_logs
store_logs ${interface}
+
done
diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh
index b1e9f53..25678be 100755
--- a/test/auto-test/FTC800.sh
+++ b/test/auto-test/FTC800.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Create 10000 policies in sequence using http/https and Agent REST/DMAAP with/without SDNC controller"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -49,17 +49,20 @@
echo "#####################################################################"
echo "#####################################################################"
- #Local vars in test script
- ##########################
-
if [ $__httpx == "HTTPS" ]; then
# Path to callback receiver
CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
+ use_simulator_https
+ use_mr_https
+ use_agent_rest_https
else
# Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
+ use_simulator_http
+ use_mr_http
+ use_agent_rest_http
fi
# Policy instance start id
@@ -67,50 +70,22 @@
clean_containers
- if [ $__httpx == "HTTPS" ]; then
- #"Using secure ports towards simulators"
- use_simulator_https
- else
- #"Using non-secure ports towards simulators"
- use_simulator_http
- fi
-
start_ric_simulators ricsim_g1 1 OSC_2.1.0
start_ric_simulators ricsim_g2 1 STD_1.1.3
start_mr
- if [ $__httpx == "HTTPS" ]; then
- #echo "Using secure ports between agent and MR"
- use_mr_https
- else
- #"Using non-secure ports between agent and MR"
- use_mr_http
- fi
-
start_cr
- if [ $interface == "SDNC" ]; then
-
+ if [[ $interface == "SDNC" ]]; then
start_sdnc
-
- if [ $__httpx == "HTTPS" ]; then
- # "Using secure ports towards SDNC"
- use_sdnc_https
- else
- #"Using non-secure ports towards SDNC"
- use_sdnc_http
- fi
- fi
-
- start_consul_cbs
-
- if [ $interface == "SDNC" ]; then
prepare_consul_config SDNC ".consul_config.json"
else
prepare_consul_config NOSDNC ".consul_config.json"
fi
+ start_consul_cbs
+
consul_config_app ".consul_config.json"
start_control_panel
@@ -119,15 +94,6 @@
set_agent_debug
- if [ $__httpx == "HTTPS" ]; then
- # "Using secure ports towards the agent"
- use_agent_rest_https
- else
- # "Using non-secure ports towards the agent"
- use_agent_rest_http
- fi
-
-
cr_equal received_callbacks 0
mr_equal requests_submitted 0
diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh
index 7fa5ea6..009efc0 100755
--- a/test/auto-test/FTC810.sh
+++ b/test/auto-test/FTC810.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http or https"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh
index b5c991c..7391331 100755
--- a/test/auto-test/FTC850.sh
+++ b/test/auto-test/FTC850.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Create/delete policies in parallel over a number of ric using a number of child process"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL, CP, CR, MR, PA, RICSIM, SDNC"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
@@ -51,32 +51,29 @@
echo "#####################################################################"
echo "#####################################################################"
- #Local vars in test script
- ##########################
-
if [ $__httpx == "HTTPS" ]; then
- # Path to callback receiver
CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
+ use_simulator_https
+ use_mr_https
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_https
+ fi
+ use_agent_rest_https
else
- # Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
+ use_simulator_http
+ use_mr_http
+ if [[ $interface = *"SDNC"* ]]; then
+ use_sdnc_http
+ fi
+ use_agent_rest_http
fi
# Clean container and start all needed containers #
clean_containers
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards simulators and sdnc"
- use_simulator_https
- use_sdnc_https
- else
- echo "Using non-secure ports towards simulators and sdnc"
- use_simulator_http
- use_sdnc_http
- fi
-
start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
start_consul_cbs
@@ -98,14 +95,6 @@
set_agent_debug
- if [ $__httpx == "HTTPS" ]; then
- echo "Using secure ports towards the agent"
- use_agent_rest_https
- else
- echo "Using non-secure ports towards the agent"
- use_agent_rest_http
- fi
-
api_get_status 200
for ((i=1; i<=$NUM_RICS; i++))
diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh
index c483504..3256797 100755
--- a/test/auto-test/FTC900.sh
+++ b/test/auto-test/FTC900.sh
@@ -19,8 +19,8 @@
TC_ONELINE_DESCR="Preparation for test of the Control Panel and the Health Check app - populating a number of ric simulators with types and instances"
-#App names to exclude checking pulling images for, space separated list
-EXCLUDED_IMAGES="SDNC SDNC_ONAP"
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
diff --git a/test/auto-test/PM_DEMO.sh b/test/auto-test/PM_DEMO.sh
new file mode 100755
index 0000000..3696d56
--- /dev/null
+++ b/test/auto-test/PM_DEMO.sh
@@ -0,0 +1,147 @@
+#!/usr/bin/env bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+TC_ONELINE_DESCR="Preparation demo setup - populating a number of ric simulators with types and instances"
+
+#App names to include in the test, space separated list
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+
+. ../common/testcase_common.sh $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+use_cr_http
+use_agent_rest_http
+use_sdnc_http
+use_simulator_http
+
+clean_containers
+
+OSC_NUM_RICS=6
+STD_NUM_RICS=5
+
+start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0
+
+start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3
+
+start_mr #Just to prevent errors in the agent log...
+
+start_control_panel
+
+CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
+use_cr_http
+
+start_sdnc
+
+start_consul_cbs
+
+prepare_consul_config SDNC ".consul_config.json"
+consul_config_app ".consul_config.json"
+
+start_policy_agent
+
+api_get_status 200
+
+# Print the A1 version for OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ sim_print $RIC_SIM_PREFIX"_g1_"$i interface
+done
+
+
+# Print the A1 version for STD
+for ((i=1; i<=$STD_NUM_RICS; i++))
+do
+ sim_print $RIC_SIM_PREFIX"_g2_"$i interface
+done
+
+
+# Load the polictypes in osc
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 100 demo-testdata/OSC/sim_qos.json
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 20008 demo-testdata/OSC/sim_tsa.json
+done
+
+
+#Check the number of schemas and the individual schemas in OSC
+api_equal json:policy_types 3 120
+
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ api_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 2 120
+done
+
+# Check the schemas in OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ api_get_policy_schema 200 100 demo-testdata/OSC/qos-agent-modified.json
+ api_get_policy_schema 200 20008 demo-testdata/OSC/tsa-agent-modified.json
+done
+
+
+# Create policies
+use_agent_rest_http
+
+api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1"
+
+# Create policies in OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT demo-testdata/OSC/piqos_template.json 1
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT demo-testdata/OSC/pitsa_template.json 1
+done
+
+
+# Check the number of policies in OSC
+for ((i=1; i<=$OSC_NUM_RICS; i++))
+do
+ sim_equal $RIC_SIM_PREFIX"_g1_"$i num_instances 2
+done
+
+
+# Create policies in STD
+for ((i=1; i<=$STD_NUM_RICS; i++))
+do
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT demo-testdata/STD/pi1_template.json 1
+done
+
+
+# Check the number of policies in STD
+for ((i=1; i<=$STD_NUM_RICS; i++))
+do
+ sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1
+done
+
+check_policy_agent_logs
+
+#### TEST COMPLETE ####
+
+store_logs END
+
+print_result
diff --git a/test/auto-test/demo-testdata/OSC/hw-agent-modified.json b/test/auto-test/demo-testdata/OSC/hw-agent-modified.json
new file mode 100644
index 0000000..5ea5802
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/hw-agent-modified.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "2",
+ "description": "Hello World policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/OSC/pihw_template.json b/test/auto-test/demo-testdata/OSC/pihw_template.json
new file mode 100644
index 0000000..7574995
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/pihw_template.json
@@ -0,0 +1,3 @@
+{
+ "threshold": XXX
+}
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/OSC/piqos_template.json b/test/auto-test/demo-testdata/OSC/piqos_template.json
new file mode 100644
index 0000000..4446ac5
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/piqos_template.json
@@ -0,0 +1,9 @@
+{
+ "scope": {
+ "ueId": "0x349d230330ea60XXX",
+ "qosId": "4"
+ },
+ "qosObjectives": {
+ "priorityLevel": 30
+ }
+ }
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/OSC/pitsa_template.json b/test/auto-test/demo-testdata/OSC/pitsa_template.json
new file mode 100644
index 0000000..7574995
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/pitsa_template.json
@@ -0,0 +1,3 @@
+{
+ "threshold": XXX
+}
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/OSC/qos-agent-modified.json b/test/auto-test/demo-testdata/OSC/qos-agent-modified.json
new file mode 100644
index 0000000..3a012cd
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/qos-agent-modified.json
@@ -0,0 +1,40 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "100",
+ "description": "Quality of Service policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjectives"
+ ]
+ }
diff --git a/test/auto-test/demo-testdata/OSC/sim_hw.json b/test/auto-test/demo-testdata/OSC/sim_hw.json
new file mode 100644
index 0000000..47e0ae0
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/sim_hw.json
@@ -0,0 +1,18 @@
+{
+ "name": "hwpolicy",
+ "description": "Hellow World policy type",
+ "policy_type_id": 2,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "HW Policy",
+ "description": "Hello World policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
+ }
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/OSC/sim_qos.json b/test/auto-test/demo-testdata/OSC/sim_qos.json
new file mode 100644
index 0000000..92eaa6f
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/sim_qos.json
@@ -0,0 +1,45 @@
+{
+ "name": "pt1",
+ "description": "pt1 policy type",
+ "policy_type_id": 100,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type1_1.0.0",
+ "description": "Quality of Service policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjectives"
+ ]
+ }
+}
diff --git a/test/auto-test/demo-testdata/OSC/sim_tsa.json b/test/auto-test/demo-testdata/OSC/sim_tsa.json
new file mode 100644
index 0000000..9227b5e
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/sim_tsa.json
@@ -0,0 +1,18 @@
+{
+ "name": "tsapolicy",
+ "description": "tsa parameters",
+ "policy_type_id": 20008,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "TS Policy",
+ "description": "Traffic Steering - High prio traffic - policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
+}
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/OSC/tsa-agent-modified.json b/test/auto-test/demo-testdata/OSC/tsa-agent-modified.json
new file mode 100644
index 0000000..d9426c7
--- /dev/null
+++ b/test/auto-test/demo-testdata/OSC/tsa-agent-modified.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "20008",
+ "description": "Traffic Steering - High prio traffic - policy type",
+ "type": "object",
+ "properties": {
+ "threshold": {
+ "type": "integer",
+ "default": 0
+ }
+ },
+ "additionalProperties": false
+ }
\ No newline at end of file
diff --git a/test/auto-test/demo-testdata/STD/pi1_template.json b/test/auto-test/demo-testdata/STD/pi1_template.json
new file mode 100644
index 0000000..e06b031
--- /dev/null
+++ b/test/auto-test/demo-testdata/STD/pi1_template.json
@@ -0,0 +1,9 @@
+{
+ "scope": {
+ "ueId": "ueXXX",
+ "qosId": "qosXXX"
+ },
+ "qosObjectives": {
+ "priorityLevel": XXX
+ }
+}
\ No newline at end of file
diff --git a/test/auto-test/testdata/ecs/ei-type-1.json b/test/auto-test/testdata/ecs/ei-type-1.json
new file mode 100644
index 0000000..c74ba28
--- /dev/null
+++ b/test/auto-test/testdata/ecs/ei-type-1.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "STD_Type1_1.0.0",
+ "description": "EI-Type 1",
+ "type": "object"
+}
\ No newline at end of file
diff --git a/test/auto-test/testdata/ecs/ei-type-2.json b/test/auto-test/testdata/ecs/ei-type-2.json
new file mode 100644
index 0000000..68a1137
--- /dev/null
+++ b/test/auto-test/testdata/ecs/ei-type-2.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "STD_Type2_1.0.0",
+ "description": "EI-Type 2",
+ "type": "object"
+}
\ No newline at end of file
diff --git a/test/auto-test/testdata/ecs/job-template.json b/test/auto-test/testdata/ecs/job-template.json
new file mode 100644
index 0000000..9426d27
--- /dev/null
+++ b/test/auto-test/testdata/ecs/job-template.json
@@ -0,0 +1,5 @@
+{
+ "jobparam1":"value1_XXXX",
+ "jobparam2":"value2_XXXX",
+ "jobparam3":"value3_XXXX"
+}
\ No newline at end of file
diff --git a/test/common/README.md b/test/common/README.md
index 09e8e22..b35966a 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -159,7 +159,7 @@
| parameter | description |
| --------- | ----------- |
-| `SDNC|SDNC_ONAP|NOSDNC` | Configure based on a1-controller (SNDC), a1-adapter (SDNC_ONAP) or without a controller/adapter (NOSDNC) |
+| `SDNC|NOSDNC` | Configure based on a1-controller (SNDC) or without a controller/adapter (NOSDNC) |
| `<output-file>` | The path to the json output file containing the prepared config. This file is used in 'consul_config_app' |
#### Function: start_consul_cbs ####
@@ -216,18 +216,6 @@
|--|
| None |
-#### Function: start_sdnc_onap ####
-Start the SDNC A1 Adapter container and its database container
-| arg list |
-|--|
-| None |
-
-#### Function: config_sdnc_onap ####
-Configure the SDNC A1 adapter - Not implemented
-| arg list |
-|--|
-| None |
-
#### Function: start_mr ####
Start the Message Router stub interface container
| arg list |
diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh
index 2091d65..29e1bf1 100644
--- a/test/common/agent_api_functions.sh
+++ b/test/common/agent_api_functions.sh
@@ -21,196 +21,7 @@
### API functiond towards the Policy Agent
-# Generic function to query the agent via the REST or DMAAP interface.
-# Used by all other agent api test functions
-# If operation prefix is '_BATCH' the the send and get response is split in two sequences,
-# one for sending the requests and one for receiving the response
-# but only when using the DMAAP interface
-# REST or DMAAP is controlled of the base url of $ADAPTER
-# arg: (GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (RESPONSE <correlation-id>)
-# (Not for test scripts)
-__do_curl_to_agent() {
- echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
- paramError=0
-
- if [ $# -lt 2 ] || [ $# -gt 3 ]; then
- paramError=1
- else
- timeout=""
- oper=""
- file=''
- httpcode=" -sw %{http_code}"
- accept=''
- content=''
- batch=0
- if [[ $1 == *"_BATCH" ]]; then
- batch=1
- fi
- if [ $# -gt 2 ]; then
- content=" -H Content-Type:application/json"
- fi
- if [ $1 == "GET" ] || [ $1 == "GET_BATCH" ]; then
- oper="GET"
- if [ $# -ne 2 ]; then
- paramError=1
- fi
- elif [ $1 == "PUT" ] || [ $1 == "PUT_BATCH" ]; then
- oper="PUT"
- if [ $# -eq 3 ]; then
- file=" --data-binary @$3"
- fi
- accept=" -H accept:application/json"
- elif [ $1 == "POST" ] || [ $1 == "POST_BATCH" ]; then
- oper="POST"
- accept=" -H accept:*/*"
- if [ $# -ne 2 ]; then
- paramError=1
- fi
- elif [ $1 == "DELETE" ] || [ $1 == "DELETE_BATCH" ]; then
- oper="DELETE"
- if [ $# -ne 2 ]; then
- paramError=1
- fi
- elif [ $1 == "RESPONSE" ]; then
- oper="RESPONSE"
- if [ $# -ne 2 ]; then
- paramError=1
- fi
- if [ $ADAPTER == $RESTBASE ] || [ $ADAPTER == $RESTBASE_SECURE ]; then
- paramError=1
- fi
- else
- paramError=1
- fi
- fi
-
- if [ $paramError -eq 1 ]; then
- ((RES_CONF_FAIL++))
- echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG
- echo "-Expected: (GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (RESPONSE <correlation-id>) [<file>]" >> $HTTPLOG
- echo "-Returning response 000" >> $HTTPLOG
- echo "-000"
- return 1
- fi
-
- if [ $ADAPTER == $RESTBASE ] || [ $ADAPTER == $RESTBASE_SECURE ]; then
- url=" "${ADAPTER}${2}
- oper=" -X "$oper
- curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file}
- echo " CMD: "$curlString >> $HTTPLOG
- if [ $# -eq 3 ]; then
- echo " FILE: $(<$3)" >> $HTTPLOG
- fi
-
- # Do retry for configured response codes, otherwise only one attempt
- maxretries=5
- while [ $maxretries -ge 0 ]; do
-
- let maxretries=maxretries-1
- res=$($curlString)
- retcode=$?
- if [ $retcode -ne 0 ]; then
- echo " RETCODE: "$retcode >> $HTTPLOG
- echo "000"
- return 1
- fi
- retry=0
- echo " RESP: "$res >> $HTTPLOG
- status=${res:${#res}-3}
- if [ ! -z "${AGENT_RETRY_CODES}" ]; then
- for retrycode in $AGENT_RETRY_CODES; do
- if [ $retrycode -eq $status ]; then
- echo -e $RED" Retrying (according to set codes for retry), got status $status....."$ERED >> $HTTPLOG
- sleep 1
- retry=1
- fi
- done
- fi
- if [ $retry -eq 0 ]; then
- maxretries=-1
- fi
- done
- echo $res
- return 0
- else
- if [ $oper != "RESPONSE" ]; then
- requestUrl=$2
- if [ $1 == "PUT" ] && [ $# -eq 3 ]; then
- payload="$(cat $3 | tr -d '\n' | tr -d ' ' )"
- echo "payload: "$payload >> $HTTPLOG
- file=" --data-binary "$payload
- fi
- #urlencode the request url since it will be carried by send-request url
- requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2")
- url=" "${ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper}
- curlString="curl -k -X POST${timeout}${httpcode}${content}${url}${file}"
- echo " CMD: "$curlString >> $HTTPLOG
- res=$($curlString)
- retcode=$?
- if [ $retcode -ne 0 ]; then
- echo " RETCODE: "$retcode >> $HTTPLOG
- echo "000"
- return 1
- fi
- echo " RESP: "$res >> $HTTPLOG
- status=${res:${#res}-3}
- if [ $status -ne 200 ]; then
- echo "000"
- return 1
- fi
- cid=${res:0:${#res}-3}
- if [[ $batch -eq 1 ]]; then
- echo $cid"200"
- return 0
- fi
- fi
- if [ $oper == "RESPONSE" ] || [ $batch -eq 0 ]; then
- if [ $oper == "RESPONSE" ]; then
- cid=$2
- fi
- url=" "${ADAPTER}"/receive-response?correlationid="${cid}
- curlString="curl -k -X GET"${timeout}${httpcode}${url}
- echo " CMD: "$curlString >> $HTTPLOG
- res=$($curlString)
- retcode=$?
- if [ $retcode -ne 0 ]; then
- echo " RETCODE: "$retcode >> $HTTPLOG
- echo "000"
- return 1
- fi
- echo " RESP: "$res >> $HTTPLOG
- status=${res:${#res}-3}
- TS=$SECONDS
- # wait of the reply from the agent...
- while [ $status -eq 204 ]; do
- if [ $(($SECONDS - $TS)) -gt 90 ]; then
- echo " RETCODE: (timeout after 90s)" >> $HTTPLOG
- echo "000"
- return 1
- fi
- sleep 0.01
- echo " CMD: "$curlString >> $HTTPLOG
- res=$($curlString)
- if [ $retcode -ne 0 ]; then
- echo " RETCODE: "$retcode >> $HTTPLOG
- echo "000"
- return 1
- fi
- echo " RESP: "$res >> $HTTPLOG
- status=${res:${#res}-3}
- done
- if [ $status -eq 200 ]; then
- body=${res:0:${#res}-3}
- echo $body
- return 0
- fi
- echo "Status not 200, returning response 000" >> $HTTPLOG
- echo "0000"
- return 1
- fi
- fi
-}
-
+. ../common/api_curl.sh
#########################################################
#### Test case functions A1 Policy management service
@@ -274,7 +85,7 @@
fi
query="/policies"$queryparams
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -303,7 +114,7 @@
else
targetJson=$targetJson"\"${arr[$i+3]}\","
fi
- file=".p.json"
+ file="./tmp/.p.json"
sed 's/XXX/'${arr[$i]}'/g' ${arr[$i+4]} > $file
json=$(cat $file)
targetJson=$targetJson"\"json\":"$json"}"
@@ -342,7 +153,7 @@
fi
query="/policy?id=$UUID$2"
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -355,7 +166,7 @@
if [ $# -eq 3 ]; then
#Create a policy json to compare with
body=${res:0:${#res}-3}
- file=".p.json"
+ file="./tmp/.p.json"
sed 's/XXX/'${2}'/g' $3 > $file
targetJson=$(< $file)
echo "TARGET JSON: $targetJson" >> $HTTPLOG
@@ -408,13 +219,13 @@
query=$query"&transient=$6"
fi
- file=".p.json"
+ file="./tmp/.p.json"
sed 's/XXX/'${pid}'/g' $7 > $file
- res="$(__do_curl_to_agent PUT $query $file)"
+ res="$(__do_curl_to_api PA PUT $query $file)"
status=${res:${#res}-3}
- echo -ne " Creating "$count"("$max")${SAMELINE}"
+ echo -ne " Executing "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
- echo " Created "$count"?("$max")"
+ echo " Executed "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
__check_stop_at_error
@@ -423,7 +234,7 @@
let pid=$pid+1
let count=$count+1
- echo -ne " Created "$count"("$max")${SAMELINE}"
+ echo -ne " Executed "$count"("$max")${SAMELINE}"
done
echo ""
@@ -467,11 +278,11 @@
query=$query"&transient=$6"
fi
- file=".p.json"
+ file="./tmp/.p.json"
sed 's/XXX/'${pid}'/g' $7 > $file
- res="$(__do_curl_to_agent PUT_BATCH $query $file)"
+ res="$(__do_curl_to_api PA PUT_BATCH $query $file)"
status=${res:${#res}-3}
- echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
+ echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne 200 ]; then
echo " Requested(batch) "$count"?("$max")"
@@ -491,12 +302,12 @@
count=0
for cid in $ARR; do
- res="$(__do_curl_to_agent RESPONSE $cid)"
+ res="$(__do_curl_to_api PA RESPONSE $cid)"
status=${res:${#res}-3}
- echo -ne " Created(batch) "$count"("$max")${SAMELINE}"
+ echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
- echo " Created(batch) "$count"?("$max")"
+ echo " Requested(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
__check_stop_at_error
@@ -504,7 +315,7 @@
fi
let count=$count+1
- echo -ne " Created(batch) "$count"("$max")${SAMELINE}"
+ echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
done
echo ""
@@ -563,19 +374,19 @@
if [ -z "$uuid" ]; then
uuid="NOUUID"
fi
- echo "" > ".pid${i}.res.txt"
- echo $resp_code $urlbase $ric_base $num_rics $uuid $start_id $template $count $pids $i > ".pid${i}.txt"
+ echo "" > "./tmp/.pid${i}.res.txt"
+ echo $resp_code $urlbase $ric_base $num_rics $uuid $start_id $template $count $pids $i > "./tmp/.pid${i}.txt"
echo $i
done | xargs -n 1 -I{} -P $pids bash -c '{
arg=$(echo {})
echo " Parallel process $arg started"
- tmp=$(< ".pid${arg}.txt")
- python3 ../common/create_policies_process.py $tmp > .pid${arg}.res.txt
+ tmp=$(< "./tmp/.pid${arg}.txt")
+ python3 ../common/create_policies_process.py $tmp > ./tmp/.pid${arg}.res.txt
}'
msg=""
for ((i=1; i<=$pids; i++))
do
- file=".pid${i}.res.txt"
+ file="./tmp/.pid${i}.res.txt"
tmp=$(< $file)
if [ -z "$tmp" ]; then
echo " Process $i : unknown result (result file empty"
@@ -591,7 +402,7 @@
fi
done
if [ -z $msg ]; then
- echo " $(($count*$num_rics)) policies created/updated"
+ echo " $(($count*$num_rics)) policy request(s) executed"
((RES_PASS++))
echo -e $GREEN" PASS"$EGREEN
return 0
@@ -627,12 +438,12 @@
while [ $count -lt $max ]; do
query="/policy?id="$UUID$pid
- res="$(__do_curl_to_agent DELETE $query)"
+ res="$(__do_curl_to_api PA DELETE $query)"
status=${res:${#res}-3}
- echo -ne " Deleting "$count"("$max")${SAMELINE}"
+ echo -ne " Executing "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
- echo " Deleted "$count"?("$max")"
+ echo " Executed "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
__check_stop_at_error
@@ -640,7 +451,7 @@
fi
let pid=$pid+1
let count=$count+1
- echo -ne " Deleted "$count"("$max")${SAMELINE}"
+ echo -ne " Executed "$count"("$max")${SAMELINE}"
done
echo ""
@@ -673,9 +484,9 @@
ARR=""
while [ $count -lt $max ]; do
query="/policy?id="$UUID$pid
- res="$(__do_curl_to_agent DELETE_BATCH $query)"
+ res="$(__do_curl_to_api PA DELETE_BATCH $query)"
status=${res:${#res}-3}
- echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
+ echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne 200 ]; then
echo " Requested(batch) "$count"?("$max")"
@@ -696,7 +507,7 @@
count=0
for cid in $ARR; do
- res="$(__do_curl_to_agent RESPONSE $cid)"
+ res="$(__do_curl_to_api PA RESPONSE $cid)"
status=${res:${#res}-3}
echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}"
@@ -750,19 +561,19 @@
if [ -z "$uuid" ]; then
uuid="NOUUID"
fi
- echo "" > ".pid${i}.del.res.txt"
- echo $resp_code $urlbase $num_rics $uuid $start_id $count $pids $i > ".pid${i}.del.txt"
+ echo "" > "./tmp/.pid${i}.del.res.txt"
+ echo $resp_code $urlbase $num_rics $uuid $start_id $count $pids $i > "./tmp/.pid${i}.del.txt"
echo $i
done | xargs -n 1 -I{} -P $pids bash -c '{
arg=$(echo {})
echo " Parallel process $arg started"
- tmp=$(< ".pid${arg}.del.txt")
- python3 ../common/delete_policies_process.py $tmp > .pid${arg}.del.res.txt
+ tmp=$(< "./tmp/pid${arg}.del.txt")
+ python3 ../common/delete_policies_process.py $tmp > ./tmp/pid${arg}.del.res.txt
}'
msg=""
for ((i=1; i<=$pids; i++))
do
- file=".pid${i}.del.res.txt"
+ file="./tmp/.pid${i}.del.res.txt"
tmp=$(< $file)
if [ -z "$tmp" ]; then
echo " Process $i : unknown result (result file empty"
@@ -778,7 +589,7 @@
fi
done
if [ -z $msg ]; then
- echo " $(($count*$num_rics)) deleted"
+ echo " $(($count*$num_rics)) policy request(s) executed"
((RES_PASS++))
echo -e $GREEN" PASS"$EGREEN
return 0
@@ -825,7 +636,7 @@
fi
query="/policy_ids"$queryparams
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -879,7 +690,7 @@
fi
query="/policy_schema?id=$2"
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -928,7 +739,7 @@
query=$query"?ric="$2
fi
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1003,7 +814,7 @@
query="/policy_status?id="$UUID$2
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1050,7 +861,7 @@
query="/policy_types?ric=$2"
fi
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1107,7 +918,7 @@
return 1
fi
query="/status"
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1140,7 +951,7 @@
query="/ric?managedElementId="$2
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1185,7 +996,7 @@
query="/rics?policyType="$2
fi
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1197,7 +1008,7 @@
if [ $# -gt 2 ]; then
body=${res:0:${#res}-3}
- res=$(python3 ../common/create_rics_json.py ".tmp_rics.json" "$3" )
+ res=$(python3 ../common/create_rics_json.py "./tmp/.tmp_rics.json" "$3" )
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, could not create target ric info json"$ERED
((RES_FAIL++))
@@ -1205,7 +1016,7 @@
return 1
fi
- targetJson=$(<.tmp_rics.json)
+ targetJson=$(<./tmp/.tmp_rics.json)
echo "TARGET JSON: $targetJson" >> $HTTPLOG
res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
@@ -1239,10 +1050,10 @@
query="/service"
json="{\"callbackUrl\": \""$4"\",\"keepAliveIntervalSeconds\": \""$3"\",\"serviceName\": \""$2"\"}"
- file=".tmp.json"
+ file="./tmp/.tmp.json"
echo "$json" > $file
- res="$(__do_curl_to_agent PUT $query $file)"
+ res="$(__do_curl_to_api PA PUT $query $file)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1290,7 +1101,7 @@
query="/services?name="$2
fi
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1347,7 +1158,7 @@
fi
query="/services"
- res="$(__do_curl_to_agent GET $query)"
+ res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1396,7 +1207,7 @@
fi
query="/services?name="$2
- res="$(__do_curl_to_agent DELETE $query)"
+ res="$(__do_curl_to_api PA DELETE $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
@@ -1425,7 +1236,7 @@
fi
query="/services/keepalive?name="$2
- res="$(__do_curl_to_agent PUT $query)"
+ res="$(__do_curl_to_api PA PUT $query)"
status=${res:${#res}-3}
if [ $status -ne $1 ]; then
diff --git a/test/common/api_curl.sh b/test/common/api_curl.sh
new file mode 100644
index 0000000..2aff131
--- /dev/null
+++ b/test/common/api_curl.sh
@@ -0,0 +1,223 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+# Generic function to query the agent/ECS via the REST or DMAAP interface.
+# Used by all other agent/ECS api test functions
+# If operation prefix is '_BATCH' the the send and get response is split in two sequences,
+# one for sending the requests and one for receiving the response
+# but only when using the DMAAP interface
+# REST or DMAAP is controlled of the base url of $ADAPTER
+# arg: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (PA|ECS RESPONSE <correlation-id>)
+# (Not for test scripts)
+__do_curl_to_api() {
+ echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ paramError=0
+
+ if [ $# -gt 0 ]; then
+ if [ $1 == "PA" ]; then
+ __ADAPTER=$ADAPTER
+ __RESTBASE=$RESTBASE
+ __RESTBASE_SECURE=$RESTBASE_SECURE
+ __RETRY_CODES=$AGENT_RETRY_CODES
+ elif [ $1 == "ECS" ]; then
+ __ADAPTER=$ECS_ADAPTER
+ __RESTBASE=$ECS_RESTBASE
+ __RESTBASE_SECURE=$ECS_RESTBASE_SECURE
+ __RETRY_CODES=$ECS_RETRY_CODES
+ else
+ paramError=1
+ fi
+ fi
+ if [ $# -lt 3 ] || [ $# -gt 4 ]; then
+ paramError=1
+ else
+ timeout=""
+ oper=""
+ file=''
+ httpcode=" -sw %{http_code}"
+ accept=''
+ content=''
+ batch=0
+ if [[ $2 == *"_BATCH" ]]; then
+ batch=1
+ fi
+ if [ $# -gt 3 ]; then
+ content=" -H Content-Type:application/json"
+ fi
+ if [ $2 == "GET" ] || [ $2 == "GET_BATCH" ]; then
+ oper="GET"
+ if [ $# -ne 3 ]; then
+ paramError=1
+ fi
+ elif [ $2 == "PUT" ] || [ $2 == "PUT_BATCH" ]; then
+ oper="PUT"
+ if [ $# -eq 4 ]; then
+ file=" --data-binary @$4"
+ fi
+ accept=" -H accept:application/json"
+ elif [ $2 == "POST" ] || [ $2 == "POST_BATCH" ]; then
+ oper="POST"
+ accept=" -H accept:*/*"
+ if [ $# -ne 3 ]; then
+ paramError=1
+ fi
+ elif [ $2 == "DELETE" ] || [ $2 == "DELETE_BATCH" ]; then
+ oper="DELETE"
+ if [ $# -ne 3 ]; then
+ paramError=1
+ fi
+ elif [ $2 == "RESPONSE" ]; then
+ oper="RESPONSE"
+ if [ $# -ne 3 ]; then
+ paramError=1
+ fi
+ if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then
+ paramError=1
+ fi
+ else
+ paramError=1
+ fi
+ fi
+
+ if [ $paramError -eq 1 ]; then
+ ((RES_CONF_FAIL++))
+ echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG
+ echo "-Expected: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (PA|ECS RESPONSE <correlation-id>)" >> $HTTPLOG
+ echo "-Returning response 000" >> $HTTPLOG
+ echo "-000"
+ return 1
+ fi
+
+ if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then
+ url=" "${__ADAPTER}${3}
+ oper=" -X "$oper
+ curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file}
+ echo " CMD: "$curlString >> $HTTPLOG
+ if [ $# -eq 4 ]; then
+ echo " FILE: $(<$4)" >> $HTTPLOG
+ fi
+
+ # Do retry for configured response codes, otherwise only one attempt
+ maxretries=5
+ while [ $maxretries -ge 0 ]; do
+
+ let maxretries=maxretries-1
+ res=$($curlString)
+ retcode=$?
+ if [ $retcode -ne 0 ]; then
+ echo " RETCODE: "$retcode >> $HTTPLOG
+ echo "000"
+ return 1
+ fi
+ retry=0
+ echo " RESP: "$res >> $HTTPLOG
+ status=${res:${#res}-3}
+ if [ ! -z "${__RETRY_CODES}" ]; then
+ for retrycode in $__RETRY_CODES; do
+ if [ $retrycode -eq $status ]; then
+ echo -e $RED" Retrying (according to set codes for retry), got status $status....."$ERED >> $HTTPLOG
+ sleep 1
+ retry=1
+ fi
+ done
+ fi
+ if [ $retry -eq 0 ]; then
+ maxretries=-1
+ fi
+ done
+ echo $res
+ return 0
+ else
+ if [ $oper != "RESPONSE" ]; then
+ requestUrl=$3
+ if [ $2 == "PUT" ] && [ $# -eq 4 ]; then
+ payload="$(cat $4 | tr -d '\n' | tr -d ' ' )"
+ echo "payload: "$payload >> $HTTPLOG
+ file=" --data-binary "$payload
+ fi
+ #urlencode the request url since it will be carried by send-request url
+ requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$3")
+ url=" "${__ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper}
+ curlString="curl -k -X POST${timeout}${httpcode}${content}${url}${file}"
+ echo " CMD: "$curlString >> $HTTPLOG
+ res=$($curlString)
+ retcode=$?
+ if [ $retcode -ne 0 ]; then
+ echo " RETCODE: "$retcode >> $HTTPLOG
+ echo "000"
+ return 1
+ fi
+ echo " RESP: "$res >> $HTTPLOG
+ status=${res:${#res}-3}
+ if [ $status -ne 200 ]; then
+ echo "000"
+ return 1
+ fi
+ cid=${res:0:${#res}-3}
+ if [[ $batch -eq 1 ]]; then
+ echo $cid"200"
+ return 0
+ fi
+ fi
+ if [ $oper == "RESPONSE" ] || [ $batch -eq 0 ]; then
+ if [ $oper == "RESPONSE" ]; then
+ cid=$3
+ fi
+ url=" "${__ADAPTER}"/receive-response?correlationid="${cid}
+ curlString="curl -k -X GET"${timeout}${httpcode}${url}
+ echo " CMD: "$curlString >> $HTTPLOG
+ res=$($curlString)
+ retcode=$?
+ if [ $retcode -ne 0 ]; then
+ echo " RETCODE: "$retcode >> $HTTPLOG
+ echo "000"
+ return 1
+ fi
+ echo " RESP: "$res >> $HTTPLOG
+ status=${res:${#res}-3}
+ TS=$SECONDS
+ # wait of the reply from the agent/ECS...
+ while [ $status -eq 204 ]; do
+ if [ $(($SECONDS - $TS)) -gt 90 ]; then
+ echo " RETCODE: (timeout after 90s)" >> $HTTPLOG
+ echo "000"
+ return 1
+ fi
+ sleep 0.01
+ echo " CMD: "$curlString >> $HTTPLOG
+ res=$($curlString)
+ if [ $retcode -ne 0 ]; then
+ echo " RETCODE: "$retcode >> $HTTPLOG
+ echo "000"
+ return 1
+ fi
+ echo " RESP: "$res >> $HTTPLOG
+ status=${res:${#res}-3}
+ done
+ if [ $status -eq 200 ]; then
+ body=${res:0:${#res}-3}
+ echo $body
+ return 0
+ fi
+ echo "Status not 200, returning response 000" >> $HTTPLOG
+ echo "0000"
+ return 1
+ fi
+ fi
+}
\ No newline at end of file
diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh
index 378a6d4..b0ae641 100644
--- a/test/common/controller_api_functions.sh
+++ b/test/common/controller_api_functions.sh
@@ -41,9 +41,10 @@
body=$(echo "$3" | sed 's/"/\\"/g')
json='{"input":{"near-rt-ric-url":"'$2'","body":"'"$body"'"}}'
fi
- echo "$json" > .sdnc.payload.json
- echo " FILE: $json" >> $HTTPLOG
- curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sdnc.payload.json"
+ payload="./tmp/.sdnc.payload.json"
+ echo "$json" > $payload
+ echo " FILE ($payload) : $json" >> $HTTPLOG
+ curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @$payload"
echo " CMD: "$curlString >> $HTTPLOG
res=$($curlString)
retcode=$?
@@ -62,8 +63,9 @@
fi
body=${res:0:${#res}-3}
echo " JSON: "$body >> $HTTPLOG
- echo "$body" > .sdnc-reply.json
- res=$(python3 ../common/extract_sdnc_reply.py .sdnc-reply.json)
+ reply="./tmp/.sdnc-reply.json"
+ echo "$body" > $reply
+ res=$(python3 ../common/extract_sdnc_reply.py $reply)
echo " EXTRACED BODY+CODE: "$res >> $HTTPLOG
echo "$res"
return 0
diff --git a/test/common/do_curl_function.sh b/test/common/do_curl_function.sh
index c4365d8..ac945fe 100755
--- a/test/common/do_curl_function.sh
+++ b/test/common/do_curl_function.sh
@@ -88,8 +88,8 @@
count=${RESULT:16:${#RESULT}}
#Find dir of the common dir
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
- echo $body > .tmp.json
- res=$(python ${DIR}/count_json_elements.py .tmp.json)
+ echo $body > ./tmp/.tmp.json
+ res=$(python ${DIR}/count_json_elements.py ./tmp/.tmp.json)
if [ $res -eq $count ]; then
echo " Body (array size) as expected"
else
diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh
new file mode 100644
index 0000000..6c726b9
--- /dev/null
+++ b/test/common/ecs_api_functions.sh
@@ -0,0 +1,848 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+# This is a script that contains specific test functions for ECS NB/SB API
+
+. ../common/api_curl.sh
+
+############### EXPERIMENTAL #############
+
+##########################################
+###### Mainly only function skeletons ####
+##########################################
+
+##########################################
+### A1-E Enrichment Data Consumer API ####
+##########################################
+#Function prefix: ecs_api_a1
+
+# API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
+# args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
+# (Function for test scripts)
+ecs_api_a1_get_job_ids() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ # Valid number of parameters 3,4,5,6 etc
+ if [ $# -lt 1 ]; then
+ __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
+ return 1
+ fi
+ owner=""
+ if [ $3 != "NOWNER" ]; then
+ owner="?owner="$3
+ fi
+
+ query="/A1-EI/v1/eitypes/$2/eijobs$owner"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ if [ $# -gt 3 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+
+ for pid in ${@:4} ; do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ if [ $pid != "EMPTY" ]; then
+ targetJson=$targetJson"\"$pid\""
+ fi
+ done
+
+ targetJson=$targetJson"]"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}
+# args: <response-code> <type-id> [<schema-file>]
+# (Function for test scripts)
+ecs_api_a1_get_type() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+ __print_err "<response-code> <type-id> [<schema-file>]" $@
+ return 1
+ fi
+
+ query="/A1-EI/v1/eitypes/$2"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ if [ $# -eq 3 ]; then
+ body=${res:0:${#res}-3}
+ if [ -f $3 ]; then
+ schema=$(cat $3)
+ else
+ echo -e $RED" FAIL. Schema file "$3", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ targetJson="{\"eiJobParametersSchema\":$schema}"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET ​/A1-EI​/v1​/eitypes
+# args: <response-code> (EMPTY | [<type-id>]+)
+# (Function for test scripts)
+ecs_api_a1_get_type_ids() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 2 ]; then
+ __print_err "<response-code> (EMPTY | [<type-id>]+)" $@
+ return 1
+ fi
+
+ query="/A1-EI/v1/eitypes"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $2 != "EMPTY" ]; then
+ for pid in ${@:2} ; do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ targetJson=$targetJson"\"$pid\""
+ done
+ fi
+ targetJson=$targetJson"]"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
+# args: <response-code> <type-id> <job-id> [<status>]
+# (Function for test scripts)
+ecs_api_a1_get_job_status() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -ne 3 ] && [ $# -ne 4 ]; then
+ __print_err "<response-code> <type-id> <job-id>" $@
+ return 1
+ fi
+
+ query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ if [ $# -eq 4 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="{\"operationalState\": \"$4\"}"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
+# args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
+# (Function for test scripts)
+ecs_api_a1_get_job() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -ne 3 ] && [ $# -ne 6 ]; then
+ __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
+ return 1
+ fi
+
+ query="/A1-EI/v1/eitypes/$2/eijobs/$3"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ if [ $# -eq 6 ]; then
+ body=${res:0:${#res}-3}
+
+ if [ -f $6 ]; then
+ jobfile=$(cat $6)
+ jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
+ else
+ echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
+# args: <response-code> <type-id> <job-id>
+# (Function for test scripts)
+ecs_api_a1_delete_job() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 3 ]; then
+ __print_err "<response-code> <type-id> <job-id>" $@
+ return 1
+ fi
+
+ query="/A1-EI/v1/eitypes/$2/eijobs/$3"
+ res="$(__do_curl_to_api ECS DELETE $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
+# args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
+# (Function for test scripts)
+ecs_api_a1_put_job() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 6 ]; then
+ __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
+ return 1
+ fi
+ if [ -f $6 ]; then
+ jobfile=$(cat $6)
+ jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
+ else
+ echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
+ file="./tmp/.p.json"
+ echo "$inputJson" > $file
+
+ query="/A1-EI/v1/eitypes/$2/eijobs/$3"
+ res="$(__do_curl_to_api ECS PUT $query $file)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+
+##########################################
+#### Enrichment Data Producer API ####
+##########################################
+# Function prefix: ecs_api_edp
+
+# API Test function: GET /ei-producer/v1/eitypes
+# args: <response-code> [ EMPTY | <type-id>+]
+# (Function for test scripts)
+ecs_api_edp_get_type_ids() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 1 ]; then
+ __print_err "<response-code> [ EMPTY | <type-id>+]" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eitypes"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ if [ $# -gt 1 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $2 != "EMPTY" ]; then
+ for pid in ${@:2} ; do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ targetJson=$targetJson"\"$pid\""
+ done
+ fi
+ targetJson=$targetJson"]"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
+# args: <response-code> <producer-id> [<status>]
+# (Function for test scripts)
+ecs_api_edp_get_producer_status() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 2 ] || [ $# -gt 3 ]; then
+ __print_err "<response-code> <producer-id> <status>" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eiproducers/$2/status"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ if [ $# -eq 3 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="{\"operational_state\": \"$3\"}"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+
+# API Test function: GET /ei-producer/v1/eiproducers
+# args: <response-code> [ EMPTY | <producer-id>+]
+# (Function for test scripts)
+ecs_api_edp_get_producer_ids() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 1 ]; then
+ __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eiproducers"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ if [ $# -gt 1 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+
+ for pid in ${@:2} ; do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ if [ $pid != "EMPTY" ]; then
+ targetJson=$targetJson"\"$pid\""
+ fi
+ done
+
+ targetJson=$targetJson"]"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
+# args: <response-code> <type-id> [<job-schema-file> (NOID | [<producer-id>]+)]
+# (Function for test scripts)
+ecs_api_edp_get_type() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ paramError=1
+ if [ $# -eq 2 ]; then
+ paramError=0
+ fi
+ if [ $# -gt 3 ]; then
+ paramError=0
+ fi
+ if [ $paramError -ne 0 ]; then
+ __print_err "<response-code> <type-id> [<job-schema-file> NOID | ([<producer-id>]+)]" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eitypes/$2"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ if [ $# -gt 3 ]; then
+ body=${res:0:${#res}-3}
+
+ if [ -f $3 ]; then
+ schema=$(cat $3)
+ else
+ echo -e $RED" FAIL. Job template file "$3", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ targetJson=""
+ if [ $4 != "EMPTY" ]; then
+ for pid in ${@:4} ; do
+ if [ "$targetJson" != "" ]; then
+ targetJson=$targetJson","
+ fi
+ targetJson=$targetJson"\"$pid\""
+ done
+ fi
+ targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
+
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
+# args: <response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
+# (Function for test scripts)
+ecs_api_edp_get_producer() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ #Possible arg count: 2, 6 7, 9, 11 etc
+ paramError=1
+ if [ $# -eq 2 ]; then
+ paramError=0
+ fi
+ if [ $# -eq 6 ] && [ "$6" == "EMPTY" ]; then
+ paramError=0
+ fi
+ variablecount=$(($#-5))
+ if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
+ paramError=0
+ fi
+
+ if [ $paramError -ne 0 ]; then
+ __print_err "<response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eiproducers/$2"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ if [ $# -gt 2 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $# -gt 6 ]; then
+ arr=(${@:6})
+ for ((i=0; i<$(($#-6)); i=i+2)); do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ if [ -f ${arr[$i+1]} ]; then
+ schema=$(cat ${arr[$i+1]})
+ else
+ echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
+ done
+ fi
+ targetJson=$targetJson"]"
+ if [ $# -gt 4 ]; then
+ targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\"}"
+ fi
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
+# args: <response-code> <producer-id>
+# (Function for test scripts)
+ecs_api_edp_delete_producer() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 2 ]; then
+ __print_err "<response-code> <producer-id>" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eiproducers/$2"
+ res="$(__do_curl_to_api ECS DELETE $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
+# args: <response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
+# (Function for test scripts)
+ecs_api_edp_put_producer() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ #Valid number of parametrer 6,7,9,11,
+ paramError=1
+ if [ $# -eq 6 ] && [ "$6" == "NOTYPE" ]; then
+ paramError=0
+ elif [ $# -gt 6 ] && [ $(($#%2)) -eq 1 ]; then
+ paramError=0
+ fi
+ if [ $paramError -ne 0 ]; then
+ __print_err "<response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> [<type-id> <schema-file>]+" $@
+ return 1
+ fi
+
+ inputJson="["
+ if [ $# -gt 6 ]; then
+ arr=(${@:6})
+ for ((i=0; i<$(($#-6)); i=i+2)); do
+ if [ "$inputJson" != "[" ]; then
+ inputJson=$inputJson","
+ fi
+ if [ -f ${arr[$i+1]} ]; then
+ schema=$(cat ${arr[$i+1]})
+ else
+ echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
+ done
+ fi
+ inputJson="\"supported_ei_types\":"$inputJson"]"
+
+ inputJson=$inputJson",\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\""
+
+ inputJson="{"$inputJson"}"
+
+ file="./tmp/.p.json"
+ echo "$inputJson" > $file
+ query="/ei-producer/v1/eiproducers/$2"
+ res="$(__do_curl_to_api ECS PUT $query $file)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
+# args: <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)
+# (Function for test scripts)
+ecs_api_edp_get_producer_jobs() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ #Valid number of parameter 2,3,6,10
+ paramError=1
+ if [ $# -eq 2 ]; then
+ paramError=0
+ fi
+ if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
+ paramError=0
+ fi
+ variablecount=$(($#-2))
+ if [ $# -gt 3 ] && [ $(($variablecount%4)) -eq 0 ]; then
+ paramError=0
+ fi
+ if [ $paramError -eq 1 ]; then
+ __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)" $@
+ return 1
+ fi
+
+ query="/ei-producer/v1/eiproducers/$2/eijobs"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ if [ $# -gt 2 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $# -gt 3 ]; then
+ arr=(${@:3})
+ for ((i=0; i<$(($#-3)); i=i+4)); do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ if [ -f ${arr[$i+3]} ]; then
+ jobfile=$(cat ${arr[$i+3]})
+ jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
+ else
+ echo -e $RED" FAIL. Job template file "${arr[$i+3]}", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"ei_job_data\":$jobfile}"
+ done
+ fi
+ targetJson=$targetJson"]"
+
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
+
+
+##########################################
+#### Service status ####
+##########################################
+# Function prefix: ecs_api_service
+
+# API Test function: GET ​/status
+# args: <response-code>
+# (Function for test scripts)
+ecs_api_service_status() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ ((RES_TEST++))
+
+ if [ $# -lt 1 ]; then
+ __print_err "<response-code> [<producer-id>]*|NOID" $@
+ return 1
+ fi
+
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ return 0
+}
\ No newline at end of file
diff --git a/test/common/prodstub_api_functions.sh b/test/common/prodstub_api_functions.sh
new file mode 100644
index 0000000..b41c79b
--- /dev/null
+++ b/test/common/prodstub_api_functions.sh
@@ -0,0 +1,210 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+
+### Admin API functions producer stub
+
+
+# Excute a curl cmd towards the prodstub simulator and check the response code.
+# args: TEST|CONF <expected-response-code> <curl-cmd-string> [<json-file-to-compare-output>]
+__execute_curl_to_prodstub() {
+ #echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
+ echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+ echo " CMD: $3" >> $HTTPLOG
+ res="$($3)"
+ echo " RESP: $res" >> $HTTPLOG
+ retcode=$?
+ if [ $retcode -ne 0 ]; then
+ echo " RETCODE: "$retcode
+ echo -e $RED" FAIL - fatal error when executing curl."$ERED
+ return 1
+ fi
+ status=${res:${#res}-3}
+ if [ $status -eq $2 ]; then
+ if [ $# -eq 4 ]; then
+ body=${res:0:${#res}-3}
+ jobfile=$(cat $4)
+ echo " TARGET JSON: $jobfile" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$jobfile" "$body")
+ if [ $res -ne 0 ]; then
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ return 1
+ fi
+ fi
+ if [ $1 == "TEST" ]; then
+ echo -e $GREEN" PASS"$EGREEN
+ else
+ echo -e $GREEN" OK"$EGREEN
+ fi
+ return 0
+ fi
+ echo -e $RED" FAIL - expected http response: "$2" but got http response: "$status $ERED
+ return 1
+}
+
+# Prodstub API: Set (or reset) response code for producer supervision
+# <response-code> <producer-id> [<forced_response_code>]
+# (Function for test scripts)
+prodstub_arm_supervision() {
+ echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+ echo "CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ >> $HTTPLOG
+ if [ $# -ne 2 ] && [ $# -ne 3 ]; then
+ ((RES_CONF_FAIL++))
+ __print_err "<response-code> <producer-id> [<forced_response_code>]" $@
+ return 1
+ fi
+
+ curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/supervision/"$2
+ if [ $# -eq 3 ]; then
+ curlString=$curlString"?response="$3
+ fi
+
+ __execute_curl_to_prodstub CONF $1 "$curlString"
+ retcode=$?
+ if [ $? -ne 0 ]; then
+ ((RES_CONF_FAIL++))
+ fi
+ return $retcode
+}
+
+# Prodstub API: Set (or reset) response code job create
+# <response-code> <producer-id> <job-id> [<forced_response_code>]
+# (Function for test scripts)
+prodstub_arm_create() {
+ echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+ echo "CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ >> $HTTPLOG
+ if [ $# -ne 3 ] && [ $# -ne 4 ]; then
+ ((RES_CONF_FAIL++))
+ __print_err "<response-code> <producer-id> <job-id> [<forced_response_code>]" $@
+ return 1
+ fi
+
+ curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/create/$2/$3"
+ if [ $# -eq 4 ]; then
+ curlString=$curlString"?response="$4
+ fi
+
+ __execute_curl_to_prodstub CONF $1 "$curlString"
+ retcode=$?
+ if [ $? -ne 0 ]; then
+ ((RES_CONF_FAIL++))
+ fi
+ return $retcode
+}
+
+# Prodstub API: Set (or reset) response code job delete
+# <response-code> <producer-id> <job-id> [<forced_response_code>]
+# (Function for test scripts)
+prodstub_arm_delete() {
+ echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+ echo "CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ >> $HTTPLOG
+ if [ $# -ne 3 ] && [ $# -ne 4 ]; then
+ ((RES_CONF_FAIL++))
+ __print_err "<response-code> <producer-id> <job-id> [<forced_response_code>]" $@
+ return 1
+ fi
+
+ curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/delete/$2/$3"
+ if [ $# -eq 4 ]; then
+ curlString=$curlString"?response="$4
+ fi
+
+ __execute_curl_to_prodstub CONF $1 "$curlString"
+ retcode=$?
+ if [ $? -ne 0 ]; then
+ ((RES_CONF_FAIL++))
+ fi
+ return $retcode
+}
+
+# Prodstub API: Arm a type of a producer
+# <response-code> <producer-id> <type-id>
+# (Function for test scripts)
+prodstub_arm_type() {
+ echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+ echo "CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ >> $HTTPLOG
+ if [ $# -ne 3 ]; then
+ ((RES_CONF_FAIL++))
+ __print_err "<response-code> <producer-id> <type-id>" $@
+ return 1
+ fi
+
+ curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/type/$2/$3"
+
+ __execute_curl_to_prodstub CONF $1 "$curlString"
+ retcode=$?
+ if [ $? -ne 0 ]; then
+ ((RES_CONF_FAIL++))
+ fi
+ return $retcode
+}
+
+# Prodstub API: Disarm a type in a producer
+# <response-code> <producer-id> <type-id>
+# (Function for test scripts)
+prodstub_disarm_type() {
+ echo -e $BOLD"CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+ echo "CONF(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ >> $HTTPLOG
+ if [ $# -ne 3 ]; then
+ ((RES_CONF_FAIL++))
+ __print_err "<response-code> <producer-id> <type-id>" $@
+ return 1
+ fi
+
+ curlString="curl -X DELETE -skw %{http_code} $PROD_STUB_LOCALHOST/arm/type/$2/$3"
+
+ __execute_curl_to_prodstub CONF $1 "$curlString"
+ retcode=$?
+ if [ $? -ne 0 ]; then
+ ((RES_CONF_FAIL++))
+ fi
+ return $retcode
+}
+
+# Prodstub API: Get job data for a job and compare with a target job json
+# <response-code> <producer-id> <job-id> <type-id> <target-url> <template-job-file>
+# (Function for test scripts)
+prodstub_check_jobdata() {
+ echo -e $BOLD"TEST(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ $EBOLD
+ echo "TEST(${BASH_LINENO[0]}): "${FUNCNAME[0]} $@ >> $HTTPLOG
+ if [ $# -ne 6 ]; then
+ ((RES_FAIL++))
+ __print_err "<response-code> <producer-id> <job-id> <type-id> <target-url> <template-job-file>" $@
+ return 1
+ fi
+ if [ -f $6 ]; then
+ jobfile=$(cat $6)
+ jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
+ else
+ echo -e $RED" FAIL. Template file "$6" for jobdata, does not exist"$ERED
+ return 1
+ fi
+ targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"ei_job_data\":$jobfile}"
+ file="./tmp/.p.json"
+ echo "$targetJson" > $file
+
+ curlString="curl -X GET -skw %{http_code} $PROD_STUB_LOCALHOST/jobdata/$2/$3"
+
+ __execute_curl_to_prodstub TEST $1 "$curlString" $file
+ retcode=$?
+ if [ $? -ne 0 ]; then
+ ((RES_FAIL++))
+ fi
+ return $retcode
+}
\ No newline at end of file
diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh
index f003559..67a398e 100644
--- a/test/common/ricsimulator_api_functions.sh
+++ b/test/common/ricsimulator_api_functions.sh
@@ -22,13 +22,10 @@
# Excute a curl cmd towards a ricsimulator and check the response code.
-# args: <expected-response-code> <curl-cmd-string> [<file>]
+# args: <expected-response-code> <curl-cmd-string>
__execute_curl_to_sim() {
echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
echo " CMD: $2" >> $HTTPLOG
- if [ $# -eq 3 ]; then
- echo " FILE: $(<$3)" >> $HTTPLOG
- fi
res="$($2)"
echo " RESP: $res" >> $HTTPLOG
retcode=$?
@@ -118,7 +115,7 @@
curlString="curl -X PUT -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4
- __execute_curl_to_sim $1 "$curlString" $4
+ __execute_curl_to_sim $1 "$curlString"
return $?
}
diff --git a/test/common/test_env.sh b/test/common/test_env.sh
index 8417ece..ac5cfa4 100755
--- a/test/common/test_env.sh
+++ b/test/common/test_env.sh
@@ -30,6 +30,12 @@
POLICY_AGENT_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent"
POLICY_AGENT_REMOTE_IMAGE_TAG="2.1.0"
+# Local ECS image and tag
+ECS_LOCAL_IMAGE="o-ran-sc/nonrtric-enrichment-coordinator-service"
+ECS_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT"
+# Remote ECS image and tag
+ECS_REMOTE_IMAGE="nexus3.o-ran-sc.org:10003/o-ran-sc/nonrtric-enrichment-coordinator-service"
+ECS_REMOTE_IMAGE_TAG="1.0.0-SNAPSHOT"
# Control Panel local image and tag
CONTROL_PANEL_LOCAL_IMAGE="o-ran-sc/nonrtric-controlpanel"
@@ -53,17 +59,6 @@
#No local image for DB, remote image always used
-# SDNC ONAP A1 Adapte remote image and tag
-SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE="nexus3.onap.org:10003/onap/sdnc-image"
-SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG="1.8-STAGING-latest"
-#No local image for the A1 adapter, remote image always used
-
-#ONAP A1 Adatper remote image and tag
-SDNC_ONAP_DB_REMOTE_IMAGE="mysql/mysql-server"
-SDNC_ONAP_DB_REMOTE_IMAGE_TAG="5.6"
-#No local image for DB, remote image always used
-
-
# Near RT RIC Simulator local image and tag
RIC_SIM_LOCAL_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator"
RIC_SIM_LOCAL_IMAGE_TAG="latest"
@@ -80,7 +75,6 @@
#CBS remote image and tag
CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app"
-CBS_REMOTE_IMAGE="onap/org.onap.dcaegen2.platform.configbinding.app-app"
CBS_REMOTE_IMAGE_TAG="2.3.0"
#No local image for CBS, remote image always used
@@ -95,6 +89,11 @@
CR_LOCAL_IMAGE_TAG="latest"
#No remote image for CR, local image always used
+#Producer stub image and tag
+PROD_STUB_LOCAL_IMAGE="producer-stub"
+PROD_STUB_LOCAL_IMAGE_TAG="latest"
+#No remote image for producer stub, local image always used
+
# Common env var for auto-test. Vars used by docker-compose need to be exported
export DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network
@@ -107,6 +106,15 @@
POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container
export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel
+export ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container)
+export ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container)
+export ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container)
+export ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container)
+
+export ECS_APP_NAME="ecs" # Name for ECS container
+ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container
+export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel
+
export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container)
export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container)
export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container)
@@ -121,6 +129,12 @@
export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container)
export CR_APP_NAME="callback-receiver" # Name for the Callback receiver
+export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container)
+export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container)
+export PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container)
+export PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container)
+export PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub
+
export CONSUL_HOST="consul-server" # Host name of consul
export CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container)
export CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container)
@@ -153,30 +167,23 @@
SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check)
SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log
-export SDNC_ONAP_APP_NAME="a1-adapter" # Name of the ONAP A1 Adapter container
-export SDNC_ONAP_EXTERNAL_PORT=8282 # ONAP A1 Adapter container external port (host -> container)
-export SDNC_ONAP_INTERNAL_PORT=8181 # ONAP A1 Adapter container internal port (container -> container)
-export SDNC_ONAP_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Adapter container external securee port (host -> container)
-export SDNC_ONAP_INTERNAL_SECURE_PORT=8343 # SNDC A1 Adapter container internal secure port (container -> container)
-export SDNC_ONAP_DB_APP_NAME="sdnc-onap-db" # Name of the ONAP A1 Adapter DB container
-SDNC_ONAP_USER="admin" # ONAP A1 Adapter username
-SDNC_ONAP_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # ONAP A1 Adapter PWD
-SDNC_ONAP_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for ONAP A1 Adapter API
-SDNC_ONAP_ALIVE_URL="/apidoc/explorer/" # Base url path for ONAP A1 Adapter API docs (for alive check)
-SDNC_ONAP_PROPERTIES_FILE="/opt/onap/ccsdk/data/properties/a1-adapter-api-dg.properties"
-SDNC_ONAP_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log
-
export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container
export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container)
export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container)
CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container
UUID="" # UUID used as prefix to the policy id to simulate a real UUID
- # Testscript need to set the UUID to use other this empty prefix is used
+ # Testscript need to set the UUID otherwise this empty prefix is used
RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface
RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface
DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http
DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https
ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP)
- # The values of this var is swiched between the two base url when needed
\ No newline at end of file
+ # The values of this var is swiched between the four base url when needed
+ECS_RESTBASE="http://localhost:"$ECS_EXTERNAL_PORT # Base url to the ECS NB REST interface
+ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to the secure ECS NB REST interface
+ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http
+ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https
+ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP)
+ # The values of this var is swiched between the four base url when needed
\ No newline at end of file
diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh
index 39a593c..ed02c7b 100755
--- a/test/common/testcase_common.sh
+++ b/test/common/testcase_common.sh
@@ -21,6 +21,14 @@
# Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [ --env-file <environment-filename> ] [--use-local-image <app-nam> [<app-name>]*]
+# Create a test case id, ATC (Auto Test Case), from the name of the test case script.
+# FTC1.sh -> ATC == FTC1
+ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh)
+
+#Create result file (containing '1' for error) for this test case
+#Will be replaced with a file containing '0' if all test cases pass
+echo "1" > "$PWD/.result$ATC.txt"
+
#Formatting for 'echo' cmd
BOLD="\033[1m"
EBOLD="\033[0m"
@@ -60,7 +68,10 @@
#Localhost constant
LOCALHOST="http://localhost:"
-# Make curl retries for http response codes set in this env var, space separated list of codes
+# Make curl retries towards ECS for http response codes set in this env var, space separated list of codes
+ECS_RETRY_CODES=""
+
+# Make curl retries towards the agent for http response codes set in this env var, space separated list of codes
AGENT_RETRY_CODES=""
# Var to contol if the agent runs in a container (normal = 0) or as application on the local machine ( = 1)
@@ -73,11 +84,17 @@
USE_LOCAL_IMAGES=""
# List of available apps to override with local image
-AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA CP SDNC RICSIM"
+AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA ECS CP SDNC RICSIM"
# Use this var (STOP_AT_ERROR=1 in the test script) for debugging/trouble shooting to take all logs and exit at first FAIL test case
STOP_AT_ERROR=0
+# Function to indent cmd output with one space
+indent1() { sed 's/^/ /'; }
+
+# Function to indent cmd output with two spaces
+indent2() { sed 's/^/ /'; }
+
# Set a description string for the test case
if [ -z "$TC_ONELINE_DESCR" ]; then
TC_ONELINE_DESCR="<no-description>"
@@ -91,24 +108,22 @@
echo $tmpval > .tmp_tcsuite_ctr
fi
-# Create a test case id, ATC (Auto Test Case), from the name of the test case script.
-# FTC1.sh -> ATC == FTC1
-ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh)
-
# Create the logs dir if not already created in the current dir
if [ ! -d "logs" ]; then
mkdir logs
fi
TESTLOGS=$PWD/logs
+# Create the tmp dir for temporary files that is not needed after the test
+# hidden files for the test env is still stored in the current dir
+if [ ! -d "tmp" ]; then
+ mkdir tmp
+fi
+
# Create a http message log for this testcase
HTTPLOG=$PWD"/.httplog_"$ATC".txt"
echo "" > $HTTPLOG
-#Create result file (containing '1' for error) for this test case
-#Will be replaced with a file containing '0' if script is ok
-
-echo "1" > "$PWD/.result$ATC.txt"
# Create a log dir for the test case
mkdir -p $TESTLOGS/$ATC
@@ -243,7 +258,7 @@
echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD
. $TEST_ENV_VAR_FILE
else
- echo -e $RED"Selected env var fle does not exist: "$TEST_ENV_VAR_FILE$ERED
+ echo -e $RED"Selected env var file does not exist: "$TEST_ENV_VAR_FILE$ERED
exit 1
fi
@@ -269,6 +284,11 @@
export CR_PORT=$CR_INTERNAL_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
+export PROD_STUB_HTTPX="http"
+export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
+export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_PORT #When CR is running outside the docker net
+export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
+
export SDNC_HTTPX="http"
export SDNC_PORT=$SDNC_INTERNAL_PORT
export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net
@@ -278,17 +298,23 @@
#Temp var to check for image variable name errors
IMAGE_ERR=0
#Create a file with image info for later printing as a table
-image_list_file=".image-list"
+image_list_file="./tmp/.image-list"
echo -e " Container\tImage\ttag" > $image_list_file
# Check if image env var is set and if so export the env var with image to use (used by docker compose files)
-# arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name>
+# arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name> <app-short-name>
__check_image_var() {
- if [ $# -ne 5 ]; then
- echo "Expected arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name>"
+ if [ $# -ne 6 ]; then
+ echo "Expected arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name> <app-short-name>"
((IMAGE_ERR++))
return
fi
+ __check_included_image $6
+ if [ $? -ne 0 ]; then
+ echo -e "$1\t<image-excluded>\t<no-tag>" >> $image_list_file
+ # Image is excluded since the corresponding app is not used in this test
+ return
+ fi
tmp=${1}"\t"
#Create var from the input var names
image="${!4}"
@@ -319,6 +345,7 @@
#Check if app local image shall override remote image
+# Possible IDs for local image override: PA, CP, SDNC, RICSIM, ECS
__check_image_local_override() {
for im in $USE_LOCAL_IMAGES; do
if [ "$1" == "$im" ]; then
@@ -328,14 +355,16 @@
return 0
}
-#Check if app uses image excluded from this test run
-__check_excluded_image() {
- for im in $EXCLUDED_IMAGES; do
+# Check if app uses image included in this test run
+# Returns 0 if image is included, 1 if not
+# Possible IDs for image inclusion: CBS, CONSUL, CP, CR, ECS, MR, PA, PRODSTUB, RICSIM, SDNC
+__check_included_image() {
+ for im in $INCLUDED_IMAGES; do
if [ "$1" == "$im" ]; then
- return 1
+ return 0
fi
done
- return 0
+ return 1
}
# Check that image env setting are available
@@ -344,53 +373,62 @@
if [ $START_ARG == "local" ]; then
#Local agent image
- __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
+ __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG" PA
#Local Control Panel image
- __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG"
+ __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG" CP
#Local SNDC image
- __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG"
+ __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG" SDNC
#Local ric sim image
- __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
+ __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG" RICSIM
elif [ $START_ARG == "remote" ] || [ $START_ARG == "remote-remove" ]; then
__check_image_local_override 'PA'
if [ $? -eq 0 ]; then
#Remote agent image
- __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_REMOTE_IMAGE" "POLICY_AGENT_REMOTE_IMAGE_TAG"
+ __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_REMOTE_IMAGE" "POLICY_AGENT_REMOTE_IMAGE_TAG" PA
else
#Local agent image
- __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
+ __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG" PA
fi
__check_image_local_override 'CP'
if [ $? -eq 0 ]; then
#Remote Control Panel image
- __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE_TAG"
+ __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE_TAG" CP
else
#Local Control Panel image
- __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG"
+ __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG" CP
fi
__check_image_local_override 'SDNC'
if [ $? -eq 0 ]; then
#Remote SDNC image
- __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG"
+ __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG" SDNC
else
#Local SNDC image
- __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG"
+ __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG" SDNC
fi
__check_image_local_override 'RICSIM'
if [ $? -eq 0 ]; then
#Remote ric sim image
- __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_REMOTE_IMAGE" "RIC_SIM_REMOTE_IMAGE_TAG"
+ __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_REMOTE_IMAGE" "RIC_SIM_REMOTE_IMAGE_TAG" RICSIM
else
#Local ric sim image
- __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
+ __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG" RICSIM
+ fi
+
+ __check_image_local_override 'ECS'
+ if [ $? -eq 0 ]; then
+ #Remote ecs image
+ __check_image_var " ECS" $START_ARG "ECS_IMAGE" "ECS_REMOTE_IMAGE" "ECS_REMOTE_IMAGE_TAG" ECS
+ else
+ #Local ecs image
+ __check_image_var " ECS" $START_ARG "ECS_IMAGE" "ECS_LOCAL_IMAGE" "ECS_LOCAL_IMAGE_TAG" ECS
fi
else
@@ -401,16 +439,12 @@
# These images are not built as part of this project official images, just check that env vars are set correctly
-__check_image_var " Message Router" $START_ARG "MRSTUB_IMAGE" "MRSTUB_LOCAL_IMAGE" "MRSTUB_LOCAL_IMAGE_TAG"
-__check_image_var " Callback Receiver" $START_ARG "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_IMAGE_TAG"
-__check_image_var " Consul" $START_ARG "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG"
-__check_image_var " CBS" $START_ARG "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG"
-__check_image_var " SDNC DB" $START_ARG "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG"
-__check_excluded_image 'SDNC_ONAP'
-if [ $? -eq 0 ]; then
- __check_image_var " SDNC ONAP A1 Adapter" $START_ARG "SDNC_ONAP_A1_ADAPTER_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG"
- __check_image_var " SDNC ONAP DB" $START_ARG "SDNC_ONAP_DB_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE_TAG"
-fi
+__check_image_var " Message Router" $START_ARG "MRSTUB_IMAGE" "MRSTUB_LOCAL_IMAGE" "MRSTUB_LOCAL_IMAGE_TAG" MR
+__check_image_var " Callback Receiver" $START_ARG "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_IMAGE_TAG" CR
+__check_image_var " Producer stub" $START_ARG "PROD_STUB_IMAGE" "PROD_STUB_LOCAL_IMAGE" "PROD_STUB_LOCAL_IMAGE_TAG" PRODSTUB
+__check_image_var " Consul" $START_ARG "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG" CONSUL
+__check_image_var " CBS" $START_ARG "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG" CBS
+__check_image_var " SDNC DB" $START_ARG "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG" SDNC #Uses sdnc app name
#Errors in image setting - exit
if [ $IMAGE_ERR -ne 0 ]; then
@@ -468,24 +502,24 @@
echo -ne " Attempt to stop and remove container(s), if running - ${SAMELINE}"
tmp="$(docker ps -aq --filter name=${3})"
if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
- docker stop $tmp &> .dockererr
+ docker stop $tmp &> ./tmp/.dockererr
if [ $? -ne 0 ]; then
((IMAGE_ERR++))
echo ""
echo -e $RED" Container(s) could not be stopped - try manual stopping the container(s)"$ERED
- cat .dockererr
+ cat ./tmp/.dockererr
return 1
fi
fi
echo -ne " Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"${SAMELINE}"
tmp="$(docker ps -aq --filter name=${3})" &> /dev/null
if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
- docker rm $tmp &> .dockererr
+ docker rm $tmp &> ./tmp/.dockererr
if [ $? -ne 0 ]; then
((IMAGE_ERR++))
echo ""
echo -e $RED" Container(s) could not be removed - try manual removal of the container(s)"$ERED
- cat .dockererr
+ cat ./tmp/.dockererr
return 1
fi
fi
@@ -493,12 +527,12 @@
echo -ne " Removing image - ${SAMELINE}"
tmp="$(docker images -q ${4})" &> /dev/null
if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
- docker rmi $4 &> .dockererr
+ docker rmi --force $4 &> ./tmp/.dockererr
if [ $? -ne 0 ]; then
((IMAGE_ERR++))
echo ""
echo -e $RED" Image could not be removed - try manual removal of the image"$ERED
- cat .dockererr
+ cat ./tmp/.dockererr
return 1
fi
echo -e " Removing image - "$GREEN"removed"$EGREEN
@@ -509,13 +543,13 @@
fi
if [ -z "$tmp_im" ]; then
echo -ne " Pulling image${SAMELINE}"
- docker pull $4 &> .dockererr
+ docker pull $4 &> ./tmp/.dockererr
tmp_im=$(docker images ${4} | grep -v REPOSITORY)
if [ -z "$tmp_im" ]; then
echo ""
echo -e " Pulling image -$RED could not be pulled"$ERED
((IMAGE_ERR++))
- cat .dockererr
+ cat ./tmp/.dockererr
return 1
fi
echo -e " Pulling image -$GREEN Pulled $EGREEN"
@@ -529,30 +563,70 @@
echo -e $BOLD"Pulling configured images, if needed"$EBOLD
-START_ARG_MOD=$START_ARG
-__check_image_local_override 'PA'
-if [ $? -eq 1 ]; then
- START_ARG_MOD="local"
+__check_included_image 'PA'
+if [ $? -eq 0 ]; then
+ START_ARG_MOD=$START_ARG
+ __check_image_local_override 'PA'
+ if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+ fi
+ app="Policy Agent"; __check_and_pull_image $START_ARG_MOD "$app" $POLICY_AGENT_APP_NAME $POLICY_AGENT_IMAGE
+else
+ echo -e $YELLOW" Excluding PA image from image check/pull"$EYELLOW
fi
-app="Policy Agent"; __check_and_pull_image $START_ARG_MOD "$app" $POLICY_AGENT_APP_NAME $POLICY_AGENT_IMAGE
-START_ARG_MOD=$START_ARG
-__check_image_local_override 'CP'
-if [ $? -eq 1 ]; then
- START_ARG_MOD="local"
+__check_included_image 'ECS'
+if [ $? -eq 0 ]; then
+ START_ARG_MOD=$START_ARG
+ __check_image_local_override 'ECS'
+ if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+ fi
+ app="ECS"; __check_and_pull_image $START_ARG_MOD "$app" $ECS_APP_NAME $ECS_IMAGE
+else
+ echo -e $YELLOW" Excluding ECS image from image check/pull"$EYELLOW
fi
-app="Non-RT RIC Control Panel"; __check_and_pull_image $START_ARG_MOD "$app" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_IMAGE
-START_ARG_MOD=$START_ARG
-__check_image_local_override 'RICSIM'
-if [ $? -eq 1 ]; then
- START_ARG_MOD="local"
+__check_included_image 'CP'
+if [ $? -eq 0 ]; then
+ START_ARG_MOD=$START_ARG
+ __check_image_local_override 'CP'
+ if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+ fi
+ app="Non-RT RIC Control Panel"; __check_and_pull_image $START_ARG_MOD "$app" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_IMAGE
+else
+ echo -e $YELLOW" Excluding Non-RT RIC Control Panel image from image check/pull"$EYELLOW
fi
-app="Near-RT RIC Simulator"; __check_and_pull_image $START_ARG_MOD "$app" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE $RIC_SIM_IMAGE
-app="Consul"; __check_and_pull_image $START_ARG "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
-app="CBS"; __check_and_pull_image $START_ARG "$app" $CBS_APP_NAME $CBS_IMAGE
-__check_excluded_image 'SDNC'
+__check_included_image 'RICSIM'
+if [ $? -eq 0 ]; then
+ START_ARG_MOD=$START_ARG
+ __check_image_local_override 'RICSIM'
+ if [ $? -eq 1 ]; then
+ START_ARG_MOD="local"
+ fi
+ app="Near-RT RIC Simulator"; __check_and_pull_image $START_ARG_MOD "$app" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE $RIC_SIM_IMAGE
+else
+ echo -e $YELLOW" Excluding Near-RT RIC Simulator image from image check/pull"$EYELLOW
+fi
+
+
+__check_included_image 'CONSUL'
+if [ $? -eq 0 ]; then
+ app="Consul"; __check_and_pull_image $START_ARG "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
+else
+ echo -e $YELLOW" Excluding Consul image from image check/pull"$EYELLOW
+fi
+
+__check_included_image 'CBS'
+if [ $? -eq 0 ]; then
+ app="CBS"; __check_and_pull_image $START_ARG "$app" $CBS_APP_NAME $CBS_IMAGE
+else
+ echo -e $YELLOW" Excluding CBS image from image check/pull"$EYELLOW
+fi
+
+__check_included_image 'SDNC'
if [ $? -eq 0 ]; then
START_ARG_MOD=$START_ARG
__check_image_local_override 'SDNC'
@@ -564,16 +638,6 @@
else
echo -e $YELLOW" Excluding SDNC image and related DB image from image check/pull"$EYELLOW
fi
-__check_excluded_image 'SDNC_ONAP'
-if [ $? -eq 0 ]; then
- app="SDNC ONAP A1 Adapter"; __check_and_pull_image $START_ARG "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE
- app="SDNC ONAP DB"; __check_and_pull_image $START_ARG "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE
-else
- echo -e $YELLOW" Excluding ONAP SDNC image and related DB image from image check/pull"$EYELLOW
-fi
-# MR stub image not checked, will be built by this script - only local image
-# CR stub image not checked, will be built by this script - only local image
-
#Errors in image setting - exit
if [ $IMAGE_ERR -ne 0 ]; then
@@ -591,56 +655,107 @@
echo -e $BOLD"Building images needed for test"$EBOLD
curdir=$PWD
-cd $curdir
-cd ../mrstub
-echo " Building mrstub image: mrstub:latest"
-docker build -t mrstub . &> .dockererr
+__check_included_image 'MR'
if [ $? -eq 0 ]; then
- echo -e $GREEN" Build Ok"$EGREEN
+ cd $curdir
+ cd ../mrstub
+ echo " Building mrstub image: $MRSTUB_LOCAL_IMAGE:$MRSTUB_LOCAL_IMAGE_TAG"
+ docker build -t $MRSTUB_LOCAL_IMAGE . &> .dockererr
+ if [ $? -eq 0 ]; then
+ echo -e $GREEN" Build Ok"$EGREEN
+ else
+ echo -e $RED" Build Failed"$ERED
+ ((RES_CONF_FAIL++))
+ cat .dockererr
+ fi
+ cd $curdir
else
- echo -e $RED" Build Failed"$ERED
- ((RES_CONF_FAIL++))
- cat .dockererr
+ echo -e $YELLOW" Excluding mrstub from image build"$EYELLOW
fi
-cd $curdir
-cd ../cr
-echo " Building Callback Receiver image: callback-receiver:latest"
-docker build -t callback-receiver . &> .dockererr
+__check_included_image 'CR'
if [ $? -eq 0 ]; then
- echo -e $GREEN" Build Ok"$EGREEN
+ cd ../cr
+ echo " Building Callback Receiver image: $CR_LOCAL_IMAGE:$CR_IMAGE_TAG"
+ docker build -t $CR_LOCAL_IMAGE . &> .dockererr
+ if [ $? -eq 0 ]; then
+ echo -e $GREEN" Build Ok"$EGREEN
+ else
+ echo -e $RED" Build Failed"$ERED
+ ((RES_CONF_FAIL++))
+ cat .dockererr
+ fi
+ cd $curdir
else
- echo -e $RED" Build Failed"$ERED
- ((RES_CONF_FAIL++))
- cat .dockererr
+ echo -e $YELLOW" Excluding Callback Receiver from image build"$EYELLOW
fi
-cd $curdir
+
+__check_included_image 'PRODSTUB'
+if [ $? -eq 0 ]; then
+ cd ../prodstub
+ echo " Building Producer stub image: $PROD_STUB_LOCAL_IMAGE:$PROD_STUB_LOCAL_IMAGE_TAG"
+ docker build -t $PROD_STUB_LOCAL_IMAGE . &> .dockererr
+ if [ $? -eq 0 ]; then
+ echo -e $GREEN" Build Ok"$EGREEN
+ else
+ echo -e $RED" Build Failed"$ERED
+ ((RES_CONF_FAIL++))
+ cat .dockererr
+ fi
+ cd $curdir
+else
+ echo -e $YELLOW" Excluding Producer stub from image build"$EYELLOW
+fi
echo ""
# Create a table of the images used in the script
echo -e $BOLD"Local docker registry images used in the this test script"$EBOLD
-docker_tmp_file=.docker-images-table
-format_string="{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}"
-echo -e " Application\tRepository\tTag\tCreated Since\tSize" > $docker_tmp_file
-echo -e " Policy Agent\t$(docker images --format $format_string $POLICY_AGENT_IMAGE)" >> $docker_tmp_file
-echo -e " Control Panel\t$(docker images --format $format_string $CONTROL_PANEL_IMAGE)" >> $docker_tmp_file
-echo -e " RIC Simulator\t$(docker images --format $format_string $RIC_SIM_IMAGE)" >> $docker_tmp_file
-echo -e " Message Router\t$(docker images --format $format_string $MRSTUB_IMAGE)" >> $docker_tmp_file
-echo -e " Callback Receiver\t$(docker images --format $format_string $CR_IMAGE)" >> $docker_tmp_file
-echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >> $docker_tmp_file
-echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >> $docker_tmp_file
-__check_excluded_image 'SDNC'
+docker_tmp_file=./tmp/.docker-images-table
+format_string="{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}\\t{{.CreatedAt}}"
+echo -e " Application\tRepository\tTag\tCreated since\tSize\tCreated at" > $docker_tmp_file
+__check_included_image 'PA'
+if [ $? -eq 0 ]; then
+ echo -e " Policy Agent\t$(docker images --format $format_string $POLICY_AGENT_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'ECS'
+if [ $? -eq 0 ]; then
+ echo -e " ECS\t$(docker images --format $format_string $ECS_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'CP'
+if [ $? -eq 0 ]; then
+ echo -e " Control Panel\t$(docker images --format $format_string $CONTROL_PANEL_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'RICSIM'
+if [ $? -eq 0 ]; then
+ echo -e " RIC Simulator\t$(docker images --format $format_string $RIC_SIM_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'MR'
+if [ $? -eq 0 ]; then
+ echo -e " Message Router\t$(docker images --format $format_string $MRSTUB_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'CR'
+if [ $? -eq 0 ]; then
+ echo -e " Callback Receiver\t$(docker images --format $format_string $CR_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'PRODSTUB'
+if [ $? -eq 0 ]; then
+ echo -e " Produccer stub\t$(docker images --format $format_string $PROD_STUB_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'CONSUL'
+if [ $? -eq 0 ]; then
+ echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'CBS'
+if [ $? -eq 0 ]; then
+ echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >> $docker_tmp_file
+fi
+__check_included_image 'SDNC'
if [ $? -eq 0 ]; then
echo -e " SDNC A1 Controller\t$(docker images --format $format_string $SDNC_A1_CONTROLLER_IMAGE)" >> $docker_tmp_file
echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >> $docker_tmp_file
fi
-__check_excluded_image 'SDNC_ONAP'
-if [ $? -eq 0 ]; then
- echo -e " SDNC ONAP A1 Adapter\t$(docker images --format $format_string $SDNC_ONAP_A1_ADAPTER_IMAGE)" >> $docker_tmp_file
- echo -e " SDNC ONAP DB\t$(docker images --format $format_string $SDNC_ONAP_DB_IMAGE)" >> $docker_tmp_file
-fi
column -t -s $'\t' $docker_tmp_file
@@ -832,6 +947,15 @@
return 0
}
+# Check if app name var is set. If so return the app name otherwise return "NOTSET"
+__check_app_name() {
+ if [ $# -eq 1 ]; then
+ echo $1
+ else
+ echo "NOTSET"
+ fi
+}
+
# Stop and remove all containers
# args: -
# (Function for test scripts)
@@ -839,20 +963,21 @@
echo -e $BOLD"Stopping and removing all running containers, by container name"$EBOLD
- CONTAINTER_NAMES=("Policy Agent " $POLICY_AGENT_APP_NAME\
- "Non-RT RIC Simulator(s)" $RIC_SIM_PREFIX\
- "Message Router " $MR_APP_NAME\
- "Callback Receiver " $CR_APP_NAME\
- "Control Panel " $CONTROL_PANEL_APP_NAME\
- "SDNC A1 Controller " $SDNC_APP_NAME\
- "SDNC DB " $SDNC_DB_APP_NAME\
- "SDNC ONAP A1 Adapter " $SDNC_ONAP_APP_NAME\
- "SDNC DB " $SDNC_ONAP_DB_APP_NAME\
- "CBS " $CBS_APP_NAME\
- "Consul " $CONSUL_APP_NAME)
+ CONTAINTER_NAMES=("Policy Agent " $(__check_app_name $POLICY_AGENT_APP_NAME)\
+ "ECS " $(__check_app_name $ECS_APP_NAME)\
+ "Non-RT RIC Simulator(s)" $(__check_app_name $RIC_SIM_PREFIX)\
+ "Message Router " $(__check_app_name $MR_APP_NAME)\
+ "Callback Receiver " $(__check_app_name $CR_APP_NAME)\
+ "Producer stub " $(__check_app_name $PROD_STUB_APP_NAME)\
+ "Control Panel " $(__check_app_name $CONTROL_PANEL_APP_NAME)\
+ "SDNC A1 Controller " $(__check_app_name $SDNC_APP_NAME)\
+ "SDNC DB " $(__check_app_name $SDNC_DB_APP_NAME)\
+ "CBS " $(__check_app_name $CBS_APP_NAME)\
+ "Consul " $(__check_app_name $CONSUL_APP_NAME))
nw=0 # Calc max width of container name, to make a nice table
for (( i=1; i<${#CONTAINTER_NAMES[@]} ; i+=2 )) ; do
+
if [ ${#CONTAINTER_NAMES[i]} -gt $nw ]; then
nw=${#CONTAINTER_NAMES[i]}
fi
@@ -861,14 +986,16 @@
for (( i=0; i<${#CONTAINTER_NAMES[@]} ; i+=2 )) ; do
APP="${CONTAINTER_NAMES[i]}"
CONTR="${CONTAINTER_NAMES[i+1]}"
- for((w=${#CONTR}; w<$nw; w=w+1)); do
- CONTR="$CONTR "
- done
- echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}${SAMELINE}"
- docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null
- echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}${SAMELINE}"
- docker rm --force $(docker ps -qa --filter name=${CONTR}) &> /dev/null
- echo -e " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}"
+ if [ $CONTR != "NOTSET" ]; then
+ for((w=${#CONTR}; w<$nw; w=w+1)); do
+ CONTR="$CONTR "
+ done
+ echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}${SAMELINE}"
+ docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null
+ echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}${SAMELINE}"
+ docker rm --force $(docker ps -qa --filter name=${CONTR}) &> /dev/null
+ echo -e " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}"
+ fi
done
echo ""
@@ -876,21 +1003,25 @@
echo -e $BOLD" Removing docker network"$EBOLD
TMP=$(docker network ls -q --filter name=$DOCKER_SIM_NWNAME)
if [ "$TMP" == $DOCKER_SIM_NWNAME ]; then
- docker network rm $DOCKER_SIM_NWNAME
+ docker network rm $DOCKER_SIM_NWNAME | indent2
if [ $? -ne 0 ]; then
echo -e $RED" Cannot remove docker network. Manually remove or disconnect containers from $DOCKER_SIM_NWNAME"$ERED
exit 1
fi
fi
+ echo -e "$GREEN Done$EGREEN"
echo -e $BOLD" Removing all unused docker neworks"$EBOLD
- docker network prune --force #&> /dev/null
+ docker network prune --force | indent2
+ echo -e "$GREEN Done$EGREEN"
echo -e $BOLD" Removing all unused docker volumes"$EBOLD
- docker volume prune --force #&> /dev/null
+ docker volume prune --force | indent2
+ echo -e "$GREEN Done$EGREEN"
echo -e $BOLD" Removing all dangling/untagged docker images"$EBOLD
docker rmi --force $(docker images -q -f dangling=true) &> /dev/null
+ echo -e "$GREEN Done$EGREEN"
echo ""
CONTRS=$(docker ps | awk '$1 != "CONTAINER" { n++ }; END { print n+0 }')
@@ -969,11 +1100,13 @@
return 1
fi
if [ "$tmp" != $DOCKER_SIM_NWNAME ]; then
- echo -e "Creating docker network:$BOLD $DOCKER_SIM_NWNAME $EBOLD"
- docker network create $DOCKER_SIM_NWNAME
+ echo -e " Creating docker network:$BOLD $DOCKER_SIM_NWNAME $EBOLD"
+ docker network create $DOCKER_SIM_NWNAME | indent2
if [ $? -ne 0 ]; then
echo -e $RED" Could not create docker network $DOCKER_SIM_NWNAME"$ERED
return 1
+ else
+ echo -e "$GREEN Done$EGREEN"
fi
else
echo -e " Docker network $DOCKER_SIM_NWNAME already exists$GREEN OK $EGREEN"
@@ -1145,14 +1278,15 @@
echo " Loading config for "$POLICY_AGENT_APP_NAME" from "$1
- curl -s $LOCALHOST${CONSUL_EXTERNAL_PORT}/v1/kv/${POLICY_AGENT_APP_NAME}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$1 >/dev/null
+ curlString="$LOCALHOST${CONSUL_EXTERNAL_PORT}/v1/kv/${POLICY_AGENT_APP_NAME}?dc=dc1 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @"$1
+ result=$(__do_curl "$curlString")
if [ $? -ne 0 ]; then
echo -e $RED" FAIL - json config could not be loaded to consul" $ERED
((RES_CONF_FAIL++))
return 1
fi
body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
- echo $body > ".output"$1
+ echo $body > "./tmp/.output"$1
if [ $? -ne 0 ]; then
echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED
@@ -1177,7 +1311,7 @@
}
# Function to perpare the consul configuration according to the current simulator configuration
-# args: SDNC|SDNC_ONAP|NOSDNC <output-file>
+# args: SDNC|NOSDNC <output-file>
# (Function for test scripts)
prepare_consul_config() {
echo -e $BOLD"Prepare Consul config"$EBOLD
@@ -1186,19 +1320,17 @@
if [ $# != 2 ]; then
((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC <output-file>" $@
+ __print_err "need two args, SDNC|NOSDNC <output-file>" $@
exit 1
fi
if [ $1 == "SDNC" ]; then
echo -e " Config$BOLD including SDNC$EBOLD configuration"
- elif [ $1 == "SDNC_ONAP" ]; then
- echo -e " Config$BOLD including SDNC ONAP$EBOLD configuration"
elif [ $1 == "NOSDNC" ]; then
- echo -e " Config$BOLD excluding SDNC or SDNC ONAP$EBOLD configuration"
+ echo -e " Config$BOLD excluding SDNC$EBOLD configuration"
else
((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC <output-file>" $@
+ __print_err "need two args, SDNC|NOSDNC <output-file>" $@
exit 1
fi
@@ -1217,21 +1349,6 @@
config_json=$config_json"\n }"
config_json=$config_json"\n ],"
fi
- if [ $1 == "SDNC_ONAP" ]; then
- config_json=$config_json"\n \"controller\": ["
- config_json=$config_json"\n {"
- config_json=$config_json"\n \"name\": \"$SDNC_ONAP_APP_NAME\","
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"baseUrl\": \"http://$SDNC_ONAP_APP_NAME:$SDNC_ONAP_INTERNAL_PORT\","
- else
- config_json=$config_json"\n \"baseUrl\": \"http://localhost:$SDNC_ONAP_EXTERNAL_PORT\","
- fi
- config_json=$config_json"\n \"userName\": \"$SDNC_ONAP_USER\","
- config_json=$config_json"\n \"password\": \"$SDNC_ONAP_PWD\""
- config_json=$config_json"\n }"
- config_json=$config_json"\n ],"
- fi
-
config_json=$config_json"\n \"streams_publishes\": {"
config_json=$config_json"\n \"dmaap_publisher\": {"
@@ -1282,8 +1399,6 @@
fi
if [ $1 == "SDNC" ]; then
config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\","
- elif [ $1 == "SDNC_ONAP" ]; then
- config_json=$config_json"\n \"controller\": \"$SDNC_ONAP_APP_NAME\","
fi
config_json=$config_json"\n \"managedElementIds\": ["
config_json=$config_json"\n \"me1_$ric\","
@@ -1309,7 +1424,12 @@
start_consul_cbs() {
echo -e $BOLD"Starting Consul and CBS"$EBOLD
-
+ __check_included_image 'CONSUL'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Consul image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"Consul will not be started"$ERED
+ exit
+ fi
__start_container consul_cbs NODOCKERARGS "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" "http" \
"$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck" "http"
}
@@ -1319,7 +1439,7 @@
###########################
use_simulator_http() {
- echo -e "Using unsecure $BOLD http $EBOLD towards the simulators"
+ echo -e "Using $BOLD http $EBOLD towards the simulators"
export RIC_SIM_HTTPX="http"
export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
@@ -1327,7 +1447,7 @@
}
use_simulator_https() {
- echo -e "Using secure $BOLD https $EBOLD towards the simulators"
+ echo -e "Using $BOLD https $EBOLD towards the simulators"
export RIC_SIM_HTTPX="https"
export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT
@@ -1342,6 +1462,13 @@
echo -e $BOLD"Starting RIC Simulators"$EBOLD
+ __check_included_image 'RICSIM'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Near-RT RIC Simulator image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"The Near-RT RIC Simulartor(s) will not be started"$ERED
+ exit
+ fi
+
RIC1=$RIC_SIM_PREFIX"_g1"
RIC2=$RIC_SIM_PREFIX"_g2"
RIC3=$RIC_SIM_PREFIX"_g3"
@@ -1398,7 +1525,12 @@
start_control_panel() {
echo -e $BOLD"Starting Control Panel"$EBOLD
-
+ __check_included_image 'CP'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Control Panel image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"The Control Panel will not be started"$ERED
+ exit
+ fi
__start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/" "http"
}
@@ -1414,7 +1546,7 @@
echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
- __check_excluded_image 'SDNC'
+ __check_included_image 'SDNC'
if [ $? -eq 1 ]; then
echo -e $RED"The image for SDNC and the related DB has not been checked for this test run due to arg to the test script"$ERED
echo -e $RED"SDNC will not be started"$ERED
@@ -1426,7 +1558,7 @@
}
use_sdnc_http() {
- echo -e $BOLD"Using http between agent and SDNC"$EBOLD
+ echo -e "Using $BOLD http $EBOLD towards SDNC"
export SDNC_HTTPX="http"
export SDNC_PORT=$SDNC_INTERNAL_PORT
export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT
@@ -1434,69 +1566,13 @@
}
use_sdnc_https() {
- echo -e $BOLD"Using https between agent and SDNC"$EBOLD
+ echo -e "Using $BOLD https $EBOLD towards SDNC"
export SDNC_HTTPX="https"
export SDNC_PORT=$SDNC_INTERNAL_SECURE_PORT
export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_SECURE_PORT
echo ""
}
-#######################
-### SDNC ONAP functions
-#######################
-
-# Start the SDNC ONAP A1 Adapter
-# args: -
-# (Function for test scripts)
-start_sdnc_onap() {
-
- echo -e $BOLD"Starting SDNC ONAP A1 Adapter"$EBOLD
-
- __check_excluded_image 'SDNC_ONAP'
- if [ $? -eq 1 ]; then
- echo -e $RED"The image for SDNC ONAP and the related DB has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"SDNC ONAP will not be started"$ERED
- exit
- fi
-
- __start_container sdnc_onap NODOCKERARGS $SDNC_ONAP_APP_NAME $SDNC_ONAP_EXTERNAL_PORT $SDNC_ONAP_ALIVE_URL "http"
-
-}
-
-# Configure the SDNC ONAP A1 Adapter
-# args: -
-# (Function for test scripts)
-config_sdnc_onap() {
-
- echo -e $BOLD"Configuring SDNC ONAP A1 Adapter"$EBOLD
-
- LOCALFILE=".sdnc_onap.prop"
- REMOTEFILE="/tmp/.sdnc_onap.prop"
-
- docker cp $SDNC_ONAP_APP_NAME:$SDNC_ONAP_PROPERTIES_FILE $LOCALFILE
- if [ $? -ne 0 ]; then
- echo -e $RED"Could not copy $SDNC_ONAP_PROPERTIES_FILE from $SDNC_ONAP_APP_NAME container"$ERED
- exit 1
- fi
-
-
- #Config of the prop file shall be inserted here
-
- #Copy file to /tmp and then to final destination, a trick to get correct permission of the file.
-
- docker cp $LOCALFILE $SDNC_ONAP_APP_NAME:$REMOTEFILE
- if [ $? -ne 0 ]; then
- echo -e $RED"Could not copy local $LOCALFILE to $REMOTEFILE in $SDNC_ONAP_APP_NAME container"$ERED
- exit 1
- fi
-
- docker exec -it $SDNC_ONAP_APP_NAME cp $REMOTEFILE $SDNC_ONAP_PROPERTIES_FILE
- if [ $? -ne 0 ]; then
- echo -e $RED"Could not copy $REMOTEFILE to $SDNC_ONAP_PROPERTIES_FILE in $SDNC_ONAP_APP_NAME container"$ERED
- exit 1
- fi
-}
-
#####################
### MR stub functions
#####################
@@ -1507,12 +1583,18 @@
start_mr() {
echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD
+ __check_included_image 'MR'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Message Router image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"The Message Router will not be started"$ERED
+ exit
+ fi
export MR_CERT_MOUNT_DIR="./cert"
__start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" "http"
}
use_mr_http() {
- echo -e $BOLD"Using http between agent and MR"$EBOLD
+ echo -e "Using $BOLD http $EBOLD towards MR"
export MR_HTTPX="http"
export MR_PORT=$MR_INTERNAL_PORT
export MR_LOCAL_PORT=$MR_EXTERNAL_PORT
@@ -1520,7 +1602,7 @@
}
use_mr_https() {
- echo -e $BOLD"Using https between agent and MR"$EBOLD
+ echo -e "Using $BOLD https $EBOLD towards MR"
export MR_HTTPX="https"
export MR_PORT=$MR_INTERNAL_SECURE_PORT
export MR_LOCAL_PORT=$MR_EXTERNAL_SECURE_PORT
@@ -1538,13 +1620,18 @@
start_cr() {
echo -e $BOLD"Starting Callback Receiver"$EBOLD
-
+ __check_included_image 'CR'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Callback Receiver image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"The Callback Receiver will not be started"$ERED
+ exit
+ fi
__start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/" "http"
}
use_cr_http() {
- echo -e $BOLD"Using http between test script and CR"$EBOLD
+ echo -e "Using $BOLD http $EBOLD towards CR"
export CR_HTTPX="http"
export CR_PORT=$CR_INTERNAL_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_PORT
@@ -1552,7 +1639,7 @@
}
use_cr_https() {
- echo -e $BOLD"Using https between test script and CR"$EBOLD
+ echo -e "Using $BOLD https $EBOLD towards CR"
export CR_HTTPX="https"
export CR_PORT=$CR_INTERNAL_SECURE_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT
@@ -1560,6 +1647,44 @@
}
###########################
+### Producer stub functions
+###########################
+
+# Start the Producer stub in the simulator group
+# args: -
+# (Function for test scripts)
+start_prod_stub() {
+
+ echo -e $BOLD"Starting Producer stub"$EBOLD
+ __check_included_image 'PRODSTUB'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Producer stub image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"The Producer stub will not be started"$ERED
+ exit
+ fi
+ __start_container prodstub NODOCKERARGS $PROD_STUB_APP_NAME $PROD_STUB_EXTERNAL_PORT "/" "http"
+
+}
+
+use_prod_stub_http() {
+ echo -e "Using $BOLD http $EBOLD towards Producer stub"
+ export PROD_STUB_HTTPX="http"
+ export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
+ export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_PORT
+ export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
+ echo ""
+}
+
+use_prod_stub_https() {
+ echo -e "Using $BOLD https $EBOLD towards Producer stub"
+ export PROD_STUB_HTTPX="https"
+ export PROD_STUB_PORT=$PROD_STUB_INTERNAL_SECURE_PORT
+ export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_SECURE_PORT
+ export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
+ echo ""
+}
+
+###########################
### Policy Agents functions
###########################
@@ -1576,12 +1701,18 @@
echo -e $BOLD"Starting Policy Agent"$EBOLD
if [ $AGENT_STAND_ALONE -eq 0 ]; then
+ __check_included_image 'PA'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Policy Agent image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"The Policy Agent will not be started"$ERED
+ exit
+ fi
__start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http"
else
echo -e $RED"The consul config produced by this test script (filename '<fullpath-to-autotest-dir>.output<file-name>"$ERED
echo -e $RED"where the file name is the file in the consul_config_app command in this script) must be pointed out by the agent "$ERED
echo -e $RED"application.yaml"$ERED
- echo -e $RED"The application jar may need to be built beforefor continuing"$ERED
+ echo -e $RED"The application jar may need to be built before continuing"$ERED
echo -e $RED"The agent shall now be running on port $POLICY_AGENT_EXTERNAL_PORT for http"$ERED
read -p "<press any key to continue>"
@@ -1594,7 +1725,7 @@
# args: -
# (Function for test scripts)
use_agent_rest_http() {
- echo -e $BOLD"Using agent REST interface with http"$EBOLD
+ echo -e "Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards the agent"
export ADAPTER=$RESTBASE
echo ""
}
@@ -1603,7 +1734,7 @@
# args: -
# (Function for test scripts)
use_agent_rest_https() {
- echo -e $BOLD"Using agent REST interface with https"$EBOLD
+ echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
export ADAPTER=$RESTBASE_SECURE
echo ""
return 0
@@ -1613,7 +1744,7 @@
# args: -
# (Function for test scripts)
use_agent_dmaap_http() {
- echo -e $BOLD"Agent using DMAAP http interface"$EBOLD
+ echo -e "Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
export ADAPTER=$DMAAPBASE
echo ""
return 0
@@ -1623,7 +1754,7 @@
# args: -
# (Function for test scripts)
use_agent_dmaap_https() {
- echo -e $BOLD"Agent using DMAAP https interface"$EBOLD
+ echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
export ADAPTER=$DMAAPBASE_SECURE
echo ""
return 0
@@ -1634,9 +1765,11 @@
# (Function for test scripts)
set_agent_debug() {
echo -e $BOLD"Setting agent debug"$EBOLD
- curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H 'Content-Type: application/json' -d '{"configuredLevel":"debug"}' &> /dev/null
+ curlString="$LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
+ result=$(__do_curl "$curlString")
if [ $? -ne 0 ]; then
__print_err "could not set debug mode" $@
+ ((RES_CONF_FAIL++))
return 1
fi
echo ""
@@ -1648,9 +1781,11 @@
# (Function for test scripts)
set_agent_trace() {
echo -e $BOLD"Setting agent trace"$EBOLD
- curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H 'Content-Type: application/json' -d '{"configuredLevel":"trace"}' &> /dev/null
+ curlString="$LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
+ result=$(__do_curl "$curlString")
if [ $? -ne 0 ]; then
__print_err "could not set trace mode" $@
+ ((RES_CONF_FAIL++))
return 1
fi
echo ""
@@ -1667,6 +1802,107 @@
return
}
+###########################
+### ECS functions
+###########################
+
+# Start the ECS
+# args: -
+# (Function for test scripts)
+start_ecs() {
+
+ echo -e $BOLD"Starting ECS"$EBOLD
+ __check_included_image 'ECS'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The ECS image has not been checked for this test run due to arg to the test script"$ERED
+ echo -e $RED"ECS will not be started"$ERED
+ exit
+ fi
+ export ECS_CERT_MOUNT_DIR="./cert"
+ __start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
+}
+
+# All calls to ECS will be directed to the ECS REST interface from now on
+# args: -
+# (Function for test scripts)
+use_ecs_rest_http() {
+ echo -e "Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS"
+ export ECS_ADAPTER=$ECS_RESTBASE
+ echo ""
+}
+
+# All calls to ECS will be directed to the ECS REST interface from now on
+# args: -
+# (Function for test scripts)
+use_ecs_rest_https() {
+ echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
+ export ECS_ADAPTER=$ECS_RESTBASE_SECURE
+ echo ""
+ return 0
+}
+
+# All calls to ECS will be directed to the ECS dmaap interface over http from now on
+# args: -
+# (Function for test scripts)
+use_ecs_dmaap_http() {
+ echo -e "Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
+ export ECS_ADAPTER=$ECS_DMAAPBASE
+ echo ""
+ return 0
+}
+
+# All calls to ECS will be directed to the ECS dmaap interface over https from now on
+# args: -
+# (Function for test scripts)
+use_ecs_dmaap_https() {
+ echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
+ export ECS_ADAPTER=$ECS_DMAAPBASE_SECURE
+ echo ""
+ return 0
+}
+
+# Turn on debug level tracing in ECS
+# args: -
+# (Function for test scripts)
+set_ecs_debug() {
+ echo -e $BOLD"Setting ecs debug"$EBOLD
+ curlString="$LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
+ result=$(__do_curl "$curlString")
+ if [ $? -ne 0 ]; then
+ __print_err "Could not set debug mode" $@
+ ((RES_CONF_FAIL++))
+ return 1
+ fi
+ echo ""
+ return 0
+}
+
+# Turn on trace level tracing in ECS
+# args: -
+# (Function for test scripts)
+set_ecs_trace() {
+ echo -e $BOLD"Setting ecs trace"$EBOLD
+ curlString="$LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
+ result=$(__do_curl "$curlString")
+ if [ $? -ne 0 ]; then
+ __print_err "Could not set trace mode" $@
+ ((RES_CONF_FAIL++))
+ return 1
+ fi
+ echo ""
+ return 0
+}
+
+# Perform curl retries when making direct call to ECS for the specified http response codes
+# Speace separated list of http response codes
+# args: [<response-code>]*
+use_agent_retries() {
+ echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
+ ECS_AGENT_RETRY_CODES=$@
+ echo ""
+ return
+}
+
#################
### Log functions
#################
@@ -1676,17 +1912,28 @@
# (Function for test scripts)
check_policy_agent_logs() {
- __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH
+ __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH WARN ERR
+}
+
+check_ecs_logs() {
+ __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
}
check_control_panel_logs() {
- __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH
+ __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH WARN ERR
+}
+
+check_sdnc_logs() {
+ __check_container_logs "SDNC A1 Controller" $SDNC_APP_NAME $SDNC_KARAF_LOG WARN ERROR
}
__check_container_logs() {
dispname=$1
appname=$2
logpath=$3
+ warning=$4
+ error=$5
+
echo -e $BOLD"Checking $dispname container $appname log ($logpath) for WARNINGs and ERRORs"$EBOLD
#tmp=$(docker ps | grep $appname)
@@ -1695,7 +1942,7 @@
echo $dispname" is not running, no check made"
return
fi
- foundentries="$(docker exec -it $tmp grep WARN $logpath | wc -l)"
+ foundentries="$(docker exec -t $tmp grep $warning $logpath | wc -l)"
if [ $? -ne 0 ];then
echo " Problem to search $appname log $logpath"
else
@@ -1705,7 +1952,7 @@
echo -e " Found \033[1m"$foundentries"\033[0m WARN entries in $appname log $logpath"
fi
fi
- foundentries="$(docker exec -it $tmp grep ERR $logpath | wc -l)"
+ foundentries="$(docker exec -t $tmp grep $error $logpath | wc -l)"
if [ $? -ne 0 ];then
echo " Problem to search $appname log $logpath"
else
@@ -1728,47 +1975,87 @@
__print_err "need one arg, <file-prefix>" $@
exit 1
fi
- echo -e $BOLD"Storing all container logs, Policy Agent app log and consul config using prefix: "$1$EBOLD
+ echo -e $BOLD"Storing all container logs using prefix: "$1$EBOLD
docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&1
- docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1
- docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1
- docker logs $POLICY_AGENT_APP_NAME > $TESTLOGS/$ATC/$1_policy-agent.log 2>&1
- docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_control-panel.log 2>&1
- docker logs $MR_APP_NAME > $TESTLOGS/$ATC/$1_mr.log 2>&1
- docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
+
+ __check_included_image 'CONSUL'
+ if [ $? -eq 0 ]; then
+ docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1
+ fi
+
+ __check_included_image 'CBS'
+ if [ $? -eq 0 ]; then
+ docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1
+ body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
+ echo "$body" > $TESTLOGS/$ATC/$1_consul_config.json 2>&1
+ fi
+
+ __check_included_image 'PA'
+ if [ $? -eq 0 ]; then
+ docker logs $POLICY_AGENT_APP_NAME > $TESTLOGS/$ATC/$1_policy-agent.log 2>&1
+ fi
+
+ __check_included_image 'ECS'
+ if [ $? -eq 0 ]; then
+ docker logs $ECS_APP_NAME > $TESTLOGS/$ATC/$1_ecs.log 2>&1
+ fi
+
+ __check_included_image 'CP'
+ if [ $? -eq 0 ]; then
+ docker logs $CONTROL_PANEL_APP_NAME > $TESTLOGS/$ATC/$1_control-panel.log 2>&1
+ fi
+
+ __check_included_image 'MR'
+ if [ $? -eq 0 ]; then
+ docker logs $MR_APP_NAME > $TESTLOGS/$ATC/$1_mr.log 2>&1
+ fi
+
+ __check_included_image 'CR'
+ if [ $? -eq 0 ]; then
+ docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
+ fi
+
cp .httplog_${ATC}.txt $TESTLOGS/$ATC/$1_httplog_${ATC}.txt 2>&1
- docker exec -it $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1
+ __check_included_image 'SDNC'
+ if [ $? -eq 0 ]; then
+ docker exec -t $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1
+ fi
- docker exec -it $SDNC_ONAP_APP_NAME cat $SDNC_ONAP_KARAF_LOG > $TESTLOGS/$ATC/$1_SDNC_ONAP_karaf.log 2>&1
+ __check_included_image 'RICSIM'
+ if [ $? -eq 0 ]; then
+ rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
+ for ric in $rics; do
+ docker logs $ric > $TESTLOGS/$ATC/$1_$ric.log 2>&1
+ done
+ fi
- rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
- for ric in $rics; do
- docker logs $ric > $TESTLOGS/$ATC/$1_$ric.log 2>&1
- done
- body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
- echo "$body" > $TESTLOGS/$ATC/$1_consul_config.json 2>&1
echo ""
}
###############
## Generic curl
###############
-# Generic curl function, assumed all 200-codes are ok
-# args: <url>
+# Generic curl function, assumes all 200-codes are ok
+# args: <valid-curl-args-including full url>
# returns: <returned response (without respose code)> or "<no-response-from-server>" or "<not found, <http-code>>""
# returns: The return code is 0 for ok and 1 for not ok
__do_curl() {
echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
- curlString="curl -skw %{http_code} $1"
+ curlString="curl -skw %{http_code} $@"
echo " CMD: $curlString" >> $HTTPLOG
res=$($curlString)
echo " RESP: $res" >> $HTTPLOG
http_code="${res:${#res}-3}"
if [ ${#res} -eq 3 ]; then
- echo "<no-response-from-server>"
- return 1
+ if [ $http_code -lt 200 ] || [ $http_code -gt 299 ]; then
+ echo "<no-response-from-server>"
+ return 1
+ else
+ echo "X2" >> $HTTPLOG
+ return 0
+ fi
else
if [ $http_code -lt 200 ] || [ $http_code -gt 299 ]; then
echo "<not found, resp:${http_code}>"
@@ -1817,8 +2104,8 @@
path=${3:5}
result="$(__do_curl $2$path)"
retcode=$?
- echo "$result" > .tmp.curl.json
- result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
+ echo "$result" > ./tmp/.tmp.curl.json
+ result=$(python3 ../common/count_json_elements.py "./tmp/.tmp.curl.json")
fi
duration=$((SECONDS-start))
echo -ne " Result=${result} after ${duration} seconds${SAMELINE}"
@@ -1875,8 +2162,8 @@
path=${3:5}
result="$(__do_curl $2$path)"
retcode=$?
- echo "$result" > .tmp.curl.json
- result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
+ echo "$result" > ./tmp/.tmp.curl.json
+ result=$(python3 ../common/count_json_elements.py "./tmp/.tmp.curl.json")
fi
if [ $retcode -ne 0 ]; then
((RES_FAIL++))
diff --git a/test/common/testsuite_common.sh b/test/common/testsuite_common.sh
index 2c5e6c3..bae1b6b 100644
--- a/test/common/testsuite_common.sh
+++ b/test/common/testsuite_common.sh
@@ -29,13 +29,8 @@
paramError=0
fi
fi
-if [ $# -eq 2 ]; then
- if [ $2 == "auto-clean" ]; then
- paramError=0
- fi
-fi
if [ $paramError -ne 0 ]; then
- echo "Expected arg: local|remote|remote-remove [ auto-clean ]"
+ echo "Expected arg: local|remote|remote-remove"
exit 1
fi
diff --git a/test/prodstub/.gitignore b/test/prodstub/.gitignore
new file mode 100644
index 0000000..4aa3a7a
--- /dev/null
+++ b/test/prodstub/.gitignore
@@ -0,0 +1,2 @@
+.tmp.json
+.dockererr
\ No newline at end of file
diff --git a/test/prodstub/Dockerfile b/test/prodstub/Dockerfile
new file mode 100644
index 0000000..bdc3521
--- /dev/null
+++ b/test/prodstub/Dockerfile
@@ -0,0 +1,33 @@
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+FROM python:3.8-slim-buster
+
+COPY app/ /usr/src/app/
+COPY cert/ /usr/src/app/cert/
+
+WORKDIR /usr/src/app
+
+RUN pip install -r requirements.txt
+
+RUN chmod +x start.sh
+
+#install nginx
+RUN apt-get update
+RUN apt-get install -y nginx=1.14.*
+
+CMD [ "./start.sh" ]
diff --git a/test/prodstub/README.md b/test/prodstub/README.md
new file mode 100644
index 0000000..aa23b78
--- /dev/null
+++ b/test/prodstub/README.md
@@ -0,0 +1,46 @@
+## producer stub - a stub interface to simulate data producers ##
+
+The producer stub is intended for function tests to simulate data producers.
+
+
+# Ports and certificates
+TBD
+
+| Port | Protocol |
+| -------- | ----- |
+| 8092 | http |
+| 8093 | https |
+
+
+
+### Control interface ###
+
+TBD
+
+
+### Build and start ###
+
+>Build image<br>
+```docker build -t producer-stub .```
+
+>Start the image on both http and https<br>
+```docker run -it -p 8092:8092 -p 8093:8093 --name producer-stub producer-stub```
+
+It will listen to http 8092 port and https 8093 port(using default certificates) at the same time.
+
+TBD
+
+## License
+
+Copyright (C) 2020 Nordix Foundation. 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.
\ No newline at end of file
diff --git a/test/prodstub/app/job-schema.json b/test/prodstub/app/job-schema.json
new file mode 100644
index 0000000..1662066
--- /dev/null
+++ b/test/prodstub/app/job-schema.json
@@ -0,0 +1,20 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "EI Job Schema",
+ "description": "Schema for EI Job",
+ "type": "object",
+ "properties": {
+ "ei_job_identity": {
+ "type": "string"
+ },
+ "ei_type_identity": {
+ "type": "string"
+ },
+ "target_uri": {
+ "type": "string"
+ },
+ "ei_job_data": {
+ "type": "object"
+ }
+ }
+ }
\ No newline at end of file
diff --git a/test/prodstub/app/nginx.conf b/test/prodstub/app/nginx.conf
new file mode 100644
index 0000000..8119b0d
--- /dev/null
+++ b/test/prodstub/app/nginx.conf
@@ -0,0 +1,100 @@
+user www-data;
+worker_processes auto;
+pid /run/nginx.pid;
+include /etc/nginx/modules-enabled/*.conf;
+
+events {
+ worker_connections 768;
+ # multi_accept on;
+}
+
+http {
+
+ ##
+ # Basic Settings
+ ##
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ keepalive_timeout 65;
+ types_hash_max_size 2048;
+ # server_tokens off;
+
+ # server_names_hash_bucket_size 64;
+ # server_name_in_redirect off;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ server { # simple reverse-proxy
+ listen 8092;
+ listen [::]:8092;
+ listen 8093 ssl;
+ listen [::]:8093 ssl;
+ server_name localhost;
+ ssl_certificate /usr/src/app/cert/cert.crt;
+ ssl_certificate_key /usr/src/app/cert/key.crt;
+ ssl_password_file /usr/src/app/cert/pass;
+
+ # serve dynamic requests
+ location / {
+ proxy_pass http://localhost:2222;
+ }
+ }
+ ##
+ # SSL Settings
+ ##
+
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
+ ssl_prefer_server_ciphers on;
+
+ ##
+ # Logging Settings
+ ##
+
+ access_log /var/log/nginx/access.log;
+ error_log /var/log/nginx/error.log;
+
+ ##
+ # Gzip Settings
+ ##
+
+ gzip on;
+
+ # gzip_vary on;
+ # gzip_proxied any;
+ # gzip_comp_level 6;
+ # gzip_buffers 16 8k;
+ # gzip_http_version 1.1;
+ # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+
+ ##
+ # Virtual Host Configs
+ ##
+
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+}
+
+
+#mail {
+# # See sample authentication script at:
+# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
+#
+# # auth_http localhost/auth.php;
+# # pop3_capabilities "TOP" "USER";
+# # imap_capabilities "IMAP4rev1" "UIDPLUS";
+#
+# server {
+# listen localhost:110;
+# protocol pop3;
+# proxy on;
+# }
+#
+# server {
+# listen localhost:143;
+# protocol imap;
+# proxy on;
+# }
+#}
diff --git a/test/prodstub/app/prodstub.py b/test/prodstub/app/prodstub.py
new file mode 100644
index 0000000..c21a7ab
--- /dev/null
+++ b/test/prodstub/app/prodstub.py
@@ -0,0 +1,463 @@
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+from flask import Flask
+from flask import request
+
+import json
+from jsonschema import validate
+
+app = Flask(__name__)
+
+# # list of callback messages
+# msg_callbacks={}
+
+# Server info
+HOST_IP = "::"
+HOST_PORT = 2222
+
+# # Metrics vars
+# cntr_msg_callbacks=0
+# cntr_msg_fetched=0
+
+# Request and response constants
+CALLBACK_CREATE_URL="/callbacks/create/<string:producer_id>"
+CALLBACK_DELETE_URL="/callbacks/delete/<string:producer_id>"
+CALLBACK_SUPERVISION_URL="/callbacks/supervision/<string:producer_id>"
+
+ARM_CREATE_RESPONSE="/arm/create/<string:producer_id>/<string:job_id>"
+ARM_DELETE_RESPONSE="/arm/delete/<string:producer_id>/<string:job_id>"
+ARM_SUPERVISION_RESPONSE="/arm/supervision/<string:producer_id>"
+ARM_TYPE="/arm/type/<string:producer_id>/<string:type_id>"
+
+COUNTER_SUPERVISION="/counter/supervision/<string:producer_id>"
+COUNTER_CREATE="/counter/create/<string:producer_id>/<string:job_id>"
+COUNTER_DELETE="/counter/delete/<string:producer_id>/<string:job_id>"
+
+JOB_DATA="/jobdata/<string:producer_id>/<string:job_id>"
+
+STATUS="/status"
+
+#Constsants
+APPL_JSON='application/json'
+UNKNOWN_QUERY_PARAMETERS="Unknown query parameter(s)"
+RETURNING_CONFIGURED_RESP="returning configured response code"
+JOBID_NO_MATCH="job id in stored json does not match request"
+PRODUCER_OR_JOB_NOT_FOUND="producer or job not found"
+PRODUCER_NOT_FOUND="producer not found"
+TYPE_NOT_FOUND="type not found"
+TYPE_IN_USE="type is in use in a job"
+JSON_CORRUPT="json in request is corrupt or missing"
+
+#Producer and job db, including armed responses
+db={}
+# producer
+# armed response for supervision
+# armed types
+# supervision counter
+# job
+# job json
+# armed response for create
+# armed response for delete
+# create counter
+# delete counter
+
+# Helper function to populate a callback dict with the basic structure
+# if job_id is None then only the producer level is setup and the producer dict is returned
+# if job_id is not None, the job level is setup and the job dict is returned (producer must exist)
+def setup_callback_dict(producer_id, job_id):
+
+ producer_dict=None
+ if (producer_id in db.keys()):
+ producer_dict=db[producer_id]
+ else:
+ if (job_id is not None):
+ return None
+ producer_dict={}
+ db[producer_id]=producer_dict
+
+ producer_dict['supervision_response']=200
+ producer_dict['supervision_counter']=0
+ producer_dict['types']=[]
+
+ if (job_id is None):
+ return producer_dict
+
+ job_dict=None
+ if (job_id in producer_dict.keys()):
+ job_dict=producer_dict[job_id]
+ else:
+ job_dict={}
+ producer_dict[job_id]=job_dict
+ job_dict['create_response']=201
+ job_dict['delete_response']=404
+ job_dict['json']=None
+ job_dict['create_counter']=0
+ job_dict['delete_counter']=0
+ return job_dict
+
+
+# Helper function to get an entry from the callback db
+# if job_id is None then only the producer dict is returned (or None if producer is not found)
+# if job_id is not None, the job is returned (or None if producer/job is not found)
+def get_callback_dict(producer_id, job_id):
+
+ producer_dict=None
+ if (producer_id in db.keys()):
+ producer_dict=db[producer_id]
+
+ if (job_id is None):
+ return producer_dict
+
+ job_dict=None
+ if (job_id in producer_dict.keys()):
+ job_dict=producer_dict[job_id]
+
+ return job_dict
+
+# Helper function find if a key/valye exist in the dictionay tree
+# True if found
+def recursive_search(s_dict, s_key, s_id):
+ for pkey in s_dict:
+ if (pkey == s_key) and (s_dict[pkey] == s_id):
+ return True
+ if (isinstance(s_dict[pkey], dict)):
+ recursive_search(s_dict[pkey], s_key, s_id)
+
+ return False
+
+# I'm alive function
+# response: always 200
+@app.route('/',
+ methods=['GET'])
+def index():
+ return 'OK', 200
+
+# Arm the create callback with a response code
+# Omitting the query parameter switch to response back to the standard 200/201 response
+# URI and parameters (PUT): /arm/create/<producer_id>/<job-id>[?response=<resonsecode>]
+# Setting
+# response: 200 (400 if incorrect query params)
+@app.route(ARM_CREATE_RESPONSE,
+ methods=['PUT'])
+def arm_create(producer_id, job_id):
+
+ arm_response=request.args.get('response')
+
+ if (arm_response is None):
+ if (len(request.args) != 0):
+ return UNKNOWN_QUERY_PARAMETERS,400
+ else:
+ if (len(request.args) != 1):
+ return UNKNOWN_QUERY_PARAMETERS,400
+
+ print("Arm create received for producer: "+str(producer_id)+" and job: "+str(job_id)+" and response: "+str(arm_response))
+
+ job_dict=setup_callback_dict(producer_id, job_id)
+
+ if (arm_response is None): #Reset the response depending if a job exists or not
+ if (job_dict['json'] is None):
+ job_dict['create_response']=201
+ else:
+ job_dict['create_response']=200
+ else:
+ job_dict['create_response']=arm_response
+
+ return "",200
+
+# Arm the delete callback with a response code
+# Omitting the query parameter switch to response back to the standard 204 response
+# URI and parameters (PUT): /arm/delete/<producer_id>/<job-id>[?response=<resonsecode>]
+# response: 200 (400 if incorrect query params)
+@app.route(ARM_DELETE_RESPONSE,
+ methods=['PUT'])
+def arm_delete(producer_id, job_id):
+
+ arm_response=request.args.get('response')
+
+ if (arm_response is None):
+ if (len(request.args) != 0):
+ return UNKNOWN_QUERY_PARAMETERS,400
+ else:
+ if (len(request.args) != 1):
+ return UNKNOWN_QUERY_PARAMETERS,400
+
+ print("Arm delete received for producer: "+str(producer_id)+" and job: "+str(job_id)+" and response: "+str(arm_response))
+
+ arm_response=request.args.get('response')
+
+ job_dict=setup_callback_dict(producer_id, job_id)
+
+ if (arm_response is None): #Reset the response depening if a job exists or not
+ if (job_dict['json'] is None):
+ job_dict['delete_response']=404
+ else:
+ job_dict['delete_response']=204
+ else:
+ job_dict['delete_response']=arm_response
+
+ return "",200
+
+# Arm the supervision callback with a response code
+# Omitting the query parameter switch to response back to the standard 200 response
+# URI and parameters (PUT): /arm/supervision/<producer_id>[?response=<resonsecode>]
+# response: 200 (400 if incorrect query params)
+@app.route(ARM_SUPERVISION_RESPONSE,
+ methods=['PUT'])
+def arm_supervision(producer_id):
+
+ arm_response=request.args.get('response')
+
+ if (arm_response is None):
+ if (len(request.args) != 0):
+ return UNKNOWN_QUERY_PARAMETERS,400
+ else:
+ if (len(request.args) != 1):
+ return UNKNOWN_QUERY_PARAMETERS,400
+
+ print("Arm supervision received for producer: "+str(producer_id)+" and response: "+str(arm_response))
+
+ producer_dict=setup_callback_dict(producer_id, None)
+ if (arm_response is None):
+ producer_dict['supervision_response']=200
+ else:
+ producer_dict['supervision_response']=arm_response
+
+ return "",200
+
+# Arm a producer with a type
+# URI and parameters (PUT): /arm/type/<string:producer_id>/<string:type-id>
+# response: 200 (404)
+@app.route(ARM_TYPE,
+ methods=['PUT'])
+def arm_type(producer_id, type_id):
+
+ print("Arm type received for producer: "+str(producer_id)+" and type: "+str(type_id))
+
+ producer_dict=get_callback_dict(producer_id, None)
+
+ if (producer_dict is None):
+ return PRODUCER_NOT_FOUND,404
+
+ type_list=producer_dict['types']
+ if (type_id not in type_list):
+ type_list.append(type_id)
+
+ return "",200
+
+# Disarm a producer with a type
+# URI and parameters (DELETE): /arm/type/<string:producer_id>/<string:type-id>
+# response: 200 (404)
+@app.route(ARM_TYPE,
+ methods=['DELETE'])
+def disarm_type(producer_id, type_id):
+
+ print("Disarm type received for producer: "+str(producer_id)+" and type: "+str(type_id))
+
+ producer_dict=get_callback_dict(producer_id, None)
+
+ if (producer_dict is None):
+ return PRODUCER_NOT_FOUND,404
+
+ if (recursive_search(producer_dict, "ei_job_type",type_id) is True):
+ return "TYPE_IN_USE",400
+
+ type_list=producer_dict['types']
+ type_list.remove(type_id)
+
+ return "",200
+
+# Callback for create job
+# URI and parameters (POST): /callbacks/create/<producer_id>
+# response 201 at create, 200 at update or other configured response code
+@app.route(CALLBACK_CREATE_URL,
+ methods=['POST'])
+def callback_create(producer_id):
+
+ req_json_dict=None
+ try:
+ req_json_dict = json.loads(request.data)
+ with open('job-schema.json') as f:
+ schema = json.load(f)
+ validate(instance=req_json_dict, schema=schema)
+ except Exception:
+ return JSON_CORRUPT,400
+
+ producer_dict=get_callback_dict(producer_id, None)
+ if (producer_dict is None):
+ return PRODUCER_OR_JOB_NOT_FOUND,400
+ type_list=producer_dict['types']
+ type_id=req_json_dict['ei_type_identity']
+ if (type_id not in type_list):
+ return TYPE_NOT_FOUND
+
+ job_id=req_json_dict['ei_job_identity']
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return PRODUCER_OR_JOB_NOT_FOUND,400
+ return_code=0
+ return_msg=""
+ if (req_json_dict['ei_job_identity'] == job_id):
+ print("Create callback received for producer: "+str(producer_id)+" and job: "+str(job_id))
+ return_code=job_dict['create_response']
+ if ((job_dict['create_response'] == 200) or (job_dict['create_response'] == 201)):
+ job_dict['json']=req_json_dict
+ if (job_dict['create_response'] == 201): #Set up next response code if create was ok
+ job_dict['create_response'] = 200
+ if (job_dict['delete_response'] == 404):
+ job_dict['delete_response'] = 204
+ else:
+ return_msg=RETURNING_CONFIGURED_RESP
+
+ job_dict['create_counter']=job_dict['create_counter']+1
+ else:
+ return JOBID_NO_MATCH, 400
+
+ return return_msg,return_code
+
+# Callback for delete job
+# URI and parameters (POST): /callbacks/delete/<producer_id>
+# response: 204 at delete or other configured response code
+@app.route(CALLBACK_DELETE_URL,
+ methods=['POST'])
+def callback_delete(producer_id):
+
+ req_json_dict=None
+ try:
+ req_json_dict = json.loads(request.data)
+ with open('job-schema.json') as f:
+ schema = json.load(f)
+ validate(instance=req_json_dict, schema=schema)
+ except Exception:
+ return JSON_CORRUPT,400
+
+ job_id=req_json_dict['ei_job_identity']
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return PRODUCER_OR_JOB_NOT_FOUND,400
+ return_code=0
+ return_msg=""
+ if (req_json_dict['ei_job_identity'] == job_id):
+ print("Delete callback received for producer: "+str(producer_id)+" and job: "+str(job_id))
+ return_code=job_dict['delete_response']
+ if (job_dict['delete_response'] == 204):
+ job_dict['json']=None
+ job_dict['delete_response']=404
+ if (job_dict['create_response'] == 200):
+ job_dict['create_response'] = 201 # reset create response if delete was ok
+ else:
+ return_msg=RETURNING_CONFIGURED_RESP
+
+ job_dict['delete_counter']=job_dict['delete_counter']+1
+ else:
+ return JOBID_NO_MATCH, 400
+
+ return return_msg, return_code
+
+# Callback for supervision of producer
+# URI and parameters (GET): /callbacks/supervision/<producer_id>
+# response: 200 or other configured response code
+@app.route(CALLBACK_SUPERVISION_URL,
+ methods=['GET'])
+def callback_supervision(producer_id):
+
+ print("Supervision callback received for producer: "+str(producer_id))
+
+ producer_dict=get_callback_dict(producer_id, None)
+ if (producer_dict is None):
+ return PRODUCER_NOT_FOUND,400
+ return_code=producer_dict['supervision_response']
+ return_msg=""
+ if (return_code != 200):
+ return_msg="returning configured response code"
+
+ producer_dict['supervision_counter']=producer_dict['supervision_counter']+1
+
+ return return_msg,producer_dict['supervision_response']
+
+# Callback for supervision of producer
+# URI and parameters (GET): "/jobdata/<string:producer_id>/<string:job_id>"
+# response: 200 or 204
+@app.route(JOB_DATA,
+ methods=['GET'])
+def get_jobdata(producer_id, job_id):
+
+ print("Get job data received for producer: "+str(producer_id)+" and job: "+str(job_id))
+
+ job_dict=setup_callback_dict(producer_id, job_id)
+ if (job_dict['json'] is None):
+ return "",204
+ else:
+ return json.dumps(job_dict['json']), 200
+
+
+# Counter for create calls for a job
+# URI and parameters (GET): "/counter/create/<string:producer_id>/<string:job_id>"
+# response: 200 and counter value
+@app.route(COUNTER_CREATE,
+ methods=['GET'])
+def counter_create(producer_id, job_id):
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return -1,200
+ return str(job_dict['create_counter']),200
+
+# Counter for delete calls for a job
+# URI and parameters (GET): "/counter/delete/<string:producer_id>/<string:job_id>"
+# response: 200 and counter value
+@app.route(COUNTER_DELETE,
+ methods=['GET'])
+def counter_delete(producer_id, job_id):
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return -1,200
+ return str(job_dict['delete_counter']),200
+
+# Counter for supervision calls for a producer
+# URI and parameters (GET): "/counter/supervision/<string:producer_id>"
+# response: 200 and counter value
+@app.route(COUNTER_SUPERVISION,
+ methods=['GET'])
+def counter_supervision(producer_id):
+ producer_dict=get_callback_dict(producer_id, None)
+ if (producer_dict is None):
+ return -1,200
+ return str(producer_dict['supervision_counter']),200
+
+# Get status info
+# URI and parameters (GET): "/status"
+# -
+@app.route(STATUS,
+ methods=['GET'])
+def status():
+ global db
+ return json.dumps(db),200
+
+
+# Reset db
+@app.route('/reset',
+ methods=['GET', 'POST', 'PUT'])
+def reset():
+ global db
+ db={}
+ return "",200
+
+### Main function ###
+
+if __name__ == "__main__":
+ app.run(port=HOST_PORT, host=HOST_IP)
diff --git a/test/prodstub/app/requirements.txt b/test/prodstub/app/requirements.txt
new file mode 100644
index 0000000..cc0dabf
--- /dev/null
+++ b/test/prodstub/app/requirements.txt
@@ -0,0 +1,3 @@
+Flask==1.1.1
+jsonschema==3.2.0
+
diff --git a/test/prodstub/app/start.sh b/test/prodstub/app/start.sh
new file mode 100755
index 0000000..21858c8
--- /dev/null
+++ b/test/prodstub/app/start.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+#start nginx
+nginx -c /usr/src/app/nginx.conf
+
+#start mrstub
+python3 -u prodstub.py
diff --git a/test/prodstub/basic_test.sh b/test/prodstub/basic_test.sh
new file mode 100755
index 0000000..c0af24e
--- /dev/null
+++ b/test/prodstub/basic_test.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+# Automated test script for producer stub container
+
+if [ $# -ne 1 ]; then
+ echo "Usage: ./basic_test.sh nonsecure|secure"
+ exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+ echo "Usage: ./basic_test.sh nonsecure|secure"
+ exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+ #Default http port for the simulator
+ PORT=8092
+ # Set http protocol
+ HTTPX="http"
+else
+ #Default https port for the simulator
+ PORT=8093
+ # Set https protocol
+ HTTPX="https"
+fi
+
+# source function to do curl and check result
+. ../common/do_curl_function.sh
+
+echo "=== hello world ==="
+RESULT="OK"
+do_curl GET / 200
+
+
+
+echo "********************"
+echo "*** All tests ok ***"
+echo "********************"
diff --git a/test/prodstub/cert/cert.crt b/test/prodstub/cert/cert.crt
new file mode 100644
index 0000000..a24dfc4
--- /dev/null
+++ b/test/prodstub/cert/cert.crt
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQCv7SV/aTc/YjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA1MDMwMDI0MzdaFw00NzA5MTgwMDI0MzdaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApsGQcCv+Ce/+AbHx+3Wu
+ujGtWF7uLX+/MahOHPfdXqidwG7OpmYnGkL06cA52P0BcZdc1hPGQbQdFJC8aW6U
+5X9owRz9IRiwpzRhRqmMJfeqrLaqLL9K5MpCv+qsDzXu9ngRLJDk5CyeEfTjosEr
+GWDywWahQKHChamdH701djFGwWGP3gttGvQoMnaSpzeyDKitBZql6bSxKkhWgFop
+yxfU7qjbzOASLWaMx2r+MIJ88+AYDqYBTj649N534AYrIdjlQnvEKzGH0sOgHFYO
+oaTTvmE/vRPlmbSX1U7mo/SvMWNPZkKUPDltyapOpBltfMiRJH4ndLOXJWRgmYha
+SQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAdAwQpntpgUWUxCTk/Pw2+w5v+VxMM
+K6QWhm9JdRn3XKQnKrFexVRso/x8TA8V50EUGwQwbnKApNXvJsV2jvbP/YwDsG2u
+jBxs0DSspjDvbhUTkuWNYufQZIUGYMyccHap+CKD4rD2loMkmwbh5rII3SGEzUFE
+rOY4VhqDjGCcILbChiY/QMA6Uyb6jLGxTARhgblWi9RWr9LuKv7raaUcnAIz1GO8
+z559kUnOKbsB46RZKRa0uIumz9qqXqxnVLWnIwT3DinpXsnzcPqNyyhTk6XR+W5o
+0AuUCyT1WKlejrfMmmV6hRNHbT4x7cQrx4EjNf5hM00mN++F+QdGMa/G
+-----END CERTIFICATE-----
diff --git a/test/prodstub/cert/generate_cert_and_key.sh b/test/prodstub/cert/generate_cert_and_key.sh
new file mode 100755
index 0000000..0f79bbf
--- /dev/null
+++ b/test/prodstub/cert/generate_cert_and_key.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+# This will generate a self-signed certificate with password 'test'
+openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999
diff --git a/test/prodstub/cert/key.crt b/test/prodstub/cert/key.crt
new file mode 100644
index 0000000..105ee75
--- /dev/null
+++ b/test/prodstub/cert/key.crt
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIpz2Uxhl1+ZwCAggA
+MB0GCWCGSAFlAwQBKgQQu1or54X1Bk5IMPGoDrdxkASCBNCBKcePejHXlG0fb2qt
+TtQrpEr8UR60iFOaeUQ2Lc1zK0wzFCXAIXEWEcaozv75mJ5ReemkBMCyuzPJnoiM
+LTeKuoUw8l48S9arB9l+/vVgUnMY0fm+QDsnPffkXKxC2kNwwFgGCT7tIGezuo/e
+a9a5JJY707YEnkhUKWAQI2Oz/I95tbeYu64d/WtSN2OLu5JVLsCGAhV4cqcShjEb
+pFlfgOHrT0z+qK7YXVR9P74qAZtGsH2ydUrtPtdvddKRpOAm4LzDNmox4Bs6e9nr
+jY56sVRiHGhqeeqW04qRks5ReZF7zuwEgUSzGNlAcbbHn6FNJPOZKuN0e8KYexEM
+y0G04rSNW8qppMsvez6txsou62CeIZ5LyAumwaJJYzwkob0nCmWYcZl5tSpkXZly
+HsQKI2UlO3tiRKd057a46/kxcK85Pwav3Il+FaRXJkzl2rkU3DSy9SjaGL0ROD0U
+1EaZCjeDdzN2GmqRQ1WhN5ivowQyWVf6H/mrxtkWZ3qLKmpa1JmvUgOybPcbqqQr
+tqjj3Oj0zvLFZDqBjfIlTAAimXPgh6qLHH+qUGrI62pMpaldNZNy/swnpPuTX2sF
+TUxFZvnGOmG3qHyvPm91+PypbdVSMb0PeB75XQFqWmajwnua7xfWrH8PLSijp5xQ
+aLyiJ1jjFqXWE9D2v7JhB2BNCYlHxP98UI8kHxh7Fw5y0EKT5pCcbrg2nuLzMrCz
+D4QaxZRuiIiPgy21kowk3WbHLYAjG7f9cIcbbX6Khc/3ulbB8xJ24WNRuzv4EHeh
+TATHqk8nIgpkn1zmvPsKILdWzqZh70IlSctSzoIGzI6C2J76ycSZmcKtar2BZya9
+f1coUlFgXMvdmrf4bt4j2u/biA48OJaVlWBYVfIXUbliFTAQ8biRZFC2n3Xg+W8t
+U2xqW14lZWBOIQFJp27foG6Z4JzyL2WZgQ0PWe0m0+tDaKA/LSWB2Qpwt4o2n0cb
+RCs++c0eFCeOgErEfmmeburMhzQsfkUqpsL+J/ZMaRSiuTCpYM8qbz+KKT/Z6zbl
+2cHWxSFRIqRKAMsj2a61IANjNIdwi2uBHZrWH1HMVVXAbGUJQFKZhxdpn5PBrXqg
+vHRa9u0MQFCjs9NcQAGnBQDS6u+pUVO02WT4MvTker+hbu+f6NPU9FMLu+QbQUEP
+SUdEZL4W9ZuBTdS3n/fTHEL8wKRB5yEW/CS5JuD+8YinZZXrsd3n3Oky05fdk6Bk
+QH9cjMXdsd0Sb0Epw3CWGtXZ6YTHlVWqjdTNlOQdzQ7qfzktgcKujGwvQK0Mgd8x
+nmG+f/HWMOss0JEL3ZR+K9Rr50u8/R+W5+e4VE57yw1fg9Jpq2/sVe2Pt8S7isFK
+qDLoFZtF5RXi1O9KcA9BpnQX1ihPSC1RoY1pGXoF2D4KkV9U4/4j2qM6MGxjQ6lw
+MN0qJ/N70Lti3YWqvYiTymLwVJr8FqoMQsV19MB8012Xd51Bvy6igddhrO83wuuV
+b8PlUzl3Tl7yOviYqxiJ0xd8qw+Hs4+FkHbZIFJcUzTHVbb4SlPUE3wn6nrrIcfK
+rT4wsYhK3afrlvK3ILi6kzzazS1dK+Hv9+mNozNf5u5nNBFQ+7MhtttzLWIaiV6D
+ilLpOwcoO0X0qrzXKR7a+rQ/Dw==
+-----END ENCRYPTED PRIVATE KEY-----
diff --git a/test/prodstub/cert/pass b/test/prodstub/cert/pass
new file mode 100644
index 0000000..30d74d2
--- /dev/null
+++ b/test/prodstub/cert/pass
@@ -0,0 +1 @@
+test
\ No newline at end of file
diff --git a/test/prodstub/prod-stub-build-start.sh b/test/prodstub/prod-stub-build-start.sh
new file mode 100755
index 0000000..7f111b6
--- /dev/null
+++ b/test/prodstub/prod-stub-build-start.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+#Builds the producer stub container and starts it in interactive mode
+
+docker build -t producer-stub .
+
+docker run -it -p 8092:8092 -p 8093:8093 --name producer-stub producer-stub
diff --git a/test/simulator-group/.gitignore b/test/simulator-group/.gitignore
index 25c8fdb..06b4f20 100644
--- a/test/simulator-group/.gitignore
+++ b/test/simulator-group/.gitignore
@@ -1,2 +1,3 @@
node_modules
-package-lock.json
\ No newline at end of file
+package-lock.json
+.dockererr
diff --git a/test/simulator-group/ecs/.gitignore b/test/simulator-group/ecs/.gitignore
new file mode 100644
index 0000000..4aa3a7a
--- /dev/null
+++ b/test/simulator-group/ecs/.gitignore
@@ -0,0 +1,2 @@
+.tmp.json
+.dockererr
\ No newline at end of file
diff --git a/test/simulator-group/ecs/docker-compose.yml b/test/simulator-group/ecs/docker-compose.yml
new file mode 100644
index 0000000..11cf810
--- /dev/null
+++ b/test/simulator-group/ecs/docker-compose.yml
@@ -0,0 +1,34 @@
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+version: '3.0'
+networks:
+ default:
+ external:
+ name: ${DOCKER_SIM_NWNAME}
+services:
+ ecs:
+ image: ${ECS_IMAGE}
+ container_name: ${ECS_APP_NAME}
+ networks:
+ default:
+ aliases:
+ - ${ECS_APP_NAME_ALIAS}
+ ports:
+ - ${ECS_EXTERNAL_PORT}:${ECS_INTERNAL_PORT}
+ - ${ECS_EXTERNAL_SECURE_PORT}:${ECS_INTERNAL_SECURE_PORT}
+
+
+
diff --git a/test/simulator-group/prodstub/.gitignore b/test/simulator-group/prodstub/.gitignore
new file mode 100644
index 0000000..4aa3a7a
--- /dev/null
+++ b/test/simulator-group/prodstub/.gitignore
@@ -0,0 +1,2 @@
+.tmp.json
+.dockererr
\ No newline at end of file
diff --git a/test/simulator-group/prodstub/docker-compose.yml b/test/simulator-group/prodstub/docker-compose.yml
new file mode 100644
index 0000000..1ce8b49
--- /dev/null
+++ b/test/simulator-group/prodstub/docker-compose.yml
@@ -0,0 +1,33 @@
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. 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=================================================
+#
+
+version: '3.0'
+networks:
+ default:
+ external:
+ name: ${DOCKER_SIM_NWNAME}
+services:
+ producer-stub:
+ networks:
+ default:
+ aliases:
+ - ${PROD_STUB_APP_NAME_ALIAS}
+ container_name: ${PROD_STUB_APP_NAME}
+ image: ${PROD_STUB_IMAGE}
+ ports:
+ - ${PROD_STUB_EXTERNAL_PORT}:${PROD_STUB_INTERNAL_PORT}
+ - ${PROD_STUB_EXTERNAL_SECURE_PORT}:${PROD_STUB_INTERNAL_SECURE_PORT}
diff --git a/test/simulator-group/sdnc/docker-compose.yml b/test/simulator-group/sdnc/docker-compose.yml
index f835504..b9391ea 100644
--- a/test/simulator-group/sdnc/docker-compose.yml
+++ b/test/simulator-group/sdnc/docker-compose.yml
@@ -54,6 +54,7 @@
- db:sdnctldb02
environment:
- MYSQL_ROOT_PASSWORD=openECOMP1.0
+ - SDNC_DB_INIT=true
- SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
- A1_TRUSTSTORE_PASSWORD=${SDNC_A1_TRUSTSTORE_PASSWORD}
logging:
diff --git a/test/simulator-group/sdnc_onap/.gitignore b/test/simulator-group/sdnc_onap/.gitignore
deleted file mode 100644
index 3384196..0000000
--- a/test/simulator-group/sdnc_onap/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.dockererr
\ No newline at end of file
diff --git a/test/simulator-group/sdnc_onap/docker-compose.yml b/test/simulator-group/sdnc_onap/docker-compose.yml
deleted file mode 100644
index 7aab1da..0000000
--- a/test/simulator-group/sdnc_onap/docker-compose.yml
+++ /dev/null
@@ -1,63 +0,0 @@
-# ==================================================================================
-# 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.
-# 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.
-# ==================================================================================
-version: '2.1'
-
-networks:
- default:
- driver: bridge
- name: ${DOCKER_SIM_NWNAME}
-
-services:
- db:
- image: ${SDNC_ONAP_DB_IMAGE}
- container_name: ${SDNC_ONAP_DB_APP_NAME}
- networks:
- - default
- ports:
- - "3306"
- environment:
- - MYSQL_ROOT_PASSWORD=openECOMP1.0
- - MYSQL_ROOT_HOST=%
- logging:
- driver: "json-file"
- options:
- max-size: "30m"
- max-file: "5"
-
- a1-controller:
- image: ${SDNC_ONAP_A1_ADAPTER_IMAGE}
- depends_on :
- - db
- container_name: ${SDNC_ONAP_APP_NAME}
- networks:
- - default
- entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"]
- ports:
- - ${SDNC_ONAP_EXTERNAL_PORT}:${SDNC_ONAP_INTERNAL_PORT}
- - ${SDNC_ONAP_EXTERNAL_SECURE_PORT}:${SDNC_ONAP_INTERNAL_SECURE_PORT}
- links:
- - db:dbhost
- - db:sdnctldb01
- - db:sdnctldb02
- environment:
- - MYSQL_ROOT_PASSWORD=openECOMP1.0
- - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
- logging:
- driver: "json-file"
- options:
- max-size: "30m"
- max-file: "5"
-