Add ct automation
authorEduardo Ramos Testillano (eramedu) <eduardo.ramos.testillano@ericsson.com>
Mon, 11 May 2020 10:23:11 +0000 (12:23 +0200)
committerEduardo Ramos Testillano (eramedu) <eduardo.ramos.testillano@ericsson.com>
Mon, 11 May 2020 10:23:11 +0000 (12:23 +0200)
Services including AF and local diameter server is now skipped as pytest test.
Another one was added as dummy services (stack 0 already loaded).

New ct script (CT automation) which needs 'netstat' tool in the ADML HTTP image.
This script:
* ask for re-build service image
* restart service container
* configure real services
* monitor service available
* ask for pytest global execution

New resources and examples needed are included.

Also fixed visilibity operation at SIGUSR2 interface: was returning
without updating response information.

docker-images/anna-adml-http/Dockerfile
example/diameter/launcher/Launcher.cpp
example/diameter/launcher/resources/rest_api/ct/ct.sh [new file with mode: 0755]
example/diameter/launcher/resources/rest_api/ct/fsm-testing/testid-waitfc_test.py [new file with mode: 0644]
example/diameter/launcher/resources/rest_api/ct/hot-changes/services_test.py
example/diameter/launcher/resources/rest_api/ct/resources/servicesDummyJson-request.json [new file with mode: 0644]
example/diameter/launcher/resources/rest_api/helpers/diameterJsonHelper/examples/dummyServices.xml [new file with mode: 0644]

index 685279f..68b3467 100644 (file)
@@ -3,7 +3,8 @@ COPY etc/ /etc
 COPY opt/adml/ /opt/adml
 
 RUN apt-get update && apt-get install -y \
-   procps
+   procps \
+   net-tools
 
 COPY starter.sh /var/starter.sh
 
index e52b5d2..507bea3 100644 (file)
@@ -1171,7 +1171,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons
     outfile.write(xmlString.c_str(), xmlString.size());
     outfile.close();
   } else if((opType == "hide") || (opType == "show") || (opType == "hidden") || (opType == "shown")) {
-    return eop.visibility(opt_response, opType, param1, (param2 != "") ? atoi(param2.c_str()) : -1);
+    result = eop.visibility(opt_response, opType, param1, (param2 != "") ? atoi(param2.c_str()) : -1);
 
   } else if((opType == "sendxml2e") || (opType == "sendhex2e")) {
     anna::diameter::comm::Message *msg;
diff --git a/example/diameter/launcher/resources/rest_api/ct/ct.sh b/example/diameter/launcher/resources/rest_api/ct/ct.sh
new file mode 100755 (executable)
index 0000000..4d485df
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+#############
+# VARIABLES #
+#############
+
+REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null)"
+[ -z "$REPO_DIR" ] && { echo "You must execute under a valid git repository !" ; exit 1 ; }
+
+SERVICES=${REPO_DIR}/example/diameter/launcher/resources/rest_api/ct/resources/servicesJson-request.json
+ENDPOINT=http://localhost:8074
+PORT=$(echo ${ENDPOINT} | cut -d: -f3)
+C_NAME=adml-http
+
+#############
+# EXECUTION #
+#############
+cd $(dirname $0)
+
+# Basic requirement:
+nghttp --version 2>/dev/null
+[ $? -ne 0 ] && { echo -e "\nThe HTTP2 client 'nghttp' is required. Install with: sudo apt install nghttp\n" ; exit 1 ; }
+echo "Requirement found !"
+
+echo
+echo "Rebuild ADML HTTP service image (y/n) [y]:"
+read opt
+[ -z "${opt}" ] && opt=y
+[ "${opt}" = "y" ] && ${REPO_DIR}/tools/build-adml-http
+
+version=$(${REPO_DIR}/tools/version)
+echo "Restart ADML HTTP service image (version '${version}') ..."
+docker kill ${C_NAME} >/dev/null
+cid=$(docker run --rm -d -p ${PORT}:${PORT} --name ${C_NAME} anna-adml-http:${version})
+echo "Container id: ${cid} (deployed as '${C_NAME}')"
+
+echo
+echo "Configuring services (${SERVICES}) ..."
+sleep 4 # wait for docker running
+nghttp -H ":method: POST" -d ${SERVICES} ${ENDPOINT}/services
+echo
+
+echo
+echo -n "Waiting for server-client connection ..."
+while true
+do
+  docker exec -it ${C_NAME} bash -c "netstat -p $(pgrep ADML) --numeric-ports | grep -w 3868 | grep -w ESTABLISHED" >/dev/null
+  [ $? -eq 0 ] && break
+  echo -n .
+done
+echo "Ready !"
+
+echo
+echo "Press ENTER to start component test, CTRL-C to abort ..."
+read dummy
+
+pytest
+
diff --git a/example/diameter/launcher/resources/rest_api/ct/fsm-testing/testid-waitfc_test.py b/example/diameter/launcher/resources/rest_api/ct/fsm-testing/testid-waitfc_test.py
new file mode 100644 (file)
index 0000000..53d8861
--- /dev/null
@@ -0,0 +1,19 @@
+import pytest
+
+
+def test_001_given_test_indentifier_and_diameter_json_condition_i_want_to_add_test_id_waitfc_step(resources, admlc, admlf):
+
+  flow = admlf.getId()
+
+  requestBody = resources("condition-request.json")
+  responseBodyRef = { "success":"true", "response":"Done" }
+
+  # Send POST
+  response = admlc.post("/testid-waitfc/{}".format(flow), requestBody)
+
+  # Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+  # Cleanup
+  response = admlc.post("/test-clear")
+
index 18e3bfc..5c90efc 100644 (file)
@@ -1,5 +1,6 @@
 import pytest
 
