diff --git a/tests/roles/ovn_adoption/defaults/main.yaml b/tests/roles/ovn_adoption/defaults/main.yaml index cfca66c2d..a3af8a35f 100644 --- a/tests/roles/ovn_adoption/defaults/main.yaml +++ b/tests/roles/ovn_adoption/defaults/main.yaml @@ -33,3 +33,16 @@ ovn_nic_mapping_patch: | ovnController: nicMappings: baremetal: baremetal + +dpa_dir: "../.." +dpa_tests_dir: "{{ dpa_dir }}/tests" + +# ospdo env: +# Whether source env is OSPD Director Operator +# i.e. https://github.com/openstack-k8s-operators/osp-director-operator +ospdo_src: false +# rhoso namespace +rhoso_namespace: "openstack" +# director operator namespace +org_namespace: "openstack" +# adoption repo default location diff --git a/tests/roles/ovn_adoption/handlers/main.yaml b/tests/roles/ovn_adoption/handlers/main.yaml index 310b6712e..e97297788 100644 --- a/tests/roles/ovn_adoption/handlers/main.yaml +++ b/tests/roles/ovn_adoption/handlers/main.yaml @@ -2,7 +2,7 @@ ansible.builtin.shell: | {{ shell_header }} {{ oc_header }} - oc delete pod ovn-copy-data - oc delete certificate ovn-data-cert - oc delete secret ovn-data-cert - {% if storage_reclaim_policy.lower() == "delete" %}oc delete pvc ovn-data{% endif %} + oc delete pod -n {{ org_namespace }} ovn-copy-data + oc delete certificate -n {{ org_namespace }} ovn-data-cert + oc delete secret -n {{ org_namespace }} ovn-data-cert + {% if storage_reclaim_policy.lower() == "delete" %}oc delete pvc -n {{ org_namespace }} ovn-data{% endif %} diff --git a/tests/roles/ovn_adoption/tasks/main.yaml b/tests/roles/ovn_adoption/tasks/main.yaml index 09ab5df9e..3792bfe78 100644 --- a/tests/roles/ovn_adoption/tasks/main.yaml +++ b/tests/roles/ovn_adoption/tasks/main.yaml @@ -36,6 +36,10 @@ retries: 10 delay: 2 +- name: execute alternative tasks when source env is ODPdO + ansible.builtin.include_tasks: ovn_ospdo_src_vars.yaml + when: ospdo_src| bool + - name: set OVN copy shell vars no_log: "{{ use_no_log }}" ansible.builtin.set_fact: @@ -50,6 +54,7 @@ CONTROLLER1_SSH="{{ controller1_ssh }}" CONTROLLER2_SSH="{{ controller2_ssh }}" CONTROLLER3_SSH="{{ controller3_ssh }}" + when: not ospdo_src| bool - name: start an adoption helper pod ansible.builtin.shell: |- @@ -63,7 +68,7 @@ kind: Certificate metadata: name: ovn-data-cert - namespace: openstack + namespace: {{ org_namespace }} spec: commonName: ovn-data-cert secretName: ovn-data-cert @@ -73,6 +78,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: + namespace: {{ org_namespace }} name: ovn-data labels: app: adoption @@ -90,10 +96,11 @@ name: ovn-copy-data annotations: openshift.io/scc: anyuid - k8s.v1.cni.cncf.io/networks: internalapi + k8s.v1.cni.cncf.io/networks: {{ copy_pods_custom_networks | default('internalapi') }} labels: app: adoption spec: + {{ copy_pods_custom_spec|default('') }} containers: - image: $OVSDB_IMAGE command: [ "sh", "-c", "sleep infinity"] @@ -126,7 +133,7 @@ ansible.builtin.shell: | {{ shell_header }} {{ oc_header }} - oc wait --for condition=Ready pod/ovn-copy-data --timeout=30s + oc wait --for condition=Ready -n {{ org_namespace }} pod/ovn-copy-data --timeout=30s register: ovn_data_pod_result until: ovn_data_pod_result is success retries: 2 @@ -168,8 +175,8 @@ {{ oc_header }} {{ ovn_copy_shell_vars }} - oc exec ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6641 > /backup/ovs-nb.db" - oc exec ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6642 > /backup/ovs-sb.db" + oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6641 > /backup/ovs-nb.db" + oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6642 > /backup/ovs-sb.db" when: enable_tlse|bool is false - name: dump OVN databases using ssl connection @@ -190,8 +197,8 @@ {{ oc_header }} {{ ovn_copy_shell_vars }} - oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_NB_IP:6641 > /backup/ovs-nb.ovsschema && ovsdb-tool convert /backup/ovs-nb.db /backup/ovs-nb.ovsschema" - oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_SB_IP:6642 > /backup/ovs-sb.ovsschema && ovsdb-tool convert /backup/ovs-sb.db /backup/ovs-sb.ovsschema" + oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_NB_IP:6641 > /backup/ovs-nb.ovsschema && ovsdb-tool convert /backup/ovs-nb.db /backup/ovs-nb.ovsschema" + oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_SB_IP:6642 > /backup/ovs-sb.ovsschema && ovsdb-tool convert /backup/ovs-sb.db /backup/ovs-sb.ovsschema" when: enable_tlse|bool is false - name: upgrade OVN databases to the latest schema from podified ovsdb-servers (tls) @@ -223,8 +230,8 @@ {{ oc_header }} {{ ovn_copy_shell_vars }} - oc exec ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db" - oc exec ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db" + oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db" + oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db" when: enable_tlse|bool - name: deploy podified OVN northd service to keep databases in sync diff --git a/tests/roles/ovn_adoption/tasks/ovn_ospdo_src_vars.yaml b/tests/roles/ovn_adoption/tasks/ovn_ospdo_src_vars.yaml new file mode 100644 index 000000000..429bc23a9 --- /dev/null +++ b/tests/roles/ovn_adoption/tasks/ovn_ospdo_src_vars.yaml @@ -0,0 +1,46 @@ +- name: get ospdo source_ovndb_ip + ansible.builtin.shell: | + oc -n {{ org_namespace }} get cm tripleo-exports-default -o yaml | awk '/ovn_dbs_node_ips:/{getline; print $3}'|tr -d '\\n' + register: source_ovndb_ip_str + +- name: register controller node + no_log: "{{ use_no_log }}" + ansible.builtin.shell: | + oc get vmi -n{{ org_namespace }} -o jsonpath='{.items[0].metadata.labels.kubevirt\.io/nodeName}' + register: controller_node + +- name: get OSPdO storage storageClass + ansible.builtin.shell: | + oc get -n {{ org_namespace }} pvc openstackclient-hosts -o jsonpath='{.spec.storageClassName}' + register: ospdo_storage_class + +- name: set OVN copy shell vars + no_log: "{{ use_no_log }}" + ansible.builtin.set_fact: + ovn_copy_shell_vars: | + STORAGE_CLASS={{ ospdo_storage_class.stdout }} + PODIFIED_OVSDB_NB_IP={{ podified_ovn_nb_ip_result.stdout }} + PODIFIED_OVSDB_SB_IP={{ podified_ovn_sb_ip_result.stdout }} + OVSDB_IMAGE={{ ovn_image }} + + SOURCE_OVSDB_IP={{ source_ovndb_ip_str.stdout }} + + CONTROLLER1_SSH="{{ controller1_ssh }}" + CONTROLLER2_SSH="echo ospdo src env, skipping on controller-1 " + CONTROLLER3_SSH="echo ospdo src env ,skipping on controller-2 " + +- name: create ovn-data-cert secret + ansible.builtin.shell: | + oc apply -f - <