Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 1 | # test-standalone/Makefile |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 2 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 3 | CONFIG_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) |
| 4 | COMMON_DIR := $(abspath ../common ) |
| 5 | |
| 6 | .DEFAULT_GOAL := prepare |
| 7 | |
| 8 | DOCKER_PROJECT ?= teststandalone |
| 9 | BOOTSTRAP_PROJECT ?= teststandalonebs |
| 10 | |
Matteo Scandolo | a317b87 | 2017-01-10 12:02:41 -0800 | [diff] [blame] | 11 | XOS_BOOTSTRAP_PORT ?= 9001 |
| 12 | XOS_UI_PORT ?= 9000 |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 13 | |
| 14 | DB_NAME ?= $(BOOTSTRAP_PROJECT)_xos_db_1 |
| 15 | |
| 16 | # Include common functions |
| 17 | include $(COMMON_DIR)/Makefile |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 18 | |
| 19 | define TRUNCATE_FN |
| 20 | CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$$$ |
| 21 | DECLARE |
| 22 | statements CURSOR FOR |
| 23 | SELECT tablename FROM pg_tables |
| 24 | WHERE tableowner = username AND schemaname = 'public'; |
| 25 | BEGIN |
| 26 | FOR stmt IN statements LOOP |
| 27 | EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; |
| 28 | END LOOP; |
| 29 | END; |
| 30 | $$$$ LANGUAGE plpgsql; |
| 31 | endef |
| 32 | export TRUNCATE_FN |
| 33 | |
| 34 | prepare: xos |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 35 | sudo docker exec -i $(DOCKER_PROJECT)_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm install --production" |
| 36 | sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 pip install dredd_hooks |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 37 | |
Scott Baker | 62d2428 | 2016-10-21 09:19:11 -0700 | [diff] [blame] | 38 | xos: prereqs config_dirs xos_download cord_services cord_libraries test_bootstrap onboarding |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 39 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 40 | test_bootstrap: |
| 41 | @echo "[TEST_BOOTSTRAP]" |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 42 | sudo rm -f onboarding-docker-compose/docker-compose.yml |
| 43 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 44 | bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT) |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 45 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run -e CONFIG_DIR=$(CONFIG_DIR) xos_bootstrap_ui python /opt/xos/tosca/run.py none - < xos.yaml |
| 46 | |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 47 | onboarding: |
Scott Baker | c5e2f3c | 2016-07-11 11:48:06 -0700 | [diff] [blame] | 48 | @echo "[ONBOARDING]" |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 49 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
Scott Baker | 7ab0221 | 2016-06-29 14:12:15 -0700 | [diff] [blame] | 50 | bash -c "echo somekey > key_import/vsg_rsa" |
| 51 | bash -c "echo somekey > key_import/vsg_rsa.pub" |
| 52 | bash -c "echo somekey > key_import/volt_rsa" |
| 53 | bash -c "echo somekey > key_import/volt_rsa.pub" |
| 54 | bash -c "echo somekey > key_import/onos_rsa" |
| 55 | bash -c "echo somekey > key_import/onos_rsa.pub" |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 56 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(COMMON_DIR)/tosca/disable-onboarding.yaml |
Scott Baker | da3b159 | 2016-10-24 10:45:36 -0700 | [diff] [blame] | 57 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(LIBRARY_DIR)/ng-xos-lib/ng-xos-lib-onboard.yaml |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 58 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(SERVICE_DIR)/vrouter/xos/vrouter-onboard.yaml |
| 59 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(SERVICE_DIR)/olt/xos/volt-onboard.yaml |
| 60 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(SERVICE_DIR)/vsg/xos/vsg-onboard.yaml |
| 61 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(SERVICE_DIR)/vtr/xos/vtr-onboard.yaml |
| 62 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(SERVICE_DIR)/onos-service/xos/onos-onboard.yaml |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 63 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < $(COMMON_DIR)/tosca/enable-onboarding.yaml |
Scott Baker | da3b159 | 2016-10-24 10:45:36 -0700 | [diff] [blame] | 64 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/ng-xos-lib |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 65 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/vrouter |
| 66 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/volt |
| 67 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/vsg |
| 68 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/vtr |
| 69 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/onos |
| 70 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
| 71 | bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT) |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 72 | |
| 73 | restore-initial-db-status: |
| 74 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "$$TRUNCATE_FN" >/dev/null 2>&1 |
| 75 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT truncate_tables('postgres');" >/dev/null 2>&1 |
| 76 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_tenant_id_seq', 1)" >/dev/null 2>&1 |
| 77 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_deployment_id_seq', 1)" >/dev/null 2>&1 |
| 78 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_flavor_id_seq', 1)" >/dev/null 2>&1 |
| 79 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_service_id_seq', 1)" >/dev/null 2>&1 |
Scott Baker | 21dc969 | 2016-08-15 14:15:53 -0700 | [diff] [blame] | 80 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/manage.py --noobserver loaddata /opt/xos/core/fixtures/core_initial_data.json |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 81 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < $(COMMON_DIR)/tosca/fixtures.yaml |
| 82 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < $(COMMON_DIR)/tosca/mydeployment.yaml |
| 83 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py $(ADMIN_USERNAME) - < ../frontend/sample.yaml |
| 84 | # sudo docker-compose run xos python /opt/xos/tosca/run.py $(ADMIN_USERNAME) /opt/xos/configurations/cord-pod/setup.yaml |
| 85 | # sudo docker-compose run xos python /opt/xos/tosca/run.py $(ADMIN_USERNAME) /opt/xos/configurations/cord-pod/nodes.yaml |
| 86 | # sudo docker-compose run xos python /opt/xos/tosca/run.py $(ADMIN_USERNAME) /opt/xos/configurations/cord-pod/images.yaml |
| 87 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py $(ADMIN_USERNAME) - < $(COMMON_DIR)/tosca/mgmt-net.yaml |
| 88 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py $(ADMIN_USERNAME) - < services.yaml |
| 89 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py $(ADMIN_USERNAME) - < $(COMMON_DIR)/tosca/cord-volt-devices.yaml |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 90 | |
| 91 | test: restore-initial-db-status |
| 92 | # RUN TESTS |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 93 | sudo docker cp $(XOS_DIR)/apiary.apib $(DOCKER_PROJECT)_xos_ui_1:/opt/xos/tests/api/apiary.apib |
| 94 | sudo docker exec -i $(DOCKER_PROJECT)_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm test" |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 95 | |
| 96 | test-tosca: restore-initial-db-status |
| 97 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui bash -c "cd /opt/xos/tosca/tests; python ./alltests.py" |
| 98 | |
| 99 | test-ui: restore-initial-db-status |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 100 | sudo docker exec -u root -i $(DOCKER_PROJECT)_xos_1 bash -c "cd /opt/xos/tests/ui-e2e; python xos-e2e-test.py" |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 101 | |