blob: 147011ed7bc8de00ad3b0b3e508c0f390d35c6e6 [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
11XOS_BOOTSTRAP_PORT ?= 9998
12XOS_UI_PORT ?= 9999
13
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 Baker50421662016-06-27 22:09:48 -070057 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
58 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
59 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
60 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
61 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 -070062 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
63 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/vrouter
64 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/volt
65 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/vsg
66 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/vtr
67 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) services/onos
68 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
69 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
Scott Baker50421662016-06-27 22:09:48 -070070
71restore-initial-db-status:
72 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "$$TRUNCATE_FN" >/dev/null 2>&1
73 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT truncate_tables('postgres');" >/dev/null 2>&1
74 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_tenant_id_seq', 1)" >/dev/null 2>&1
75 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_deployment_id_seq', 1)" >/dev/null 2>&1
76 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_flavor_id_seq', 1)" >/dev/null 2>&1
77 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 -070078 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 -070079 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
80 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
81 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py $(ADMIN_USERNAME) - < ../frontend/sample.yaml
82 # sudo docker-compose run xos python /opt/xos/tosca/run.py $(ADMIN_USERNAME) /opt/xos/configurations/cord-pod/setup.yaml
83 # sudo docker-compose run xos python /opt/xos/tosca/run.py $(ADMIN_USERNAME) /opt/xos/configurations/cord-pod/nodes.yaml
84 # sudo docker-compose run xos python /opt/xos/tosca/run.py $(ADMIN_USERNAME) /opt/xos/configurations/cord-pod/images.yaml
85 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
86 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py $(ADMIN_USERNAME) - < services.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/cord-volt-devices.yaml
Scott Baker50421662016-06-27 22:09:48 -070088
89test: restore-initial-db-status
90 # RUN TESTS
Zack Williams3670f442016-10-04 17:37:12 -070091 sudo docker cp $(XOS_DIR)/apiary.apib $(DOCKER_PROJECT)_xos_ui_1:/opt/xos/tests/api/apiary.apib
92 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 -070093
94test-tosca: restore-initial-db-status
95 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui bash -c "cd /opt/xos/tosca/tests; python ./alltests.py"
96
97test-ui: restore-initial-db-status
Zack Williams3670f442016-10-04 17:37:12 -070098 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 -070099