blob: ecd5f7e921b236a0e4a607d5835e4654f2334bad [file] [log] [blame]
Zack Williams3670f442016-10-04 17:37:12 -07001# test-standalone/Makefile
Scott Baker50421662016-06-27 22:09:48 -07002
Zack Williams3670f442016-10-04 17:37:12 -07003CONFIG_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
4COMMON_DIR := $(abspath ../common )
5
6.DEFAULT_GOAL := prepare
7
8DOCKER_PROJECT ?= teststandalone
9BOOTSTRAP_PROJECT ?= teststandalonebs
10
Matteo Scandoloa317b872017-01-10 12:02:41 -080011XOS_BOOTSTRAP_PORT ?= 9001
12XOS_UI_PORT ?= 9000
Zack Williams3670f442016-10-04 17:37:12 -070013
14DB_NAME ?= $(BOOTSTRAP_PROJECT)_xos_db_1
15
16# Include common functions
17include $(COMMON_DIR)/Makefile
Scott Baker50421662016-06-27 22:09:48 -070018
19define 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;
31endef
32export TRUNCATE_FN
33
34prepare: xos
Zack Williams3670f442016-10-04 17:37:12 -070035 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 Baker50421662016-06-27 22:09:48 -070037
Scott Baker62d24282016-10-21 09:19:11 -070038xos: prereqs config_dirs xos_download cord_services cord_libraries test_bootstrap onboarding
Scott Baker50421662016-06-27 22:09:48 -070039
Zack Williams3670f442016-10-04 17:37:12 -070040test_bootstrap:
41 @echo "[TEST_BOOTSTRAP]"
Scott Baker50421662016-06-27 22:09:48 -070042 sudo rm -f onboarding-docker-compose/docker-compose.yml
43 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
Zack Williams3670f442016-10-04 17:37:12 -070044 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Scott Baker50421662016-06-27 22:09:48 -070045 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 Baker50421662016-06-27 22:09:48 -070047onboarding:
Scott Bakerc5e2f3c2016-07-11 11:48:06 -070048 @echo "[ONBOARDING]"
Zack Williams3670f442016-10-04 17:37:12 -070049 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
Scott Baker7ab02212016-06-29 14:12:15 -070050 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 Williams3670f442016-10-04 17:37:12 -070056 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 Bakerda3b1592016-10-24 10:45:36 -070057 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 Baker50421662016-06-27 22:09:48 -070058 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 Williams3670f442016-10-04 17:37:12 -070063 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 Bakerda3b1592016-10-24 10:45:36 -070064 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/ng-xos-lib
Zack Williams3670f442016-10-04 17:37:12 -070065 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 Baker50421662016-06-27 22:09:48 -070072
73restore-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 Baker21dc9692016-08-15 14:15:53 -070080 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 Williams3670f442016-10-04 17:37:12 -070081 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 Baker50421662016-06-27 22:09:48 -070090
91test: restore-initial-db-status
92 # RUN TESTS
Zack Williams3670f442016-10-04 17:37:12 -070093 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 Baker50421662016-06-27 22:09:48 -070095
96test-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
99test-ui: restore-initial-db-status
Zack Williams3670f442016-10-04 17:37:12 -0700100 sudo docker exec -u root -i $(DOCKER_PROJECT)_xos_1 bash -c "cd /opt/xos/tests/ui-e2e; python xos-e2e-test.py"
Scott Baker50421662016-06-27 22:09:48 -0700101