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 | |
| 32 | xos: prereqs dirs download_services bootstrap onboarding |
| 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 | |
| 49 | download_services: |
| 50 | make -f ../common/Makefile.services |
| 51 | |
| 52 | update_services: |
| 53 | make -f ../common/Makefile.services update |
| 54 | |
| 55 | onboarding: |
| 56 | echo "[ONBOARDING]" |
| 57 | bash ../common/wait_for_onboarding_ready.sh 9998 xos |
| 58 | sudo bash -c "echo somekey > key_import/vsg_rsa" |
| 59 | sudo bash -c "echo somekey > key_import/vsg_rsa.pub" |
| 60 | sudo bash -c "echo somekey > key_import/volt_rsa" |
| 61 | sudo bash -c "echo somekey > key_import/volt_rsa.pub" |
| 62 | sudo bash -c "echo somekey > key_import/onos_rsa" |
| 63 | sudo bash -c "echo somekey > key_import/onos_rsa.pub" |
| 64 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/disable-onboarding.yaml |
| 65 | 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 |
| 66 | 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 |
| 67 | 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 |
| 68 | 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 |
| 69 | 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 |
| 70 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/enable-onboarding.yaml |
| 71 | bash ../common/wait_for_onboarding_ready.sh 9998 services/vrouter |
| 72 | bash ../common/wait_for_onboarding_ready.sh 9998 services/volt |
| 73 | bash ../common/wait_for_onboarding_ready.sh 9998 services/vsg |
| 74 | bash ../common/wait_for_onboarding_ready.sh 9998 services/vtr |
| 75 | bash ../common/wait_for_onboarding_ready.sh 9998 services/onos |
| 76 | bash ../common/wait_for_onboarding_ready.sh 9998 xos |
| 77 | bash ../common/wait_for_xos_port.sh 9999 |
| 78 | |
| 79 | restore-initial-db-status: |
| 80 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "$$TRUNCATE_FN" >/dev/null 2>&1 |
| 81 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT truncate_tables('postgres');" >/dev/null 2>&1 |
| 82 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_tenant_id_seq', 1)" >/dev/null 2>&1 |
| 83 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_deployment_id_seq', 1)" >/dev/null 2>&1 |
| 84 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_flavor_id_seq', 1)" >/dev/null 2>&1 |
| 85 | sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_service_id_seq', 1)" >/dev/null 2>&1 |
| 86 | 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 |
| 87 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/fixtures.yaml |
| 88 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/mydeployment.yaml |
| 89 | 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 |
| 90 | |
| 91 | # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/setup.yaml |
| 92 | # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/nodes.yaml |
| 93 | # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/images.yaml |
| 94 | 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 |
| 95 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < services.yaml |
| 96 | 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 |
| 97 | |
| 98 | |
| 99 | test: restore-initial-db-status |
| 100 | # RUN TESTS |
| 101 | sudo docker cp $(XOS_DIR)/apiary.apib teststandalone_xos_ui_1:/opt/xos/tests/api/apiary.apib |
| 102 | sudo docker exec -i teststandalone_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm test" |
| 103 | |
| 104 | test-tosca: restore-initial-db-status |
| 105 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui bash -c "cd /opt/xos/tosca/tests; python ./alltests.py" |
| 106 | |
| 107 | test-ui: restore-initial-db-status |
| 108 | sudo docker exec -u root -i teststandalone_xos_1 bash -c "cd /opt/xos/tests/ui-e2e; python xos-e2e-test.py" |
| 109 | |
| 110 | base-container: |
| 111 | make -f ../common/Makefile.containers xos_base |
| 112 | |
| 113 | devel-container: base-container |
| 114 | make -f ../common/Makefile.containers xos_devel synchronizer onboarding_synchronizer |
| 115 | |
| 116 | containers: devel-container |
| 117 | make -f ../common/Makefile.containers xos_test |
| 118 | |
| 119 | stop: |
| 120 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop |
| 121 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop |
| 122 | |
| 123 | showlogs: |
| 124 | sudo docker-compose logs |
| 125 | |
| 126 | rm: stop |
| 127 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f |
| 128 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f |
| 129 | |
| 130 | docker-clean: |
| 131 | sudo docker rm -f $(shell sudo docker ps -aq) |
| 132 | |
| 133 | enter-xos: |
| 134 | sudo docker exec -ti teststandalone_xos_ui_1 bash |
| 135 | |
| 136 | enter-xos-db: |
| 137 | sudo docker exec -ti $(DB_NAME) bash |