+@pytest.mark.skip(reason="this is run as part of 'ct.sh' wrapper script")
 @pytest.mark.run(order=1)
 @pytest.mark.xfail(reason="This will fail if already provisioned (if you want success here, restart the ADML HTTP Service)")
 def test_001_given_services_json_representation_i_want_to_load_it_through_adml_service(resources, admlc):
@@ -12,3 +13,15 @@ def test_001_given_services_json_representation_i_want_to_load_it_through_adml_s
 
   ### Verify response
   admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
+def test_002_given_dummy_services_json_representation_i_want_to_load_it_through_adml_service(resources, admlc):
+
+  requestBody = resources("servicesDummyJson-request.json")
+  responseBodyRef = { "success":"true", "response":"loaded services correctly" }
+
+  # Send POST
+  response = admlc.post("/services", requestBody)
+
+  ### Verify response
+  admlc.assert_response__status_body_headers(response, 200, responseBodyRef)
+
diff --git a/example/diameter/launcher/resources/rest_api/ct/resources/servicesDummyJson-request.json b/example/diameter/launcher/resources/rest_api/ct/resources/servicesDummyJson-request.json
new file mode 100644 (file)
index 0000000..709400d
--- /dev/null
@@ -0,0 +1,11 @@
+{
+   "servicesJson": {
+      "services": {
+         "stack": {
+            "@dictionary": "stacks/diameter_base.0.xml",
+            "@fixMode": "Never",
+            "@id": "0"
+         }
+      }
+   }
+}
diff --git a/example/diameter/launcher/resources/rest_api/helpers/diameterJsonHelper/examples/dummyServices.xml b/example/diameter/launcher/resources/rest_api/helpers/diameterJsonHelper/examples/dummyServices.xml
new file mode 100644 (file)
index 0000000..61d9f89
--- /dev/null
@@ -0,0 +1,5 @@
+<!-- This is ignored as already registered on ADML HTTP start. Operation never fails -->
+<services>
+  <stack id="0" dictionary="stacks/diameter_base.0.xml" fixMode="Never"/>
+</services>
+