Skip to content

Commit

Permalink
Add Controller and Connector smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeRadinovich committed Apr 25, 2019
1 parent f36d272 commit 886a0f5
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 49 deletions.
6 changes: 4 additions & 2 deletions README.md
@@ -1,3 +1,5 @@
# demo
# Usage

FIX ME!
```
./run-smoke-tests.sh
```
2 changes: 2 additions & 0 deletions docker-compose.yml
Expand Up @@ -31,6 +31,8 @@ services:
container_name: iofog-agent
depends_on:
- iofog-controller
ports:
- "54321:54321"
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
4 changes: 3 additions & 1 deletion run-smoke-tests.sh
Expand Up @@ -8,4 +8,6 @@ docker-compose -f docker-compose.yml -f docker-compose-test.yml up \
--abort-on-container-exit \
--exit-code-from test-runner

echo $?
echo $?

docker-compose down
19 changes: 7 additions & 12 deletions test-runner/run-tests.sh
@@ -1,29 +1,24 @@
#!/usr/bin/env bash

# Our test suite config
CONTROLLER_HOST="http://iofog-controller:51121"
TEST_SUITE="tests/demo-test-suite.yml"

#
# Wait until we can connect to a url given in $1
#
function waitFor() {

# Can we connect?
echo "Waiting for $1"
until $(curl --output /dev/null --silent --head --connect-to --url ${1}); do
printf '.'
sleep 2
done
echo "$1 is up"
}


# Wait until Controller has come up
echo "Waiting for Controller to start"
waitFor ${CONTROLLER_HOST}
for HOST in http://iofog-controller:51121 http://iofog-connector:8080 http://iofog-agent:54321 ; do
waitFor "$HOST"
done

echo "Beginning Test Runner Smoke tests.."
python --version
pyresttest ${CONTROLLER_HOST} tests/demo-test-suite.yml

echo "Test Runner Smoke tests Complete"
pyresttest http:// tests/demo-test-suite.yml #--log debug

echo "Test Runner Smoke tests Complete"
39 changes: 35 additions & 4 deletions test-runner/tests/connector-smoke-tests.yml
Expand Up @@ -6,7 +6,38 @@
- config:
- testset: "Testing connection to iofog-connector via REST API"

# FINISH ME
#- test:
# - name: "Check Connection"
# - group: "Controller"
- test:
- name: "Add Public Pipe"
- group: "Connector"
- url: "iofog-connector:8080/api/v2/mapping/add?mapping={'type':'public','maxconnections':60,'heartbeatabsencethreshold':200000}"
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- method: 'POST'
- expected_status: [200]
- extract_binds:
- 'public_id': {'jsonpath_mini': 'id'}

- test:
- name: "Add Private Pipe"
- group: "Connector"
- url: "iofog-connector:8080/api/v2/mapping/add?mapping={'type':'private','maxconnectionsport1':1, 'maxconnectionsport2':1, 'heartbeatabsencethresholdport1':200000, 'heartbeatabsencethresholdport2':200000}"
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- method: 'POST'
- expected_status: [200]
- extract_binds:
- 'private_id': {'jsonpath_mini': 'id'}

- test:
- name: "Remove Public Pipe"
- group: "Connector"
- url: {'template':"iofog-connector:8080/api/v2/remove?mappingid=$public_id"}
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- method: 'POST'
- expected_status: [200]

- test:
- name: "Remove Private Pipe"
- group: "Connector"
- url: {'template':"iofog-connector:8080/api/v2/remove?mappingid=$private_id"}
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- method: 'POST'
- expected_status: [200]
138 changes: 113 additions & 25 deletions test-runner/tests/controller-smoke-tests.yml
Expand Up @@ -10,49 +10,137 @@
- test:
- name: "Non Auth Connection"
- group: "Controller"
- url: "/api/v3/iofog"
- url: "iofog-controller:51121/api/v3/iofog"
- expected_status: [404]

- test:
- name: "Test Status"
- name: "Get Status"
- group: "Controller"
- url: "/api/v3/status"
- url: "iofog-controller:51121/api/v3/status"
- headers: {'Content-Type': 'application/json'}
- method: 'POST'
- method: 'GET'
- expected_status: [200]

- test:
- name: "Create User"
- name: "Get Email Activation"
- group: "Controller"
- url: "/api/v3/status"
- url: "iofog-controller:51121/api/v3/email-activation"
- headers: {'Content-Type': 'application/json'}
- method: 'POST'
- body: '{"email":"user@domain.com","password":"#Bugs4Fun"}'
- expected_status: [201]
- method: 'GET'
- expected_status: [200]

