Commit 9aef0e5c authored by Konstantinos Togias's avatar Konstantinos Togias
Browse files

Verify the real bootstrap role locally and in the existing CI job

parent bab71a16
Loading
Loading
Loading
Loading
Loading
+3 −1
Changes for .gitlab-ci.yml: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ ansible-lint:
  stage: lint
  extends: .ansible_setup
  script:
    - ansible-lint -c .ansible-lint ansible/playbooks ansible/roles ansible/role-template
    - ansible-lint -c .ansible-lint ansible/playbooks ansible/roles ansible/role-template ansible/tests/test_platform_bootstrap.yml

syntax-check:
  stage: test
@@ -61,6 +61,8 @@ syntax-check:
        ansible-playbook -i inventory/r2.example.yml --syntax-check "$playbook"
      done

    - ANSIBLE_ROLES_PATH=roles ansible-playbook -i localhost, tests/test_platform_bootstrap.yml

python-smoke:
  stage: test
  script:
+3 −1
Changes for README.md: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -85,8 +85,10 @@ empty defaults preserve health-only deployments. The paired chart provides
SRM and chart revisions; upgrade or roll back the set together. Bootstrap
generation is not a backend-health or credential-validity check.

Offline producer tests run locally and in the existing Python CI job:
Offline producer tests run in the existing Python CI job. The real-role check
also runs locally and in the existing syntax-check job, without cluster access:

```sh
python -m unittest discover -s ansible/tests -p test_tfsdk_bootstrap.py
ANSIBLE_ROLES_PATH=ansible/roles ansible-playbook -i localhost, ansible/tests/test_platform_bootstrap.yml
```
+77 −0
Changes for ansible/tests/test_platform_bootstrap.yml: 77 added lines, 0 removed lines.
Original line number Diff line number Diff line
---
- name: Verify platform bootstrap generation without cluster access
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - name: Generate one declaration through the platform role
      ansible.builtin.include_role:
        name: oop-platform
        tasks_from: bootstrap
      vars:
        oop_platform_extra_values: {}
        oop_platform_bootstrap:
          version: openop.srm.bootstrap/v1
          zones: []
          control_paths:
            - ref: remote
              adapter_type: kubernetes
              kubeconfig_secret:
                name: test-credentials
                key: config
              infrastructure:
                kube_context: remote
                namespace: applications
            - ref: local
              adapter_type: kubernetes
              infrastructure:
                in_cluster: true
                namespace: other-applications

    - name: Verify generated configuration and mount agree
      ansible.builtin.assert:
        that:
          - oop_platform_bootstrap_values.srm.srmcontroller.controlPathCredentials | length == 1
          - >-
            (oop_platform_bootstrap_values.srm.srmcontroller.topology | from_yaml).control_paths[0].infrastructure.kubeconfig_path
            == oop_platform_bootstrap_values.srm.srmcontroller.controlPathCredentials[0].mountPath ~ '/config'
          - (oop_platform_bootstrap_values.srm.srmcontroller.topology | from_yaml).control_paths[1].infrastructure.in_cluster

    - name: Reset to health-only defaults through the same role
      ansible.builtin.include_role:
        name: oop-platform
        tasks_from: bootstrap
      vars:
        oop_platform_extra_values: {}
        oop_platform_bootstrap: {}

    - name: Verify generated configuration was cleared
      ansible.builtin.assert:
        that:
          - oop_platform_bootstrap_values == {}

    - name: Verify competing topology is rejected
      block:
        - name: Attempt competing topology inputs
          ansible.builtin.include_role:
            name: oop-platform
            tasks_from: bootstrap
          vars:
            oop_platform_bootstrap: {control_paths: []}
            oop_platform_extra_values:
              srm:
                srmcontroller:
                  topology: "control_paths: []"
      rescue:
        - name: Check the configuration migration diagnostic
          ansible.builtin.assert:
            that:
              - "'competing values' in ansible_failed_result.msg"
        - name: Record the expected rejection
          ansible.builtin.set_fact:
            bootstrap_competing_rejected: true

    - name: Require competing-input rejection
      ansible.builtin.assert:
        that:
          - bootstrap_competing_rejected | default(false)