move over configurations from xos repo
Change-Id: I66583bdaea582986d8f16a29066a79c6687b97fb
diff --git a/test-standalone/Makefile b/test-standalone/Makefile
new file mode 100644
index 0000000..626495a
--- /dev/null
+++ b/test-standalone/Makefile
@@ -0,0 +1,137 @@
+include ../common/Makedefs
+
+MYIP:=$(shell hostname -i)
+CONFIG_DIR:=$(shell pwd)
+DOCKER_COMPOSE_YML=./onboarding-docker-compose/docker-compose.yml
+BOOTSTRAP_YML=./docker-compose-bootstrap.yml
+DOCKER_PROJECT=teststandalone
+BOOTSTRAP_PROJECT=teststandalonebs
+XOS_BOOTSTRAP_PORT=9998
+XOS_UI_PORT=9999
+DB_NAME=$(BOOTSTRAP_PROJECT)_xos_db_1
+
+define TRUNCATE_FN
+ CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$$$
+ DECLARE
+ statements CURSOR FOR
+ SELECT tablename FROM pg_tables
+ WHERE tableowner = username AND schemaname = 'public';
+ BEGIN
+ FOR stmt IN statements LOOP
+ EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
+ END LOOP;
+ END;
+ $$$$ LANGUAGE plpgsql;
+endef
+export TRUNCATE_FN
+
+prepare: xos
+ sudo docker exec -i teststandalone_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm install --production"
+ sudo docker exec teststandalone_xos_ui_1 pip install dredd_hooks
+
+xos: prereqs dirs download_services bootstrap onboarding
+
+prereqs:
+ sudo make -f ../common/Makefile.prereqs
+
+dirs:
+ # if this directory doesn't exist, then docker-compose will create it with root permission
+ mkdir -p key_import
+ mkdir -p onboarding-docker-compose
+
+bootstrap:
+ echo "[BOOTSTRAP]"
+ sudo rm -f onboarding-docker-compose/docker-compose.yml
+ sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
+ bash ../common/wait_for_xos_port.sh 9998
+ 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
+
+download_services:
+ make -f ../common/Makefile.services
+
+update_services:
+ make -f ../common/Makefile.services update
+
+onboarding:
+ echo "[ONBOARDING]"
+ bash ../common/wait_for_onboarding_ready.sh 9998 xos
+ sudo bash -c "echo somekey > key_import/vsg_rsa"
+ sudo bash -c "echo somekey > key_import/vsg_rsa.pub"
+ sudo bash -c "echo somekey > key_import/volt_rsa"
+ sudo bash -c "echo somekey > key_import/volt_rsa.pub"
+ sudo bash -c "echo somekey > key_import/onos_rsa"
+ sudo bash -c "echo somekey > key_import/onos_rsa.pub"
+ sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/disable-onboarding.yaml
+ 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
+ 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
+ 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
+ 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
+ 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
+ sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py None - < ../common/enable-onboarding.yaml
+ bash ../common/wait_for_onboarding_ready.sh 9998 services/vrouter
+ bash ../common/wait_for_onboarding_ready.sh 9998 services/volt
+ bash ../common/wait_for_onboarding_ready.sh 9998 services/vsg
+ bash ../common/wait_for_onboarding_ready.sh 9998 services/vtr
+ bash ../common/wait_for_onboarding_ready.sh 9998 services/onos
+ bash ../common/wait_for_onboarding_ready.sh 9998 xos
+ bash ../common/wait_for_xos_port.sh 9999
+
+restore-initial-db-status:
+ sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "$$TRUNCATE_FN" >/dev/null 2>&1
+ sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT truncate_tables('postgres');" >/dev/null 2>&1
+ sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_tenant_id_seq', 1)" >/dev/null 2>&1
+ sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_deployment_id_seq', 1)" >/dev/null 2>&1
+ sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_flavor_id_seq', 1)" >/dev/null 2>&1
+ sudo docker exec $(DB_NAME) psql -U postgres -d xos -c "SELECT setval('core_service_id_seq', 1)" >/dev/null 2>&1
+ 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
+ sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/fixtures.yaml
+ sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py none - < ../common/mydeployment.yaml
+ 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
+
+ # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/setup.yaml
+ # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/nodes.yaml
+ # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/cord-pod/images.yaml
+ 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
+ sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui python /opt/xos/tosca/run.py padmin@vicci.org - < services.yaml
+ 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
+
+
+test: restore-initial-db-status
+ # RUN TESTS
+ sudo docker cp $(XOS_DIR)/apiary.apib teststandalone_xos_ui_1:/opt/xos/tests/api/apiary.apib
+ sudo docker exec -i teststandalone_xos_ui_1 bash -c "cd /opt/xos/tests/api; npm test"
+
+test-tosca: restore-initial-db-status
+ sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) run xos_ui bash -c "cd /opt/xos/tosca/tests; python ./alltests.py"
+
+test-ui: restore-initial-db-status
+ sudo docker exec -u root -i teststandalone_xos_1 bash -c "cd /opt/xos/tests/ui-e2e; python xos-e2e-test.py"
+
+base-container:
+ make -f ../common/Makefile.containers xos_base
+
+devel-container: base-container
+ make -f ../common/Makefile.containers xos_devel synchronizer onboarding_synchronizer
+
+containers: devel-container
+ make -f ../common/Makefile.containers xos_test
+
+stop:
+ test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
+ sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
+
+showlogs:
+ sudo docker-compose logs
+
+rm: stop
+ test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
+ sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
+
+docker-clean:
+ sudo docker rm -f $(shell sudo docker ps -aq)
+
+enter-xos:
+ sudo docker exec -ti teststandalone_xos_ui_1 bash
+
+enter-xos-db:
+ sudo docker exec -ti $(DB_NAME) bash
diff --git a/test-standalone/README.md b/test-standalone/README.md
new file mode 100644
index 0000000..32e7c95
--- /dev/null
+++ b/test-standalone/README.md
@@ -0,0 +1,11 @@
+# API Test Configuration
+
+This configuration is intended to be used to test the API,
+to use it:
+
+- `make containers`
+- `make`
+
+Then anytime is needed `make test` (`xos/api` folder is shared with the container)
+
+Note that this test will be automatically executed by (Jenkins)[https://jenkins.opencord.org/]
\ No newline at end of file
diff --git a/test-standalone/docker-compose-bootstrap.yml b/test-standalone/docker-compose-bootstrap.yml
new file mode 100644
index 0000000..857db96
--- /dev/null
+++ b/test-standalone/docker-compose-bootstrap.yml
@@ -0,0 +1,35 @@
+xos_db:
+ image: xosproject/xos-postgres
+ expose:
+ - "5432"
+
+xos_bootstrap_ui:
+ image: xosproject/xos
+ command: python /opt/xos/manage.py runserver 0.0.0.0:9998 --insecure --makemigrations
+ ports:
+ - "9998:9998"
+ links:
+ - xos_db
+ volumes:
+ - ../common/xos_common_config:/opt/xos/xos_configuration/xos_common_config
+ - ../vtn/files/xos_vtn_config:/opt/xos/xos_configuration/xos_vtn_config:ro
+ - ../../xos_services:/opt/xos_services
+
+xos_synchronizer_onboarding:
+ image: xosproject/xos-synchronizer-onboarding
+ command: bash -c "cd /opt/xos/synchronizers/onboarding; ./run.sh"
+# command: sleep 86400
+ labels:
+ org.xosproject.kind: synchronizer
+ org.xosproject.target: onboarding
+ links:
+ - xos_db
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ - ./key_import:/opt/xos/key_import:ro
+ - ./onboarding-docker-compose:/opt/xos/synchronizers/onboarding/docker-compose
+ - ../../xos_services:/opt/xos_services
+ log_driver: "json-file"
+ log_opt:
+ max-size: "100k"
+ max-file: "5"
diff --git a/test-standalone/services.yaml b/test-standalone/services.yaml
new file mode 100644
index 0000000..40e0127
--- /dev/null
+++ b/test-standalone/services.yaml
@@ -0,0 +1,258 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Just enough Tosca to get the vSG slice running on the CORD POD
+
+imports:
+ - custom_types/xos.yaml
+
+topology_template:
+ node_templates:
+ # CORD Services
+ service#vtr:
+ type: tosca.nodes.Service
+ properties:
+ view_url: /admin/vtr/vtrservice/$id$/
+ kind: vTR
+ replaces: service_vtr
+
+ service#volt:
+ type: tosca.nodes.VOLTService
+ requirements:
+ - vsg_tenant:
+ node: service#vsg
+ relationship: tosca.relationships.TenantOfService
+ properties:
+ view_url: /admin/cord/voltservice/$id$/
+ kind: vOLT
+ replaces: service_volt
+
+ addresses_vsg:
+ type: tosca.nodes.AddressPool
+ properties:
+ addresses: 10.168.0.0/24
+ gateway_ip: 10.168.0.1
+ gateway_mac: 02:42:0a:a8:00:01
+
+ addresses_exampleservice-public:
+ type: tosca.nodes.AddressPool
+ properties:
+ addresses: 10.168.1.0/24
+ gateway_ip: 10.168.1.1
+ gateway_mac: 02:42:0a:a8:00:01
+
+ service#vsg:
+ type: tosca.nodes.VSGService
+ requirements:
+ - vrouter_tenant:
+ node: service#vrouter
+ relationship: tosca.relationships.TenantOfService
+ properties:
+ view_url: /admin/cord/vsgservice/$id$/
+ # backend_network_label: hpc_client
+ private_key_fn: /opt/xos/synchronizers/vcpe/vcpe_private_key
+# node_label: label_vsg
+ replaces: service_vsg
+
+ service#vrouter:
+ type: tosca.nodes.VRouterService
+ properties:
+ view_url: /admin/vrouter/vrouterservice/$id$/
+ replaces: service_vrouter
+ requirements:
+ - addresses_vsg:
+ node: addresses_vsg
+ relationship: tosca.relationships.ProvidesAddresses
+ - addresses_service1:
+ node: addresses_exampleservice-public
+ relationship: tosca.relationships.ProvidesAddresses
+
+# service#fabric:
+# type: tosca.nodes.FabricService
+# properties:
+# view_url: /admin/fabric/fabricservice/$id$/
+# replaces: service_fabric
+
+# service#ONOS_Fabric:
+# type: tosca.nodes.ONOSService
+# requirements:
+# properties:
+# kind: onos
+# view_url: /admin/onos/onosservice/$id$/
+# no_container: true
+# rest_hostname: onos-fabric
+# replaces: service_ONOS_Fabric
+
+# service#ONOS_CORD:
+# type: tosca.nodes.ONOSService
+# properties:
+# no-delete: true
+# no-create: false
+# no-update: true
+
+# # vOLT_ONOS_app:
+# # type: tosca.nodes.ONOSvOLTApp
+# # requirements:
+# # - onos_tenant:
+# # node: service#ONOS_CORD
+# # relationship: tosca.relationships.TenantOfService
+# # - volt_service:
+# # node: service#volt
+# # relationship: tosca.relationships.UsedByService
+# # properties:
+# # install_dependencies: onos-ext-notifier-1.0-SNAPSHOT.oar, onos-ext-volt-event-publisher-1.0-SNAPSHOT.oar
+# # dependencies: org.onosproject.openflow-base, org.onosproject.olt, org.ciena.onos.ext_notifier, org.ciena.onos.volt_event_publisher
+# # autogenerate: volt-network-cfg
+
+# # vRouter_ONOS_app:
+# # type: tosca.nodes.ONOSvRouterApp
+# # requirements:
+# # - onos_tenant:
+# # node: service#ONOS_Fabric
+# # relationship: tosca.relationships.TenantOfService
+# # - vrouter_service:
+# # node: service#vrouter
+# # relationship: tosca.relationships.UsedByService
+# # properties:
+# # dependencies: org.onosproject.vrouter
+# # autogenerate: vrouter-network-cfg
+
+# Private:
+# type: tosca.nodes.NetworkTemplate
+
+# management:
+# type: tosca.nodes.network.Network.XOS
+# properties:
+# no-create: true
+# no-delete: true
+# no-update: true
+
+# image#vsg-1.0:
+# type: tosca.nodes.Image
+
+# mysite:
+# type: tosca.nodes.Site
+
+# label_vsg:
+# type: tosca.nodes.NodeLabel
+
+# # Networks required by the CORD setup
+# mysite_vsg-access:
+# type: tosca.nodes.network.Network
+# properties:
+# ip_version: 4
+# requirements:
+# - network_template:
+# node: Private
+# relationship: tosca.relationships.UsesNetworkTemplate
+# - owner:
+# node: mysite_vsg
+# relationship: tosca.relationships.MemberOfSlice
+# - connection:
+# node: mysite_vsg
+# relationship: tosca.relationships.ConnectsToSlice
+
+# # CORD Slices
+# mysite_vsg:
+# description: vSG Controller Slice
+# type: tosca.nodes.Slice
+# properties:
+# network: noauto
+# requirements:
+# - vsg_service:
+# node: service#vsg
+# relationship: tosca.relationships.MemberOfService
+# - site:
+# node: mysite
+# relationship: tosca.relationships.MemberOfSite
+# - management:
+# node: management
+# relationship: tosca.relationships.ConnectsToNetwork
+# - image:
+# node: image#vsg-1.0
+# relationship: tosca.relationships.DefaultImage
+
+# # Let's add a user who can be administrator of the household
+# johndoe@myhouse.com:
+# type: tosca.nodes.User
+# properties:
+# password: letmein
+# firstname: john
+# lastname: doe
+# requirements:
+# - site:
+# node: mysite
+# relationship: tosca.relationships.MemberOfSite
+# - dependency:
+# node: mysite_vsg
+# relationship: tosca.relationships.DependsOn
+
+# # A subscriber
+# My House:
+# type: tosca.nodes.CORDSubscriber
+# properties:
+# service_specific_id: 123
+# firewall_enable: false
+# cdn_enable: false
+# url_filter_enable: false
+# url_filter_level: R
+# requirements:
+# - house_admin:
+# node: johndoe@myhouse.com
+# relationship: tosca.relationships.AdminPrivilege
+
+# Mom's PC:
+# type: tosca.nodes.CORDUser
+# properties:
+# mac: 01:02:03:04:05:06
+# level: PG_13
+# requirements:
+# - household:
+# node: My House
+# relationship: tosca.relationships.SubscriberDevice
+
+# Dad's PC:
+# type: tosca.nodes.CORDUser
+# properties:
+# mac: 90:E2:BA:82:F9:75
+# level: PG_13
+# requirements:
+# - household:
+# node: My House
+# relationship: tosca.relationships.SubscriberDevice
+
+# Jack's Laptop:
+# type: tosca.nodes.CORDUser
+# properties:
+# mac: 68:5B:35:9D:91:D5
+# level: PG_13
+# requirements:
+# - household:
+# node: My House
+# relationship: tosca.relationships.SubscriberDevice
+
+# Jill's Laptop:
+# type: tosca.nodes.CORDUser
+# properties:
+# mac: 34:36:3B:C9:B6:A6
+# level: PG_13
+# requirements:
+# - household:
+# node: My House
+# relationship: tosca.relationships.SubscriberDevice
+
+# My Volt:
+# type: tosca.nodes.VOLTTenant
+# properties:
+# service_specific_id: 123
+# s_tag: 222
+# c_tag: 111
+# requirements:
+# - provider_service:
+# node: service#volt
+# relationship: tosca.relationships.MemberOfService
+# - subscriber:
+# node: My House
+# relationship: tosca.relationships.BelongsToSubscriber
+# - dependency:
+# node: mysite_vsg
+# relationship: tosca.relationships.DependsOn
diff --git a/test-standalone/xos.yaml b/test-standalone/xos.yaml
new file mode 100644
index 0000000..85bdd02
--- /dev/null
+++ b/test-standalone/xos.yaml
@@ -0,0 +1,28 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+ - custom_types/xos.yaml
+
+topology_template:
+ node_templates:
+ xos:
+ type: tosca.nodes.XOS
+ properties:
+ ui_port: 9999
+ bootstrap_ui_port: 9998
+ docker_project_name: teststandalone
+ db_container_name: teststandalonebs_xos_db_1
+ frontend_only: true
+ source_ui_image: xosproject/xos-test
+
+ /opt/xos/xos_configuration/xos_common_config:
+ type: tosca.nodes.XOSVolume
+ properties:
+ host_path: { path_join: [ SELF, CONFIG_DIR, ../common/xos_common_config, ENV_VAR ] }
+ read_only: false
+ requirements:
+ - xos:
+ node: xos
+ relationship: tosca.relationships.UsedByXOS