blob: 44a53633f1d0af12307761ec29cd214429c4f420 [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
Scott Baker1b29f972016-07-01 09:20:58 -070058update_xos:
59 make -f ../common/Makefile.services update_xos
60
Scott Baker50421662016-06-27 22:09:48 -070061onboarding:
62 echo "[ONBOARDING]"
63 bash ../common/wait_for_onboarding_ready.sh 9998 xos
Scott Baker7ab02212016-06-29 14:12:15 -070064 bash -c "echo somekey > key_import/vsg_rsa"
65 bash -c "echo somekey > key_import/vsg_rsa.pub"
66 bash -c "echo somekey > key_import/volt_rsa"
67 bash -c "echo somekey > key_import/volt_rsa.pub"
68 bash -c "echo somekey > key_import/onos_rsa"
69 bash -c "echo somekey > key_import/onos_rsa.pub"
Scott Baker50421662016-06-27 22:09:48 -070070 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/disable-onboarding.yaml
71 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
72 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
73 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
74 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
75 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
76 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/enable-onboarding.yaml
77 bash ../common/wait_for_onboarding_ready.sh 9998 services/vrouter
78 bash ../common/wait_for_onboarding_ready.sh 9998 services/volt
79 bash ../common/wait_for_onboarding_ready.sh 9998 services/vsg
80 bash ../common/wait_for_onboarding_ready.sh 9998 services/vtr
81 bash ../common/wait_for_onboarding_ready.sh 9998 services/onos
82 bash ../common/wait_for_onboarding_ready.sh 9998 xos
83 bash ../common/wait_for_xos_port.sh 9999
84
85restore-initial-db-status:
86 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "$$TRUNCATE_FN" >/dev/null 2>&1
87 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT truncate_tables('postgres');" >/dev/null 2>&1
88 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_tenant_id_seq', 1)" >/dev/null 2>&1
89 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_deployment_id_seq', 1)" >/dev/null 2>&1
90 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_flavor_id_seq', 1)" >/dev/null 2>&1
91 sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_service_id_seq', 1)" >/dev/null 2>&1
92 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
93 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/fixtures.yaml
94 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/mydeployment.yaml
95 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
96
97 # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/setup.yaml
98 # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/nodes.yaml
99 # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/images.yaml
100 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
101 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < services.yaml
102 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
103
104
105test: restore-initial-db-status
106 # RUN TESTS
107 sudo docker cp $(XOS_DIR)/apiary.apib teststandalone_xos_ui_1:/opt/xos/tests/api/apiary.apib
108 sudo docker exec -i teststandalone_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm test"
109
110test-tosca: restore-initial-db-status
111 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui bash -c "cd /opt/xos/tosca/tests; python ./alltests.py"
112
113test-ui: restore-initial-db-status
114 sudo docker exec -u root -i teststandalone_xos_1 bash -c "cd /opt/xos/tests/ui-e2e; python xos-e2e-test.py"
115
116base-container:
117 make -f ../common/Makefile.containers xos_base
118
119devel-container: base-container
120 make -f ../common/Makefile.containers xos_devel synchronizer onboarding_synchronizer
121
Scott Bakerbda441d2016-06-28 14:14:31 -0700122containers: prereqs download_xos devel-container
Scott Baker50421662016-06-27 22:09:48 -0700123 make -f ../common/Makefile.containers xos_test
124
Scott Baker4b37d1a2016-07-01 13:41:52 -0700125rebuild:
126 bash ../common/rebuild.sh $(XOS_BOOTSTRAP_PORT)
127 bash ../common/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
128
Scott Baker50421662016-06-27 22:09:48 -0700129stop:
130 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
131 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
132
133showlogs:
Scott Bakercada1982016-06-30 15:26:16 -0700134 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs
135
136showlogs_bootstrap:
137 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs
Scott Baker50421662016-06-27 22:09:48 -0700138
139rm: stop
140 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
141 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
142
143docker-clean:
144 sudo docker rm -f $(shell sudo docker ps -aq)
145
146enter-xos:
147 sudo docker exec -ti teststandalone_xos_ui_1 bash
148
149enter-xos-db:
150 sudo docker exec -ti $(DB_NAME) bash