- test:
- name: "Authentication using basic auth"
- name: "Get Fog Types"
- group: "Controller"
- url: "/api/v3/user/login"
- url: "iofog-controller:51121/api/v3/fog-types"
- headers: {'Content-Type': 'application/json'}
- method: 'POST'
- body: '{"email":"user@domain.com","password":"#Bugs4Fun"}'
- method: 'GET'
- expected_status: [200]

- test:
- name: "Authentication using basic auth"
- group: "Controller"
- url: "/api/v3/user/profile"
- name: "Sign up"
- group: "User"
- url: "iofog-controller:51121/api/v3/user/signup"
- headers: {'Content-Type': 'application/json'}
- method: 'POST'
- body: '{"email":"user@domain.com","password":"#Bugs4Fun"}'
- expected_status: [200]
- body: '{"firstName":"Serge","lastName":"Radinovich","email":"serge@edgeworx.io","password":"123pwer89iu23409i"}'
- method: "POST"
- expected_status: [201]

- test:
- name: "Authentication using basic auth"
- group: "Controller"
- url: "/api/v3/user/profile"
- name: "Login"
- group: "User"
- url: "iofog-controller:51121/api/v3/user/login"
- headers: {'Content-Type': 'application/json'}
- method: 'POST'
- body: '{"Authorization":""}'
- expected_status: [200]
- body: '{"email":"serge@edgeworx.io","password":"123pwer89iu23409i"}'
- method: "POST"
- expected_status: [200]
- extract_binds:
- 'accessToken': {'jsonpath_mini': 'accessToken'}

- test:
- name: "Get Profile"
- group: "User"
- url: "iofog-controller:51121/api/v3/user/profile"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "GET"
- expected_status: [200]

- test:
- name: "Get Flow"
- group: "Flow"
- url: "iofog-controller:51121/api/v3/flow"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "GET"
- expected_status: [200]

- test:
- name: "Get Iofog Node List"
- group: "Iofog"
- url: "iofog-controller:51121/api/v3/iofog-list"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "GET"
- expected_status: [200]

# TODO: Need agent details first
#- test:
# - name: "Create a new ioFog node"
# - group: "Iofog"
# - url: "iofog-controller:51121/api/v3/iofog"
# - headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
# - body: '{ "fogType": { "id": 1, "name": "Standard Linux (x86)", "image": "iointegrator1.png", "description": "A standard Linux server of at least moderate processing power and capacity. Compatible with common Linux types such as Ubuntu, Red Hat, and CentOS." } }'
# - method: "POST"
# - expected_status: [200]
#
# TODO: Need to register agent first
#- test:
# - name: "Get Iofog Node Info"
# - group: "Iofog"
# - url: {'template':"iofog-controller:51121/api/v3/iofog/$node_id"}
# - headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
# - method: "GET"
# - expected_status: [200]

- test:
- name: "Create Agent Node"
- group: "Iofog"
- url: "iofog-controller:51121/api/v3/iofog"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- body: '{"name":"agent-smith","fogType":0}'
- method: "POST"
- extract_binds:
- 'uuid': {'jsonpath_mini': 'uuid'}
- expected_status: [201]

- test:
- name: "Provision Key for Agent"
- group: "Iofog"
- url: {'template':"iofog-controller:51121/api/v3/iofog/$uuid/provisioning-key"}
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "GET"
- extract_binds:
- 'key': {'jsonpath_mini': 'key'}
- expected_status: [201]

- test:
- name: "Get Microservices Catalog"
- group: "Catalog"
- url: "iofog-controller:51121/api/v3/catalog/microservices"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "GET"
- expected_status: [200]

- test:
- name: "Get Registries"
- group: "Registries"
- url: "iofog-controller:51121/api/v3/registries"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "GET"
- expected_status: [200]

- test:
- name: "Log out"
- group: "User"
- url: "iofog-controller:51121/api/v3/user/logout"
- headers: {template:{'Content-Type': 'application/json', 'Authorization': "$accessToken"}}
- method: "POST"
- expected_status: [204]
5 changes: 0 additions & 5 deletions test-runner/tests/demo-test-suite.yml
Expand Up @@ -14,11 +14,6 @@
- url: "/api/v3/iofog"
- expected_status: [404]

# Import our Controller Tests
- import: tests/controller-smoke-tests.yml

# Import our Connector Tests
- import: tests/connector-smoke-tests.yml

# Import our Connector Tests
- import: tests/agent-smoke-tests.yml

0 comments on commit 886a0f5

Please sign in to comment.