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: |
| 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 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 | |
| 58 | onboarding: |
| 59 | echo "[ONBOARDING]" |
| 60 | bash ../common/wait_for_onboarding_ready.sh 9998 xos |
| 61 | sudo bash -c "echo somekey > key_import/vsg_rsa" |
| 62 | sudo bash -c "echo somekey > key_import/vsg_rsa.pub" |
| 63 | sudo bash -c "echo somekey > key_import/volt_rsa" |
| 64 | sudo bash -c "echo somekey > key_import/volt_rsa.pub" |
| 65 | sudo bash -c "echo somekey > key_import/onos_rsa" |
| 66 | sudo bash -c "echo somekey > key_import/onos_rsa.pub" |
| 67 | 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 | |
| 82 | restore-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 | |
| 102 | test: 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 | |
| 107 | test-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 | |
| 110 | test-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 | |
| 113 | base-container: |
| 114 | make -f ../common/Makefile.containers xos_base |
| 115 | |
| 116 | devel-container: base-container |
| 117 | make -f ../common/Makefile.containers xos_devel synchronizer onboarding_synchronizer |
| 118 | |
Scott Baker | bda441d | 2016-06-28 14:14:31 -0700 | [diff] [blame^] | 119 | containers: prereqs download_xos devel-container |
Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 120 | make -f ../common/Makefile.containers xos_test |
| 121 | |
| 122 | stop: |
| 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 | |
| 126 | showlogs: |
| 127 | sudo docker-compose logs |
| 128 | |
| 129 | rm: stop |
| 130 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f |
| 131 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f |
| 132 | |
| 133 | docker-clean: |
| 134 | sudo docker rm -f $(shell sudo docker ps -aq) |
| 135 | |
| 136 | enter-xos: |
| 137 | sudo docker exec -ti teststandalone_xos_ui_1 bash |
| 138 | |
| 139 | enter-xos-db: |
| 140 | sudo docker exec -ti $(DB_NAME) bash |