diff --git a/Dockerfile b/Dockerfile index 610a8bd..fd283bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,27 +2,43 @@ # Test Runner is an image built to execute a set of unit and integration tests for # the 'demo' project. # -FROM python:3 +FROM python:3-buster -# Install our deps -RUN apt-get update -qq && apt-get install -y \ - sudo \ - jq \ - python-pycurl \ - rubygems +# Install dependencies +RUN apt-get update -y +RUN apt-get install -y jq git bash libcurl4 curl openssh-client +# Install pycurl +ENV PYCURL_SSL_LIBRARY=openssl +RUN apt-get install -y build-essential \ + && pip install pycurl + +RUN pip install \ + future \ + jmespath \ + jsonschema \ + pyresttest \ + shyaml + +# TODO: (lkrcal) Enable these when kubectl tests are ready # Set the Kubernetes version as found in the UCP Dashboard or API -RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.5/bin/linux/amd64/kubectl && \ - chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl +# RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.5/bin/linux/amd64/kubectl && \ +# chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl + +RUN git clone https://github.com/sstephenson/bats.git && cd bats && ./install.sh /usr/local && cd .. && rm -rf bats -RUN git clone https://github.com/sstephenson/bats.git && cd bats && ./install.sh /usr/local +# Install iofogctl +RUN curl https://packagecloud.io/install/repositories/iofog/iofogctl/script.deb.sh | bash +RUN apt update -y +RUN apt install iofogctl=2.0.0 -y +RUN iofogctl version -# Install the pyresttest and deps (the basis of all our smoke tests) -RUN pip install pyresttest jsonschema future shyaml jmespath +# Make dir for test results +RUN mkdir -p /test-results # Copy over all the files we need COPY run.bash / COPY tests /tests/ # Run our tests -ENTRYPOINT ["/bin/sh", "-c", "/run.bash"] \ No newline at end of file +ENTRYPOINT ["/bin/sh", "-c", "/run.bash"] diff --git a/README.md b/README.md index e5fa8e0..961a06a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ The following test suites are available: Note that some of additional test suites are automatically skipped as of this release of Test Runner. +## Prerequisites + +You must have iofogctl configured with its default namespace pointing to the ECN you want to test + ## Usage | Test suite | Description | Required configuration | @@ -20,27 +24,29 @@ Note that some of additional test suites are automatically skipped as of this re | Basic microservice deployment integration tests | Sets up users and catalog entries, deploys and destroys microservices on each Agent | | -The format of the environment variables is the following: +Example usage of the test runner with iofogctl configuration: -* _CONTROLLER_ - IP:PORT format (e.g. "1.2.3.4:51121") -* _CONTROLLER_EMAIL_ - existing user identifier in Controller to use for testing (e.g. "user@domain.com") -* _CONTROLLER_PASSWORD_ - login password for the user (e.g. "#Bugs4Fun") -* _AGENTS_ - comma separated URI with user and optional port (e.g. root@1.2.3.4:6451,user@6.7.8.9) - -Note that whenever _AGENTS_ is specified, you need to mount appropriate ssh keys to /root/.ssh of the test-runner containers. The keys can be in any default SSH position: ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/id_rsa. +```bash +docker run --name test-runner \ + -v ~/.iofog/:/root/.iofog/ \ + iofog/test-runner:latest +``` -Example usage of the test runner with full configuration: +Example usage of the test runner with endpoint configurations configuration: ```bash docker run --name test-runner \ - -v ~/.ssh/my_iofog_ssh_key:/root/.ssh/id_rsa \ + -v ~/.ssh/my_iofog_agent_ssh_key:/root/.ssh/id_rsa \ -e CONTROLLER="1.2.3.4:51121" \ -e CONTROLLER_EMAIL="user@domain.com" \ -e CONTROLLER_PASSWORD="#Bugs4Fun" \ - -e AGENTS="root@1.2.3.4:6451,user@6.7.8.9" \ + -e AGENT_USER="root" \ + -e AGENT_KEY="/root/.ssh/id_rsa" \ iofog/test-runner:latest ``` +Note that whenever AGENTS is specified, you need to mount appropriate ssh keys to /root/.ssh of the test-runner containers. The keys can be in any default SSH position: ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/id_rsa. + ## Test Results The output of this test-suite currently is a single XML File that is Junit-XML compliant. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b45c8fe..604af21 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,9 @@ pr: variables: repository: 'focal-freedom-236620/test-runner' + ref: $(Build.SourceBranch) buildTag: $(Build.BuildId) + imageTag: jobs: - job: TestRunner @@ -25,6 +27,18 @@ jobs: vmImage: 'Ubuntu-16.04' steps: + - script: | + if [[ $(ref) == refs/tags* ]]; then + TAG=$(echo $(ref) | sed "s|refs/tags/v||g") + echo "##vso[task.setvariable variable=imageTag]$TAG" + else + LATESTTAG=$(git tag | tail -1) + LATESTVERS=${LATESTTAG#?} + if [ -z "$LATESTVERS" ]; then LATESTVERS=0.0.0; fi + echo "##vso[task.setvariable variable=imageTag]$LATESTVERS-b$(buildTag)" + fi + echo $(imageTag) + displayName: 'Set image tag' - task: Docker@2 displayName: 'Docker build' inputs: @@ -34,6 +48,7 @@ jobs: Dockerfile: "Dockerfile" tags: | $(buildTag) + $(imageTag) latest - task: Docker@2 @@ -45,10 +60,11 @@ jobs: Dockerfile: "Dockerfile" tags: | $(buildTag) + $(imageTag) latest - script: | - echo "gcr.io/${REPOSITORY}:${BUILDTAG}" > $(Build.ArtifactStagingDirectory)/docker-image.txt + echo "gcr.io/${REPOSITORY}:$(imageTag)" > $(Build.ArtifactStagingDirectory)/docker-image.txt displayName: 'Save Docker image name to artifact' - task: PublishPipelineArtifact@0 diff --git a/run.bash b/run.bash index e876dcd..9bce217 100755 --- a/run.bash +++ b/run.bash @@ -2,62 +2,58 @@ set -o noclobber -o nounset -TESTS=( "integration" "smoke" "iofogctl" "k4g" ) -TEST_COUNTS=() -TEST_COUNT=0 -FAILURES=0 -SKIPPED=0 +TEST_TOTAL_COUNT=0 +TEST_SUCCESS_COUNT=0 +TEST_SKIPPED_COUNT=0 +TEST_FAILURE_COUNT=0 function loadConfiguration() { - NAMESPACE="${NAMESPACE:-iofog}" CONTROLLER="${CONTROLLER:-}" - CONNECTOR="${CONNECTOR:-}" - CONTROLLER_HOST="" - CONTROLLER_EMAIL="${CONTROLLER_EMAIL:-user@domain.com}" - CONTROLLER_PASSWORD="${CONTROLLER_PASSWORD:-#Bugs4Fun}" - CONNECTOR_HOST="" - AGENTS="${AGENTS:-}" - AGENTS_ARR=() - - # TODO: (lkrcal) move this to k8s deployment (init containers or such), this script should not be k8s aware - CONTEXT=$(kubectl config current-context 2>/dev/null) - if [[ -n "${CONTEXT}" ]]; then - echo "Found kubernetes context, using ${CONTEXT} to retrieve configuration..." - CONTROLLER=$(kubectl -n "${NAMESPACE}" get svc controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}:{.spec.ports[0].port}') - CONNECTOR=$(kubectl -n "${NAMESPACE}" get svc connector -o jsonpath='{.status.loadBalancer.ingress[0].ip}:{.spec.ports[0].port}') - fi - - if [[ -n "${CONTROLLER}" ]]; then - CONTROLLER_HOST="http://${CONTROLLER}/api/v3" + AGENT_USER="${AGENT_USER:-}" + if [[ ! -z "${CONTROLLER}" ]]; then + # Controller informations provided + # Prefix Controller with http:// if needed + if [[ ${CONTROLLER} != "http"* ]]; then + CONTROLLER="http://${CONTROLLER}" + fi + CONTROLLER_EMAIL="${CONTROLLER_EMAIL:-user@domain.com}" + CONTROLLER_PASSWORD="${CONTROLLER_PASSWORD:-#Bugs4Fun}" + iofogctl connect --ecn-addr "${CONTROLLER}" --name controller --email "${CONTROLLER_EMAIL}" --pass "${CONTROLLER_PASSWORD}" + else + # iofogctl must be used + CONTROLLER="$(iofogctl describe controlplane | grep endpoint | awk '{print $2}')" + CONTROLLER_EMAIL="$(iofogctl describe controlplane | grep email | awk '{print $2}')" + CONTROLLER_PASSWORD="$(iofogctl describe controlplane | grep password | awk '{print $2}' | tr -d \' | base64 --decode)" fi - - if [[ -n "${CONNECTOR}" ]]; then - CONNECTOR_HOST="http://${CONNECTOR}/api/v2" + if [[ ! -z "${AGENT_USER}" ]]; then + iofogctl configure agents --user "${AGENT_USER}" --key "${AGENT_KEYFILE}" fi - - IFS=',' read -r -a AGENTS_ARR <<< "${AGENTS}" + CONTROLLER="${CONTROLLER:-$(iofogctl describe controlplane | grep endpoint | awk '{print $2}')}" + CONTROLLER_HOST="${CONTROLLER}/api/v3" + AGENTS=(${AGENTS:-$(iofogctl get agents | awk 'NR>=5 {print $1}' | sed '$d')}) echo "--- CONFIGURATION ---" echo -n "Controller: " - if [[ -n "${CONTROLLER}" ]]; then - echo -n "${CONTROLLER} (username: ${CONTROLLER_EMAIL}, password: $(echo "${CONTROLLER_PASSWORD}" | sed -r 's/./*/g'))" - fi - echo - echo -n "Connector: " - if [[ -n "${CONNECTOR}" ]]; then - echo -n "${CONNECTOR}" + if [[ -n "${CONTROLLER_HOST}" ]]; then + echo -n "${CONTROLLER_HOST} (username: ${CONTROLLER_EMAIL}, password: $(echo "${CONTROLLER_PASSWORD}" | sed -r 's/./*/g'))" fi echo echo -n "Agents: " - if [[ ${#AGENTS_ARR[@]} -gt 0 ]]; then - echo -n "${AGENTS_ARR[@]}" + if [[ ${#AGENTS[@]} -gt 0 ]]; then + echo -n "${AGENTS[@]}" fi echo } function checkController() { local CONTROLLER_HOST="$1" - local STATUS=$(curl --request GET --url "${CONTROLLER_HOST}/status" 2>/dev/null | jq -r ".status") + for IDX in $(seq 1 30); do + STATUS=$(curl --request GET --url "${CONTROLLER_HOST}/status" 2>/dev/null | jq -r ".status") + if [[ "${STATUS}" == "running" ]]; then + break + fi + sleep 1 + done if [[ "${STATUS}" != "online" ]]; then echo "Controller ${CONTROLLER_HOST} not ready..." echo "${STATUS}" @@ -66,28 +62,12 @@ function checkController() { echo "Controller ${CONTROLLER_HOST} is ready." } -function checkConnector() { - local CONNECTOR_HOST="$1" - local STATUS=$(curl --request POST --url "${CONNECTOR_HOST}/status" \ - --header 'Content-Type: application/x-www-form-urlencoded' --data mappingid=all 2>/dev/null \ - | jq -r '.status') - if [[ "${STATUS}" != "running" ]]; then - echo "Connector ${CONNECTOR_HOST} not ready..." - echo "${STATUS}" - exit 1 - fi - echo "Connector ${CONNECTOR_HOST} is ready." -} - function checkAgent() { local AGENT="$1" - local USERNAME_HOST="${AGENT%:*}" - local PORT="$(echo "${AGENT}" | cut -d':' -s -f2)" - local PORT="${PORT:-22}" - echo "Waiting for Agent ${USERNAME_HOST}:${PORT}..." - STATUS="$(ssh -o StrictHostKeyChecking=no "${USERNAME_HOST}" -p "${PORT}" sudo iofog-agent status | grep 'Connection to Controller')" + echo "Waiting for Agent ${AGENT}..." + STATUS="$(iofogctl legacy agent $AGENT status | grep 'Connection to Controller')" if [[ "${STATUS}" != *"ok"* ]]; then - echo "Agent ${USERNAME_HOST}:${PORT} not ready!" + echo "Agent $AGENT not ready!" echo "${STATUS}" exit 1 fi @@ -96,22 +76,31 @@ function checkAgent() { function printSuiteResult() { local SUITE_STATUS="$1" - ${TEST_COUNT}=${TEST_COUNT} + 1 if [[ "${SUITE_STATUS}" == "SKIPPED" ]]; then echo -n "SKIPPED" - ${SKIPPED}=${SKIPPED} + 1 elif [[ ${SUITE_STATUS} -eq 0 ]]; then echo -n "OK" else - ${FAILURES}=${FAILURES} + 1 echo -n "FAIL" fi } +function countSuiteResult() { + local SUITE_STATUS="$1" + TEST_TOTAL_COUNT=$((TEST_TOTAL_COUNT+1)) + if [[ "${SUITE_STATUS}" == "SKIPPED" ]]; then + TEST_SKIPPED_COUNT=$((TEST_SKIPPED_COUNT+1)) + elif [[ ${SUITE_STATUS} -eq 0 ]]; then + TEST_SUCCESS_COUNT=$((TEST_SUCCESS_COUNT+1)) + else + TEST_FAILURE_COUNT=$((TEST_FAILURE_COUNT+1)) + fi +} + function testSuiteControllerSmoke() { if [[ -n "${CONTROLLER_HOST}" ]] && [[ -n "${CONTROLLER_EMAIL}" ]] && [[ -n "${CONTROLLER_PASSWORD}" ]]; then echo "--- Running CONTROLLER SMOKE TEST SUITE ---" - pyresttest http://"${CONTROLLER}" tests/smoke/controller.yml + pyresttest "${CONTROLLER}" tests/smoke/controller.yml SUITE_CONTROLLER_SMOKE_STATUS=$? else echo "--- Skipping CONTROLLER SMOKE TEST SUITE ---" @@ -120,22 +109,8 @@ function testSuiteControllerSmoke() { fi } -function testSuiteConnectorSmoke() { - if [[ -n "${CONNECTOR_HOST}" ]]; then - echo "--- Running CONNECTOR SMOKE TEST SUITE ---" - pyresttest http://"${CONNECTOR}" tests/smoke/connector.yml - SUITE_CONNECTOR_SMOKE_STATUS=$? - else - echo "--- Skipping CONNECTOR SMOKE TEST SUITE ---" - echo "Insufficient configuration to run this test suite!" - SUITE_CONNECTOR_SMOKE_STATUS="SKIPPED" - fi -} - function testSuiteAgentsSmoke() { - TEST_COUNT_AGENT=$(bats -c tests/smoke/agent.bats) - TEST_COUNTS+=(${TEST_COUNT_AGENT}) - if [[ ${#AGENTS_ARR[@]} -gt 0 ]]; then + if [[ ${#AGENTS[@]} -gt 0 ]]; then echo "--- Running AGENT SMOKE TEST SUITE ---" bats tests/smoke/agent.bats SUITE_AGENT_SMOKE_STATUS=$? @@ -147,7 +122,7 @@ function testSuiteAgentsSmoke() { } function testSuiteBasicIntegration() { - if [[ ${#AGENTS_ARR[@]} -gt 0 ]] && [[ -n "${CONTROLLER_HOST}" ]] && [[ -n "${CONTROLLER_EMAIL}" ]] && [[ -n "${CONTROLLER_PASSWORD}" ]]; then + if [[ ${#AGENTS[@]} -gt 0 ]] && [[ -n "${CONTROLLER_HOST}" ]] && [[ -n "${CONTROLLER_EMAIL}" ]] && [[ -n "${CONTROLLER_PASSWORD}" ]]; then export CONTROLLER_EMAIL export CONTROLLER_PASSWORD @@ -155,9 +130,9 @@ function testSuiteBasicIntegration() { SUITE_BASIC_INTEGRATION_STATUS=0 # Spin up microservices - for IDX in "${!AGENTS_ARR[@]}"; do + for IDX in "${!AGENTS[@]}"; do export IDX - pyresttest http://"${CONTROLLER}" tests/integration/deploy-weather.yml + pyresttest "${CONTROLLER}" tests/integration/deploy-weather.yml if [[ "$?" -gt 0 ]]; then SUITE_BASIC_INTEGRATION_STATUS=1 fi @@ -180,9 +155,9 @@ function testSuiteBasicIntegration() { # pyresttest http://"$ENDPOINT" tests/integration/test-weather.yml ; (( ERR |= "$?" )) #done - for IDX in "${!AGENTS_ARR[@]}"; do + for IDX in "${!AGENTS[@]}"; do export IDX - pyresttest http://"${CONTROLLER}" tests/integration/destroy-weather.yml + pyresttest "${CONTROLLER}" tests/integration/destroy-weather.yml if [[ "$?" -gt 0 ]]; then SUITE_BASIC_INTEGRATION_STATUS=2 fi @@ -197,72 +172,65 @@ function testSuiteBasicIntegration() { function buildXML() { - MY_XML="${PWD}/tests/TEST-RESULTS.xml" - touch "${MY_XML}" - idx=0 - echo '' >> "$MY_XML" - echo "" >> "${MY_XML}" - for test_name in ${TESTS[@]}; do - echo "" >> "${MY_XML}" - idx+=1 - echo "" >> "${MY_XML}" - done + countSuiteResult "${SUITE_CONTROLLER_SMOKE_STATUS}" + countSuiteResult "${SUITE_AGENT_SMOKE_STATUS}" + countSuiteResult "${SUITE_BASIC_INTEGRATION_STATUS}" + countSuiteResult "${SUITE_KUBERNETES_STATUS}" + countSuiteResult "${SUITE_IOFOGCTL_STATUS}" + + if [[ ! -d "/root/test-results" ]]; then + echo "Directory /root/test-results/ does not exist (or is not mounted in Docker container). Cannot export JUnit XML test results!" + else + MY_XML="/root/test-results/TEST-RESULTS.xml" + rm -f "${MY_XML}" + echo "" > "${MY_XML}" + echo "" >> "${MY_XML}" + echo " " >> "${MY_XML}" + echo " " >> "${MY_XML}" + echo " " >> "${MY_XML}" + echo " " >> "${MY_XML}" + echo " " >> "${MY_XML}" echo "" >> "${MY_XML}" - - mv ${MY_XML} /root/test-results/. + fi } - loadConfiguration -[[ -n "${CONTROLLER}" ]] && checkController "${CONTROLLER_HOST}" -[[ -n "${CONNECTOR}" ]] && checkConnector "${CONNECTOR_HOST}" -for AGENT in "${AGENTS_ARR[@]}"; do checkAgent "${AGENT}"; done +checkController "${CONTROLLER_HOST}" +for AGENT in "${AGENTS[@]}"; do checkAgent "${AGENT}"; done testSuiteControllerSmoke testSuiteAgentsSmoke testSuiteBasicIntegration -# TODO: (Serge) Enable Connector tests when Connector is stable -# testSuiteConnectorSmoke -echo "--- Skipping CONNECTOR SMOKE TEST SUITE ---" -SUITE_CONNECTOR_SMOKE_STATUS="SKIPPED" - # TODO: (lkrcal) Enable these tests when ready for platform pipeline # TODO: (xaoc000) Ensure each of these get sub functions and do test_counting there #bats tests/k4g/k4g.bats -TEST_COUNT_K4G=$(bats -c tests/smoke/agent.bats) -TEST_COUNTS+=(${TEST_COUNT_K4G}) echo "--- Skipping KUBERNETES TEST SUITE ---" SUITE_KUBERNETES_STATUS="SKIPPED" # TODO: (lkrcal) Enable these tests when ready for platform pipeline -TEST_COUNT_CTL=$(bats -c tests/smoke/agent.bats) -TEST_COUNTS+=(${TEST_COUNT_CTL}) #bats tests/iofogctl/iofogctl.bats echo "--- Skipping IOFOGCTL TEST SUITE ---" SUITE_IOFOGCTL_STATUS="SKIPPED" - echo "--- Test Results: --- SUITE_CONTROLLER_SMOKE_STATUS: $( printSuiteResult "${SUITE_CONTROLLER_SMOKE_STATUS}") -SUITE_CONNECTOR_SMOKE_STATUS: $( printSuiteResult "${SUITE_CONNECTOR_SMOKE_STATUS}") SUITE_AGENT_SMOKE_STATUS: $( printSuiteResult "${SUITE_AGENT_SMOKE_STATUS}") SUITE_BASIC_INTEGRATION_STATUS: $( printSuiteResult "${SUITE_BASIC_INTEGRATION_STATUS}") SUITE_KUBERNETES_STATUS: $( printSuiteResult "${SUITE_KUBERNETES_STATUS}") SUITE_IOFOGCTL_STATUS: $( printSuiteResult "${SUITE_IOFOGCTL_STATUS}") " +buildXML + if [[ "${SUITE_CONTROLLER_SMOKE_STATUS}" =~ ^(0|SKIPPED)$ ]] && \ - [[ "${SUITE_CONNECTOR_SMOKE_STATUS}" =~ ^(0|SKIPPED)$ ]] && \ [[ "${SUITE_AGENT_SMOKE_STATUS}" =~ ^(0|SKIPPED)$ ]] && \ [[ "${SUITE_BASIC_INTEGRATION_STATUS}" =~ ^(0|SKIPPED)$ ]] && \ [[ "${SUITE_KUBERNETES_STATUS}" =~ ^(0|SKIPPED)$ ]] && \ [[ "${SUITE_IOFOGCTL_STATUS}" =~ ^(0|SKIPPED)$ ]]; then echo "--- SUCCESS ---" - buildXML exit 0 else echo "--- SOME TESTS FAILED ---" - buildXML exit 1 fi diff --git a/tests/functions.bash b/tests/functions.bash index b8044a6..dbf598c 100755 --- a/tests/functions.bash +++ b/tests/functions.bash @@ -4,10 +4,7 @@ function forAgentsOutputContains(){ local CMD="$1" local SUBSTR="$2" for AGENT in "${AGENTS[@]}"; do - local USERNAME_HOST="${AGENT%:*}" - local PORT="$(echo "${AGENT}" | cut -d':' -s -f2)" - local PORT="${PORT:-22}" - RESULT=$(ssh -o StrictHostKeyChecking=no "${USERNAME_HOST}" -p "${PORT}" "sudo $CMD") + local RESULT=$(iofogctl legacy agent $AGENT "$CMD") [[ "$RESULT" == *"$SUBSTR"* ]] done } @@ -15,10 +12,7 @@ function forAgentsOutputContains(){ function forAgents(){ local CMD="$1" for AGENT in "${AGENTS[@]}"; do - local USERNAME_HOST="${AGENT%:*}" - local PORT="$(echo "${AGENT}" | cut -d':' -s -f2)" - local PORT="${PORT:-22}" - ssh -o StrictHostKeyChecking=no "${USERNAME_HOST}" -p "${PORT}" "sudo $CMD" + iofogctl legacy agent $AGENT "$CMD" [[ $? == 0 ]] done } diff --git a/tests/iofogctl/iofogctl.yml b/tests/iofogctl/iofogctl.yml deleted file mode 100644 index 9d63794..0000000 --- a/tests/iofogctl/iofogctl.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Test connecting to iofog-connector via HTTP -# - ---- -- config: - - testset: "Testing iofogctl REST Calls" - - timeout: 600000 # 10 seconds - -- test: - - name: "Add Public Pipe" - - group: "Connector" - - url: "/api/v2/mapping/add" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - method: 'POST' - - body: "mapping={'type':'public','maxconnections':60,'heartbeatabsencethreshold':200000}" - - expected_status: [200] - - extract_binds: - - 'public_id': {'jsonpath_mini': 'id'} - -- test: - - name: "Add Private Pipe" - - group: "Connector" - - url: "/api/v2/mapping/add" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - method: 'POST' - - body: "mapping={'type':'private','maxconnectionsport1':1, 'maxconnectionsport2':1, 'heartbeatabsencethresholdport1':200000, 'heartbeatabsencethresholdport2':200000}" - - expected_status: [200] - - extract_binds: - - 'private_id': {'jsonpath_mini': 'id'} - -- test: - - name: "Remove Public Pipe" - - group: "Connector" - - url: "api/v2/mapping/remove" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$public_id"} - - method: 'POST' - - expected_status: [200] - -- test: - - name: "Remove Private Pipe" - - group: "Connector" - - url: {'template':"/api/v2/mapping/remove"} - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$private_id"} - - method: 'POST' - - expected_status: [200] - -- test: - - name: "Remove Non-existent Public Pipe" - - group: "Connector" - - url: "api/v2/mapping/remove" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$public_id"} - - method: 'POST' - - expected_status: [404] - -- test: - - name: "Remove Non-existent Private Pipe" - - group: "Connector" - - url: {'template':"/api/v2/mapping/remove"} - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$private_id"} - - method: 'POST' - - expected_status: [404] \ No newline at end of file diff --git a/tests/smoke/agent.bats b/tests/smoke/agent.bats index debf5c1..0f3ea35 100755 --- a/tests/smoke/agent.bats +++ b/tests/smoke/agent.bats @@ -4,12 +4,8 @@ #importAgents -@test "Checking SSH Connection" { - forAgents "echo Connected" -} - @test "Checking Agents Statuses" { - forAgents "iofog-agent status" + forAgents "status" } # TODO: (Serge) Interface names changes based on deployment, rewrite this test @@ -18,35 +14,35 @@ #} @test "iofog-agent version" { - forAgentsOutputContains "iofog-agent version" "ioFog" + forAgentsOutputContains "version" "ioFog" } @test "iofog-agent info" { - forAgentsOutputContains "iofog-agent info" "Iofog UUID" + forAgentsOutputContains "info" "Iofog UUID" } @test "iofog-agent provision BAD" { - forAgentsOutputContains "iofog-agent provision asd" "Invalid Provisioning Key" + forAgentsOutputContains "provision asd" "Invalid Provisioning Key" } @test "iofog-agent config INVALID RAM" { - forAgentsOutputContains "iofog-agent config -m 50" "Memory limit range" + forAgentsOutputContains "config -m 50" "Memory limit range" } @test "iofog-agent config RAM string" { - forAgentsOutputContains "iofog-agent config -m test" "invalid value" + forAgentsOutputContains "config -m test" "invalid value" } @test "iofog-agent config VALID RAM" { - forAgentsOutputContains "iofog-agent config -m 1024" "New Value" + forAgentsOutputContains "config -m 1024" "New Value" } # Test that the SSH connection to Agents is Valid @test "Integration Test UUID is Available" { - forAgentsOutputContains "iofog-agent info | grep UUID" "UUID" + forAgentsOutputContains "info | grep UUID" "UUID" } # Test that the SSH connection to Agents is Valid @test "Integration Test Connection to Controller" { - forAgentsOutputContains "iofog-agent status | grep 'Connection to Controller'" "ok" + forAgentsOutputContains "status | grep 'Connection to Controller'" "ok" } diff --git a/tests/smoke/connector.yml b/tests/smoke/connector.yml deleted file mode 100644 index 059eadd..0000000 --- a/tests/smoke/connector.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Test connecting to iofog-connector via HTTP -# - ---- -- config: - - testset: "Testing connection to iofog-connector via REST API" - - timeout: 600000 # 10 seconds - -- test: - - name: "Add Public Pipe" - - group: "Connector" - - url: "/api/v2/mapping/add" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - method: 'POST' - - body: "mapping={'type':'public','maxconnections':60,'heartbeatabsencethreshold':200000}" - - expected_status: [200] - - extract_binds: - - 'public_id': {'jsonpath_mini': 'id'} - -- test: - - name: "Add Private Pipe" - - group: "Connector" - - url: "/api/v2/mapping/add" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - method: 'POST' - - body: "mapping={'type':'private','maxconnectionsport1':1, 'maxconnectionsport2':1, 'heartbeatabsencethresholdport1':200000, 'heartbeatabsencethresholdport2':200000}" - - expected_status: [200] - - extract_binds: - - 'private_id': {'jsonpath_mini': 'id'} - -- test: - - name: "Remove Public Pipe" - - group: "Connector" - - url: "api/v2/mapping/remove" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$public_id"} - - method: 'POST' - - expected_status: [200] - -- test: - - name: "Remove Private Pipe" - - group: "Connector" - - url: {'template':"/api/v2/mapping/remove"} - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$private_id"} - - method: 'POST' - - expected_status: [200] - -- test: - - name: "Remove Non-existent Public Pipe" - - group: "Connector" - - url: "api/v2/mapping/remove" - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$public_id"} - - method: 'POST' - - expected_status: [404] - -- test: - - name: "Remove Non-existent Private Pipe" - - group: "Connector" - - url: {'template':"/api/v2/mapping/remove"} - - headers: {'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache'} - - body: {'template':"mappingid=$private_id"} - - method: 'POST' - - expected_status: [404] \ No newline at end of file