Skip to content

Commit

Permalink
Merge "ext zuul-executor - ci test - enable the test for OLM too"
Browse files Browse the repository at this point in the history
  • Loading branch information
Microzuul CI authored and Gerrit Code Review committed Mar 20, 2024
2 parents 855ff79 + 8992a63 commit e7f74e7
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 106 deletions.
2 changes: 1 addition & 1 deletion doc/developer/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tests run in the [project's CI](https://zuul.microshift.softwarefactory-project.
1. This command is a wrapper on top of `ansible-playbook` to run the same Ansible playbook
than the CI. This includes steps to deploy the operator if needed.

The command requires a configuration file that can be intiated with `go run ./main.go init config`.
The command requires a configuration file that can be intialized with `go run ./main.go init config`.
The path to the configuration file must be specified via the `--config` parameter. A valid file
for running CI jobs locally is available in `playbooks/files/sf-operator-cli.yaml`.

Expand Down
28 changes: 0 additions & 28 deletions playbooks/files/sf-no-ze.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions roles/apply-custom-resources/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
cr_path: playbooks/files/sf.yaml
namespace: sf
2 changes: 1 addition & 1 deletion roles/apply-custom-resources/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Apply the custom resources
ansible.builtin.command: kubectl apply -f playbooks/files/sf.yaml
ansible.builtin.command: kubectl -n {{ namespace }} apply -f {{ cr_path }}
args:
chdir: "{{ zuul.project.src_dir }}"

Expand Down
2 changes: 1 addition & 1 deletion roles/clean-installations-cli/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
- name: Clean up previous operator installation
when: remote_os_host
ansible.builtin.shell: >
go run ./main.go {{ cli_global_flags }} SF wipe --all
go run ./main.go {{ cli_global_flags }} SF wipe --all
args:
chdir: "{{ zuul.project.src_dir | default(src_dir) }}"
60 changes: 0 additions & 60 deletions roles/clean-installations/tasks/main.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions roles/health-check/check-sf-resource-ready/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
retries: 60
delay: 10
reconciledBy: ""
namespace: sf
cr_name: my-sf
6 changes: 3 additions & 3 deletions roles/health-check/check-sf-resource-ready/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
when: mode == 'olm'
block:
- name: Wait for the custom resources to be reconciledBy {{ reconciledBy }}
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.status}'
ansible.builtin.command: kubectl -n {{ namespace }} get sf {{ cr_name }} -o=jsonpath='{.status}'
register: sf_ready
until:
- sf_ready.stdout != ""
Expand All @@ -22,14 +22,14 @@
ansible.builtin.command: sleep 1

- name: Get current resource generation
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.metadata.generation}'
ansible.builtin.command: kubectl -n {{ namespace }} get sf {{ cr_name }} -o=jsonpath='{.metadata.generation}'
register: cr_generation
until: cr_generation.stdout != ""
retries: "{{ retries }}"
delay: "{{ delay }}"

- name: Wait for the custom resources to be ready
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.status}'
ansible.builtin.command: kubectl -n {{ namespace }} get sf {{ cr_name }} -o=jsonpath='{.status}'
register: sf_ready
until:
- sf_ready.stdout != ""
Expand Down
60 changes: 54 additions & 6 deletions roles/health-check/test-external-ze/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
---
### Pre cleaning to ensure that no zuul-executor exists in the adjacent namespace

- name: "Ensure no External Zuul executor running"
ansible.builtin.shell: |
kubectl -n ext-ze delete SoftwareFactory my-ext-ze || true
kubectl -n ext-ze delete sts zuul-executor || true
### Set control plane to deactivate the default zuul-executor and expose required services

- name: "Deactivate the Zuul executor in the control plan"
ansible.builtin.include_role:
name: run-operator-standalone
name: update-custom-resource
vars:
cr_path: playbooks/files/sf-no-ze.yaml
cr_spec:
config-location:
base-url: "http://gerrit-httpd/"
name: config
zuul-connection-name: gerrit
k8s-api-url: "https://microshift.dev:6443"
logserver-host: microshift.dev
zuul:
executor:
enabled: false

- name: Expose a Zookeeper Service as a LoadBalancer (reachable on microshift.dev)
kubernetes.core.k8s:
Expand Down Expand Up @@ -62,6 +80,8 @@
statefulset.kubernetes.io/pod-name: logserver-0
type: LoadBalancer

### Deploy the external zuul-executor in the adjacent namespace

