Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 1 | include ../common/Makedefs |
| 2 | |
| 3 | MYIP:=$(shell hostname -i) |
| 4 | CONFIG_DIR:=$(shell pwd) |
| 5 | DOCKER_COMPOSE_YML=./onboarding-docker-compose/docker-compose.yml |
| 6 | BOOTSTRAP_YML=./docker-compose-bootstrap.yml |
| 7 | DOCKER_PROJECT=teststandalone |
| 8 | BOOTSTRAP_PROJECT=teststandalonebs |
| 9 | XOS_BOOTSTRAP_PORT=9998 |
| 10 | XOS_UI_PORT=9999 |
| 11 | DB_NAME=$(BOOTSTRAP_PROJECT)_xos_db_1 |
| 12 | |
| 13 | define 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; |
| 25 | endef |
| 26 | export TRUNCATE_FN |
| 27 | |
| 28 | prepare: 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 Baker | bda441d | 2016-06-28 14:14:31 -0700 | [diff] [blame] | 32 | xos: prereqs dirs download_xos download_services bootstrap onboarding |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 33 | |
| 34 | prereqs: |
| 35 | sudo make -f ../common/Makefile.prereqs |
| 36 | |
| 37 | dirs: |
| 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 | |
| 42 | bootstrap: |
Scott Baker | c5e2f3c | 2016-07-11 11:48:06 -0700 | [diff] [blame] | 43 | @echo "[BOOTSTRAP]" |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 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 Baker | bda441d | 2016-06-28 14:14:31 -0700 | [diff] [blame] | 49 | download_xos: |
| 50 | make -f ../common/Makefile.services xos_core |
| 51 | |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 52 | download_services: |
| 53 | make -f ../common/Makefile.services |
| 54 | |
| 55 | update_services: |
| 56 | make -f ../common/Makefile.services update |
| 57 | |
Scott Baker | 1b29f97 | 2016-07-01 09:20:58 -0700 | [diff] [blame] | 58 | update_xos: |
| 59 | make -f ../common/Makefile.services update_xos |
| 60 | |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 61 | onboarding: |
Scott Baker | c5e2f3c | 2016-07-11 11:48:06 -0700 | [diff] [blame] | 62 | @echo "[ONBOARDING]" |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 63 | bash ../common/wait_for_onboarding_ready.sh 9998 xos |
Scott Baker | 7ab0221 | 2016-06-29 14:12:15 -0700 | [diff] [blame] | 64 | 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 Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 70 | 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 | |
| 85 | restore-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 | |
| 105 | test: 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 | |
| 110 | test-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 | |
| 113 | test-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 | |
| 116 | base-container: |
| 117 | make -f ../common/Makefile.containers xos_base |
| 118 | |
| 119 | devel-container: base-container |
| 120 | make -f ../common/Makefile.containers xos_devel synchronizer onboarding_synchronizer |
| 121 | |
Scott Baker | bda441d | 2016-06-28 14:14:31 -0700 | [diff] [blame] | 122 | containers: prereqs download_xos devel-container |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 123 | make -f ../common/Makefile.containers xos_test |
| 124 | |
Scott Baker | 4b37d1a | 2016-07-01 13:41:52 -0700 | [diff] [blame] | 125 | rebuild: |
| 126 | bash ../common/rebuild.sh $(XOS_BOOTSTRAP_PORT) |
| 127 | bash ../common/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
| 128 | |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 129 | stop: |
| 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 | |
| 133 | showlogs: |
Scott Baker | cada198 | 2016-06-30 15:26:16 -0700 | [diff] [blame] | 134 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs |
| 135 | |
| 136 | showlogs_bootstrap: |
| 137 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 138 | |
| 139 | rm: 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 | |
| 143 | docker-clean: |
| 144 | sudo docker rm -f $(shell sudo docker ps -aq) |
| 145 | |
| 146 | enter-xos: |
| 147 | sudo docker exec -ti teststandalone_xos_ui_1 bash |
| 148 | |
| 149 | enter-xos-db: |
| 150 | sudo docker exec -ti $(DB_NAME) bash |