diff --git a/.circleci/config.yml b/.circleci/config.yml index ce522e0e0..10fa20c69 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -132,6 +132,12 @@ workflows: - build-oci-images: <<: *run_for_numeric_tags image_tag: << pipeline.git.tag >> + - e2e: + <<: *run_for_numeric_tags + image_tag: << pipeline.git.tag >> + requires: + - build-oci-images + - build-all - publish-oci-images: <<: *run_for_numeric_tags <<: *v2_release_requires @@ -195,6 +201,7 @@ workflows: <<: *run_for_all_branches - e2e: <<: *run_for_all_branches + image_tag: v2-dev requires: - build-oci-images - build-all @@ -268,6 +275,10 @@ jobs: destination: test-artifacts e2e: executor: local_cluster_test_executor + parameters: + image_tag: + type: string + default: "v2-dev" steps: - checkout - kubectl-install @@ -335,11 +346,13 @@ jobs: # the connector in east kubectl wait listener/backend \ --timeout=60s \ - '--for=jsonpath={.status.hasMatchingConnector}=true' + '--for=jsonpath={.status.hasMatchingConnector}=true' - run: name: Running E2E Tests command: | set -x + export SKUPPER_SYSTEM_CONTROLLER_IMAGE="quay.io/skupper/system-controller:<< parameters.image_tag >>" + export SKUPPER_CLI_IMAGE="quay.io/skupper/cli:<< parameters.image_tag >>" cd tests cp ~/kc.west ~/.kube/config make ci-tests diff --git a/tests/Makefile b/tests/Makefile index 82ad56400..1716ddea7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -3,7 +3,7 @@ EXTRA_VARS := --extra-vars "@$(ROOT_PATH)/vars.yml" COLLECTION_PATH := $(ROOT_PATH)/e2e/collections/ansible_collections/e2e/tests # Remove expose-pods-by-name from the CI tests, until we close # this issue https://github.com/skupperproject/skupper/issues/2251 -TESTS_CI := attached-connector,ha,hello-world,labels-and-annotations +TESTS_CI := attached-connector,ha,hello-world,labels-and-annotations,system-sites # E2E Test directories E2E_TEST_DIRS := $(sort $(wildcard $(ROOT_PATH)/e2e/scenarios/*)) diff --git a/tests/e2e/scenarios/system-sites/ansible.cfg b/tests/e2e/scenarios/system-sites/ansible.cfg new file mode 100644 index 000000000..5d6186172 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/ansible.cfg @@ -0,0 +1,8 @@ +[defaults] +collections_path = ../../collections +roles_path = ../../collections/ansible_collections/e2e/tests/roles +deprecation_warnings = False + +[persistent_connection] +connect_timeout = 30 +command_timeout = 30 diff --git a/tests/e2e/scenarios/system-sites/cleanup-tasks.yml b/tests/e2e/scenarios/system-sites/cleanup-tasks.yml new file mode 100644 index 000000000..b4a22d770 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/cleanup-tasks.yml @@ -0,0 +1,36 @@ +--- +- name: "[ {{ test_identifier }} ] - Cleanup frontend container" + ansible.builtin.command: + cmd: "{{ platform }} rm -f frontend" + failed_when: false + when: + - not skip_teardown | default(false) | bool + - "'west' in inventory_hostname" + +- name: "[ {{ test_identifier }} ] - Cleanup backend container" + ansible.builtin.command: + cmd: "{{ platform }} rm -f backend" + failed_when: false + when: + - not skip_teardown | default(false) | bool + - "'east' in inventory_hostname" + +- name: "[ {{ test_identifier }} ] - Stop namespaces" + skupper.v2.system: + action: stop + namespace: "{{ namespace_name }}" + platform: "{{ platform }}" + image: "{{ skupper_cli_image }}" + failed_when: false + when: not skip_teardown | default(false) | bool + +- name: "[ {{ test_identifier }} ] - Uninstall system controller" + skupper.v2.controller: + action: uninstall + platform: "{{ platform }}" + image: "{{ skupper_system_controller_image }}" + failed_when: false + run_once: true + when: not skip_teardown | default(false) | bool + + diff --git a/tests/e2e/scenarios/system-sites/inventory/group_vars/all.yml b/tests/e2e/scenarios/system-sites/inventory/group_vars/all.yml new file mode 100644 index 000000000..a708e279e --- /dev/null +++ b/tests/e2e/scenarios/system-sites/inventory/group_vars/all.yml @@ -0,0 +1,8 @@ +--- +ansible_connection: local +ansible_user: "{{ lookup('env', 'USER') }}" +ansible_python_interpreter: /usr/bin/python3 +debug: false +namespace_prefix: "e2e-system-sites" +skupper_cli_image: "{{ lookup('ansible.builtin.env', 'SKUPPER_CLI_IMAGE') | default('quay.io/skupper/cli:v2-dev', true) }}" +skupper_system_controller_image: "{{ lookup('ansible.builtin.env', 'SKUPPER_SYSTEM_CONTROLLER_IMAGE') | default('quay.io/skupper/system-controller:v2-dev', true) }}" diff --git a/tests/e2e/scenarios/system-sites/inventory/host_vars/east.yml b/tests/e2e/scenarios/system-sites/inventory/host_vars/east.yml new file mode 100644 index 000000000..52376ebd5 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/inventory/host_vars/east.yml @@ -0,0 +1,4 @@ +--- +# Platform configuration +platform: docker +namespace_name: east diff --git a/tests/e2e/scenarios/system-sites/inventory/host_vars/west.yml b/tests/e2e/scenarios/system-sites/inventory/host_vars/west.yml new file mode 100644 index 000000000..880dcc221 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/inventory/host_vars/west.yml @@ -0,0 +1,5 @@ +--- +# Platform configuration +platform: docker +namespace_name: west + diff --git a/tests/e2e/scenarios/system-sites/inventory/hosts.yml b/tests/e2e/scenarios/system-sites/inventory/hosts.yml new file mode 100644 index 000000000..9aff776d1 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/inventory/hosts.yml @@ -0,0 +1,5 @@ +--- +all: + hosts: + west: + east: diff --git a/tests/e2e/scenarios/system-sites/resources/east/connector.yml b/tests/e2e/scenarios/system-sites/resources/east/connector.yml new file mode 100644 index 000000000..0d634e9d8 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/resources/east/connector.yml @@ -0,0 +1,9 @@ +--- +apiVersion: skupper.io/v2alpha1 +kind: Connector +metadata: + name: backend +spec: + routingKey: backend + port: 9090 + host: 127.0.0.1 diff --git a/tests/e2e/scenarios/system-sites/resources/east/site.yml b/tests/e2e/scenarios/system-sites/resources/east/site.yml new file mode 100644 index 000000000..a02b9cc5d --- /dev/null +++ b/tests/e2e/scenarios/system-sites/resources/east/site.yml @@ -0,0 +1,5 @@ +--- +apiVersion: skupper.io/v2alpha1 +kind: Site +metadata: + name: east diff --git a/tests/e2e/scenarios/system-sites/resources/west/listener.yml b/tests/e2e/scenarios/system-sites/resources/west/listener.yml new file mode 100644 index 000000000..026ba2703 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/resources/west/listener.yml @@ -0,0 +1,9 @@ +--- +apiVersion: skupper.io/v2alpha1 +kind: Listener +metadata: + name: backend +spec: + routingKey: backend + port: 8080 + host: 127.0.0.1 diff --git a/tests/e2e/scenarios/system-sites/resources/west/router_access.yml b/tests/e2e/scenarios/system-sites/resources/west/router_access.yml new file mode 100644 index 000000000..cbf48b3fc --- /dev/null +++ b/tests/e2e/scenarios/system-sites/resources/west/router_access.yml @@ -0,0 +1,14 @@ +apiVersion: skupper.io/v2alpha1 +kind: RouterAccess +metadata: + name: router-access-west + namespace: west +spec: + roles: + - name: inter-router + port: 55671 + - name: edge + port: 45671 + subjectAlternativeNames: + - 0.0.0.0 + - '::' \ No newline at end of file diff --git a/tests/e2e/scenarios/system-sites/resources/west/site.yml b/tests/e2e/scenarios/system-sites/resources/west/site.yml new file mode 100644 index 000000000..e069d75da --- /dev/null +++ b/tests/e2e/scenarios/system-sites/resources/west/site.yml @@ -0,0 +1,7 @@ +--- +apiVersion: skupper.io/v2alpha1 +kind: Site +metadata: + name: west +spec: + linkAccess: default diff --git a/tests/e2e/scenarios/system-sites/test.yml b/tests/e2e/scenarios/system-sites/test.yml new file mode 100644 index 000000000..6729aa1d2 --- /dev/null +++ b/tests/e2e/scenarios/system-sites/test.yml @@ -0,0 +1,97 @@ +--- +- name: Hello World System Sites Test (Manual Reload) + hosts: all + roles: + - e2e.tests.skupper_test_images + + vars: + test_identifier: "Hello World with System Sites (Manual Reload)" + + environment: + SKUPPER_PLATFORM: "{{ platform }}" + + tasks: + # Pre-test cleanup + - name: "[ {{ test_identifier }} ] - Pre-test cleanup" + ansible.builtin.include_tasks: cleanup-tasks.yml + + - name: "[ {{ test_identifier }} ] - Main test block" + block: + - name: "[ {{ test_identifier }} ] - Install system controller" + skupper.v2.controller: + action: install + platform: "{{ platform }}" + image: "{{ skupper_system_controller_image }}" + run_once: true + delegate_to: localhost + register: system_install + + # West Site - Setup and get token + - name: "[ {{ test_identifier }} ] - West Site Setup" + block: + - name: "[ {{ test_identifier }} ] - Deploy frontend service" + ansible.builtin.shell: + cmd: "{{ platform }} run --name frontend -d --rm -p 127.0.0.1:7070:8080 quay.io/skupper/hello-world-frontend --backend http://host.containers.internal:8080" + changed_when: false + + - name: "[ {{ test_identifier }} ] - Apply west site resources" + skupper.v2.resource: + path: "{{ playbook_dir }}/resources/west/" + platform: "{{ platform }}" + namespace: "{{ namespace_name }}" + + - name: "[ {{ test_identifier }} ] - Start west namespace" + skupper.v2.system: + action: start + platform: "{{ platform }}" + namespace: "{{ namespace_name }}" + image: "{{ skupper_cli_image }}" + register: west + + when: "'west' in inventory_hostname" + run_once: true + + # East Site - Must run after token is created + - name: "[ {{ test_identifier }} ] - East Site Setup" + block: + - name: "[ {{ test_identifier }} ] - Deploy backend service" + ansible.builtin.shell: + cmd: "{{ platform }} run --name backend -d --rm -p 127.0.0.1:9090:8080 quay.io/skupper/hello-world-backend" + changed_when: false + register: backend_deploy + + - name: "[ {{ test_identifier }} ] - Apply east site resources" + skupper.v2.resource: + path: "{{ playbook_dir }}/resources/east/" + platform: "{{ platform }}" + namespace: "{{ namespace_name }}" + + - name: "[ {{ test_identifier }} ] - Apply token to east site" + skupper.v2.resource: + def: "{{ west.links['0.0.0.0'] }}" + namespace: "{{ namespace_name }}" + platform: "{{ platform }}" + + - name: "[ {{ test_identifier }} ] - Start east namespace" + skupper.v2.system: + action: start + platform: "{{ platform }}" + namespace: "{{ namespace_name }}" + image: "{{ skupper_cli_image }}" + register: east + when: "'east' in inventory_hostname" + + # Verify connectivity - test if backend is accessible from frontend container + - name: "[ {{ test_identifier }} ] - Test via Skupper (listener)" + ansible.builtin.command: + cmd: "curl -s -f http://127.0.0.1:8080/api/hello" + register: curl_result + retries: 10 + delay: 10 + until: curl_result.rc == 0 + when: "'west' in inventory_hostname" + changed_when: false + + always: + - name: "[ {{ test_identifier }} ] - Post-test cleanup" + ansible.builtin.include_tasks: cleanup-tasks.yml