- name: "Sync expected secrets resources from the control plan ns to ext-ze ns"
ansible.builtin.shell: |
kubectl get secrets {{ item }} -o json | jq --arg name {{ item }} '. + {metadata: {name: $name}}' | kubectl apply -n ext-ze -f -
Expand All @@ -72,11 +92,23 @@
- zuul-keystore-password

- name: "Deploy the external Zuul executor"
when: mode == 'standalone'
ansible.builtin.include_role:
name: run-operator-standalone
vars:
cr_path: playbooks/files/ext-ze.yaml
context: ext-ze
log_file: sf-operator_ext-ze.log
current_cr_path: /tmp/current_cr_ext-ze.yaml

- name: "Deploy the external Zuul executor"
when: mode == 'olm'
ansible.builtin.include_role:
name: apply-custom-resources
vars:
cr_path: playbooks/files/ext-ze.yaml
namespace: ext-ze
cr_name: my-ext-ze

- name: Expose a Zuul Executor Finger service as a LoadBalancer (reachable on microshift.dev)
kubernetes.core.k8s:
Expand All @@ -98,14 +130,30 @@
run: zuul-executor
type: LoadBalancer

### Real proof that external executor is running as expected

- name: "Run the 'config-update-zuul' test case"
ansible.builtin.include_role:
name: health-check/config-update-zuul

- name: "Remove the External Zuul executor"
### Post actions

- name: "Ensure no External Zuul executor running"
ansible.builtin.shell: |
kubectl -n ext-ze delete sts zuul-executor
kubectl -n ext-ze delete SoftwareFactory my-ext-ze || true
kubectl -n ext-ze delete sts zuul-executor || true
- name: "Activate the Zuul executor in the control plan"
- name: "Restore the Zuul executor in the control plan (by using the default CR)"
ansible.builtin.include_role:
name: run-operator-standalone
name: update-custom-resource
vars:
cr_spec:
config-location:
base-url: "http://gerrit-httpd/"
name: config
zuul-connection-name: gerrit
k8s-api-url: ""
logserver-host: ""
zuul:
executor:
enabled: true
2 changes: 2 additions & 0 deletions roles/run-operator-standalone/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
glue: true
cr_path: playbooks/files/sf.yaml
context: ci
log_file: sf-operator.log
current_cr_path: /tmp/current_cr.yaml
6 changes: 3 additions & 3 deletions roles/run-operator-standalone/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
# Empty the sf-operator.log output before the run
- name: Ensure ~/zuul-output/logs
ansible.builtin.file:
path: ~/zuul-output/logs/sf-operator.log
path: ~/zuul-output/logs/{{ log_file }}
state: absent
when:
- glue

- name: Run the operator in standalone mode
ansible.builtin.shell: |
set -o pipefail
go run ./main.go {{ cli_global_flags }} --context {{ context }} dev create standalone-sf --cr {{ cr_path }} 2>&1 | tee -a ~/zuul-output/logs/sf-operator.log
go run ./main.go {{ cli_global_flags }} --context {{ context }} dev create standalone-sf --cr {{ cr_path }} 2>&1 | tee -a ~/zuul-output/logs/{{ log_file }}
args:
chdir: "{{ zuul.project.src_dir }}"

- name: Copy current spec
ansible.builtin.shell: "cp {{ cr_path }} /tmp/current_cr.yaml"
ansible.builtin.shell: "cp {{ cr_path }} {{ current_cr_path }}"
args:
chdir: "{{ zuul.project.src_dir }}"
when:
Expand Down
1 change: 0 additions & 1 deletion roles/run-tests/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
- name: zuul-client-api
- name: zuul-components
- name: test-external-ze
when: "{{ mode == 'standalone' }}"
- name: test-log-forwarding
- name: backup
loop_control:
Expand Down
4 changes: 2 additions & 2 deletions roles/update-custom-resource/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
- name: "Update CRD"
when: mode == 'olm'
block:
- name: "Update SoftwareFactory resource {{ cr_name }}"
- name: "Update SoftwareFactory resource (using k8s module)"
kubernetes.core.k8s:
kubeconfig: "{{ kubeconfig }}"
definition:
kind: "{{ cr_kind }}"
namespace: "{{ cr_namespace }}"
metadata:
name: "{{ cr_name }}"
namespace: sf
namespace: "{{ cr_namespace }}"
spec: "{{ cr_spec }}"

- ansible.builtin.include_role:
Expand Down

0 comments on commit e7f74e7

Please sign in to comment.