blob: 05f6451e8522dd7794063c6b7434adb4b2302579 [file] [log] [blame]
Scott Baker50421662016-06-27 22:09:48 -07001include ../common/Makedefs
2
3MYIP:=$(shell hostname -i)
4CONFIG_DIR:=$(shell pwd)
5DOCKER_COMPOSE_YML=./onboarding-docker-compose/docker-compose.yml
6BOOTSTRAP_YML=./docker-compose-bootstrap.yml
7DOCKER_PROJECT=teststandalone
8BOOTSTRAP_PROJECT=teststandalonebs
9XOS_BOOTSTRAP_PORT=9998
10XOS_UI_PORT=9999
11DB_NAME=$(BOOTSTRAP_PROJECT)_xos_db_1
12
13define TRUNCATE_FN
14 CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$$$
15 DECLARE
16 statements CURSOR FOR
17 SELECT tablename FROM pg_tables
18 WHERE tableowner = username AND schemaname = 'public';
19 BEGIN
20 FOR stmt IN statements LOOP
21 EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
22 END LOOP;
23 END;
24 $$$$ LANGUAGE plpgsql;
25endef
26export TRUNCATE_FN
27
28prepare: xos
29 sudo docker exec -i teststandalone_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm install --production"
30 sudo docker exec teststandalone_xos_ui_1 pip install dredd_hooks
31
Scott Bakerbda441d2016-06-28 14:14:31 -070032xos: prereqs dirs download_xos download_services bootstrap onboarding
Scott Baker50421662016-06-27 22:09:48 -070033
34prereqs:
35 sudo make -f ../common/Makefile.prereqs
36
37dirs:
38 # if this directory doesn't exist, then docker-compose will create it with root permission
39 mkdir -p key_import
40 mkdir -p onboarding-docker-compose
41
42bootstrap:
43 echo "[BOOTSTRAP]"
44 sudo rm -f onboarding-docker-compose/docker-compose.yml
45 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
46 bash ../common/wait_for_xos_port.sh 9998
47 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
48
Scott Bakerbda441d2016-06-28 14:14:31 -070049download_xos:
50 make -f ../common/Makefile.services xos_core
51
Scott Baker50421662016-06-27 22:09:48 -070052download_services:
53 make -f ../common/Makefile.services
54
55update_services:
56 make -f ../common/Makefile.services update
57
58onboarding:
59 echo "[ONBOARDING]"
60 bash ../common/wait_for_onboarding_ready.sh 9998 xos
Scott Baker7ab02212016-06-29 14:12:15 -070061 bash -c "echo somekey > key_import/vsg_rsa"
62 bash -c "echo somekey > key_import/vsg_rsa.pub"
63 bash -c "echo somekey > key_import/volt_rsa"
64 bash -c "echo somekey > key_import/volt_rsa.pub"
65 bash -c "echo somekey > key_import/onos_rsa"
66 bash -c "echo somekey > key_import/onos_rsa.pub"
Scott Baker50421662016-06-27 22:09:48 -070067 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/disable-onboarding.yaml
68 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
69 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
70 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
71 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
72 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
73 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/enable-onboarding.yaml
74 bash ../common/wait_for_onboarding_ready.sh 9998 services/vrouter
75 bash ../common/wait_for_onboarding_ready.sh 9998 services/volt
76 bash ../common/wait_for_onboarding_ready.sh 9998 services/vsg
77 bash ../common/wait_for_onboarding_ready.sh 9998 services/vtr
78 bash ../common/wait_for_onboarding_ready.sh 9998 services/onos
79 bash ../common/wait_for_onboarding_ready.sh 9998 xos
80 bash ../common/wait_for_xos_port.sh 9999
81
82restore-initial-db-status:
83 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "$$TRUNCATE_FN" >/dev/null 2>&1
84 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT truncate_tables('postgres');" >/dev/null 2>&1
85 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_tenant_id_seq', 1)" >/dev/null 2>&1
86 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_deployment_id_seq', 1)" >/dev/null 2>&1
87 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_flavor_id_seq', 1)" >/dev/null 2>&1
88 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_service_id_seq', 1)" >/dev/null 2>&1
89 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/manage.py --noobserver --nomodelpolicy loaddata /opt/xos/core/fixtures/core_initial_data.json
90 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/fixtures.yaml
91 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/mydeployment.yaml
92 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < ../frontend/sample.yaml
93
94 # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/setup.yaml
95 # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/nodes.yaml
96 # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/images.yaml
97 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < ../cord-pod/mgmt-net.yaml
98 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < services.yaml
99 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < ../cord-pod/cord-volt-devices.yaml
100
101
102test: restore-initial-db-status
103 # RUN TESTS
104 sudo docker cp $(XOS_DIR)/apiary.apib teststandalone_xos_ui_1:/opt/xos/tests/api/apiary.apib
105 sudo docker exec -i teststandalone_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm test"
106
107test-tosca: restore-initial-db-status
108 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui bash -c "cd /opt/xos/tosca/tests; python ./alltests.py"
109
110test-ui: restore-initial-db-status
111 sudo docker exec -u root -i teststandalone_xos_1 bash -c "cd /opt/xos/tests/ui-e2e; python xos-e2e-test.py"
112
113base-container:
114 make -f ../common/Makefile.containers xos_base
115
116devel-container: base-container
117 make -f ../common/Makefile.containers xos_devel synchronizer onboarding_synchronizer
118
Scott Bakerbda441d2016-06-28 14:14:31 -0700119containers: prereqs download_xos devel-container
Scott Baker50421662016-06-27 22:09:48 -0700120 make -f ../common/Makefile.containers xos_test
121
122stop:
123 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
124 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
125
126showlogs:
Scott Bakercada1982016-06-30 15:26:16 -0700127 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs
128
129showlogs_bootstrap:
130 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs
Scott Baker50421662016-06-27 22:09:48 -0700131
132rm: stop
133 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
134 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
135
136docker-clean:
137 sudo docker rm -f $(shell sudo docker ps -aq)
138
139enter-xos:
140 sudo docker exec -ti teststandalone_xos_ui_1 bash
141
142enter-xos-db:
143 sudo docker exec -ti $(DB_NAME) bash