summaryrefslogtreecommitdiffstats
path: root/test/remote-ansible/init-mockserver.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/remote-ansible/init-mockserver.sh')
-rwxr-xr-xtest/remote-ansible/init-mockserver.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/remote-ansible/init-mockserver.sh b/test/remote-ansible/init-mockserver.sh
new file mode 100755
index 0000000..e594ef5
--- /dev/null
+++ b/test/remote-ansible/init-mockserver.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 Bell Canada.
+#
+# 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.
+#
+
+. ./$TEST_DIRECTORY/utils.sh
+
+CBA_NAME="remote-ansible"
+DIR_PAYLOADS="$TEST_DIRECTORY/$CBA_NAME/mock-payloads"
+
+OP=expectation
+if [[ $1 == rm ]]; then
+ OP=clear
+fi
+
+# JOB TEMPLATE
+echo "Mocking Job Template route..."
+export PATH_JT_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/success/api/v2/job_templates/hello_world_job_template/"
+JT_PAYLOAD="$DIR_PAYLOADS/job-template.json"
+apply_env_to_json_template $JT_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JT_PAYLOAD"
+
+# JOB TEMPLATE ERROR
+echo "Mocking Job Template Error route..."
+export PATH_JT_ERR_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/failure/api/v2/job_templates/hello_world_job_template/"
+JT_ERR_PAYLOAD="$DIR_PAYLOADS/job-template-error.json"
+apply_env_to_json_template $JT_ERR_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JT_ERR_PAYLOAD"
+
+# JOB TEMPLATE LAUNCH - GET
+echo "Mocking Job Template Launch GET route..."
+export PATH_GET_JT_LAUNCH_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/success/api/v2/job_templates/123/launch/"
+GET_JT_LAUNCH_PAYLOAD="$DIR_PAYLOADS/get_job-template-launch.json"
+apply_env_to_json_template $GET_JT_LAUNCH_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$GET_JT_LAUNCH_PAYLOAD"
+
+# JOB TEMPLATE LAUNCH
+echo "Mocking Inventory route..."
+export PATH_INVENTORY_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/success/api/v2/inventories/"
+INVENTORY_PAYLOAD="$DIR_PAYLOADS/inventory.json"
+apply_env_to_json_template $INVENTORY_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$INVENTORY_PAYLOAD"
+
+# JOB TEMPLATE LAUNCH - POST
+echo "Mocking Job Template Launch POST route..."
+export PATH_POST_JT_LAUNCH_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/success/api/v2/job_templates/123/launch/"
+POST_JT_LAUNCH_PAYLOAD="$DIR_PAYLOADS/post_job-template-launch.json"
+apply_env_to_json_template $POST_JT_LAUNCH_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$POST_JT_LAUNCH_PAYLOAD"
+
+# JOB EXECUTION
+echo "Mocking Job Execution route..."
+export PATH_JOB_EXECUTION_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/success/api/v2/jobs/456/"
+JOB_EXECUTION_PAYLOAD="$DIR_PAYLOADS/job-execution.json"
+apply_env_to_json_template $JOB_EXECUTION_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JOB_EXECUTION_PAYLOAD"
+
+# JOB OUTPUT
+echo "Mocking Job Output route..."
+export PATH_JOB_OUTPUT_PAYLOAD="/mock-$CI_PIPELINE_ID/remote-ansible/success/api/v2/jobs/456/stdout/"
+JOB_OUTPUT_PAYLOAD="$DIR_PAYLOADS/job-output.json"
+apply_env_to_json_template $JOB_OUTPUT_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JOB_OUTPUT_PAYLOAD"