Skip to content

Commit

Permalink
CVP-1871. Modified config file by removing items in skip-list and fix…
Browse files Browse the repository at this point in the history
…ed ansible lint errors. Removed ansible-lint.yml.
  • Loading branch information
LikhithaEda committed Jul 9, 2021
1 parent 6f4c417 commit aafbc79
Show file tree
Hide file tree
Showing 68 changed files with 528 additions and 383 deletions.
17 changes: 13 additions & 4 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
exclude_paths:
- .cache/ # implicit unless exclude_paths is defined in config
- .github/
- roles/
- Dockerfiles
- ./*.yml
- yamllint.yml

warn_list: [] # or 'skip_list' to silence them completely
warn_list: [] # or 'skip_list' to silence them completely

skip_list:
- deprecated-command-syntax # Using command rather than an argument to e.g. file
Expand All @@ -17,4 +16,14 @@ skip_list:
- command-instead-of-shell # Use shell only when shell functionality is required
# - yaml # Violations reported by yamllint
- line-length
- comments
- '102' # No Jinja2
- '206' # Variables should have spaces before and after: {{ var_name}}
- '301' # All tasks should be named
- '302' # Include should has tags
- '303' # Use ":" YAML syntax when arguments are over 4
- '305' # Variable should has space "{{ foo }}"
- '306' # Shells that use pipes should set the pipefail option
- '403' # Package installs should not use latest
- '502' # Use chown module
- '601' # trailing whitespace
- '602' # line too long
27 changes: 0 additions & 27 deletions ansible-lint.yml

This file was deleted.

29 changes: 20 additions & 9 deletions deploy-olm-operator.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
- name: Deploy the operator on an OCP cluster with OLM as part of the operator testing pipeline
- name: >
Deploy the operator on an OCP
cluster with OLM as part of the
operator testing pipeline
hosts: all
become: false
gather_facts: false
Expand All @@ -15,27 +18,28 @@
quay_token: "{{ quay_token }}"
quay_namespace: "cvpops"
oc_bin_path: "{{ 'kubectl' if run_upstream else 'oc' }}"
jq_bin_path : "/usr/bin/jq"
jq_bin_path: "/usr/bin/jq"
yq_bin_path: "/usr/local/bin/yq"
testing_bin_path: "/usr/local/bin"
scorecard_first_cr: true
run_scorecard: true
current_channel: '' # Added to avoid a bug with undefined variables

current_channel: '' # Added to avoid a bug with undefined variables


tasks:
- name: "Login to the testing OpenShift instance"
shell: "{{ oc_bin_path }} login {{ openshift_url }} -u system:admin --insecure-skip-tls-verify"
shell: >
"{{ oc_bin_path }} login {{ openshift_url }}
-u system:admin --insecure-skip-tls-verify"
register: login_result
retries: 20
delay: 10
until: login_result.rc == 0
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
when:
- openshift_url is defined
- not run_upstream|bool
- openshift_url is defined
- not run_upstream|bool

- name: "Parse operator metadata needed to run the tests"
include_role:
Expand All @@ -52,8 +56,15 @@
include_role:
name: deploy_olm_operator
always:
- name: "Remove the quay release of the test operator in the testing namespace"
shell: "curl -s -H \"Authorization: basic {{ quay_token }}\" -X DELETE https://quay.io/cnr/api/v1/packages/{{ quay_namespace }}/{{ package_name }}-test/{{ quay_release }}/helm"
- name: >
"Remove the quay release of the
test operator in the testing namespace"
shell: >
"curl -s -H \"Authorization: basic
{{ quay_token }}\" -X DELETE
https://quay.io/cnr/api/v1/packages/{{
quay_namespace }}/{{ package_name }}-test/{{
quay_release }}/helm"
when:
- quay_release is defined
- package_name is defined
Expand Down
4 changes: 3 additions & 1 deletion extract-operator-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
umoci_bin_path: "/usr/local/bin/umoci"

tasks:
- name: "Extract the operator bundle image into files needed to run the tests"
- name: >
"Extract the operator bundle
image into files needed to run the tests"
include_role:
name: extract_operator_bundle
Expand Down
20 changes: 15 additions & 5 deletions local-test-operator-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
run_catalog_init: true
work_dir: "/tmp/operator-test"
testing_bin_path: "{{ work_dir }}/bin"
current_channel: '' # Added to avoid a potential bug with undefined variables
current_channel: >
'' # Added to avoid a potential
bug with undefined variables
olm_ver: 0.14.1

tasks:
Expand All @@ -24,7 +26,9 @@
umoci_bin_path: "{{ testing_bin_path }}/umoci"
opm_bin_path: "{{ testing_bin_path }}/opm"
operator_sdk_bin_path: "{{ testing_bin_path }}/operator-sdk"
oc_bin_path: '{{ ''kubectl'' if run_upstream else "{{ testing_bin_path }}/oc" }}'
oc_bin_path: >
'{{ ''kubectl'' if run_upstream
else "{{ testing_bin_path }}/oc" }}'
- name: "Install operator testing prerequisites"
Expand All @@ -37,7 +41,9 @@
name: build_image_bundle
when: run_upstream|bool

- name: "Extract the operator bundle image into files needed to run the tests"
- name: >
"Extract the operator bundle image
into files needed to run the tests"
include_role:
name: extract_operator_bundle
Expand All @@ -64,10 +70,14 @@
- name: "Install OLM"
block:
- name: "Installing OLM"
shell: "{{ operator_sdk_bin_path }} olm install --version {{ olm_ver }}"
shell: >
"{{ operator_sdk_bin_path }} olm
install --version {{ olm_ver }}"
- name: "Delete catalogsource"
shell: "{{ oc_bin_path }} delete catalogsource operatorhubio-catalog -n olm"
shell: >
"{{ oc_bin_path }} delete catalogsource
operatorhubio-catalog -n olm"
ignore_errors: true
when:
- olm_needed.stdout != "operatorgroup"
Expand Down
96 changes: 74 additions & 22 deletions local-test-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
openshift_namespace: "test-operator"
work_dir: "/tmp/operator-test"
testing_bin_path: "{{ work_dir }}/bin"
current_channel: '' # Added to avoid a potential bug with undefined variables
current_channel: >
'' # Added to avoid a potential
bug with undefined variables
olm_ver: 0.14.1
events_file_path: "{{ work_dir }}/events.json"

Expand All @@ -39,7 +41,9 @@
scorecard_cr_dir: "{{ work_dir }}/scorecard-cr-files"
kube_objects_dir: "{{ work_dir }}/kube_objects"
testing_bin_path: "{{ work_dir }}/bin"
oc_bin_path: '{{ ''kubectl'' if run_upstream else "{{ testing_bin_path }}/oc" }}'
oc_bin_path: >
'{{ ''kubectl'' if run_upstream else
"{{ testing_bin_path }}/oc" }}'
jq_bin_path: "{{ testing_bin_path }}/jq"
yq_bin_path: "{{ testing_bin_path }}/yq"
go_bin_path: "{{ testing_bin_path }}/go/bin/go"
Expand Down Expand Up @@ -82,10 +86,14 @@
- name: "Install OLM"
block:
- name: "Installing OLM"
shell: "{{ operator_sdk_bin_path }} olm install --version {{ olm_ver }}"
shell: >
"{{ operator_sdk_bin_path }}
olm install --version {{ olm_ver }}"
- name: "Delete catalogsource"
shell: "{{ oc_bin_path }} delete catalogsource operatorhubio-catalog -n olm"
shell: >
"{{ oc_bin_path }} delete catalogsource
operatorhubio-catalog -n olm"
ignore_errors: true
when:
- olm_needed.stdout != "operatorgroup"
Expand All @@ -96,23 +104,27 @@
name: build_catalog_upstream
when: run_upstream|bool

- name: "Run operator-courier nest to copy the operator metadata in nested format to the work dir"
- name: >
"Run operator-courier nest to copy the
operator metadata in nested format to the work dir"
shell: "operator-courier nest {{ operator_dir }} {{ operator_work_dir }}"
when: not run_upstream|bool
- name: Copy the operator metadata in nested format to the work dir
copy:
src: "{{ operator_dir }}/"
dest: "{{ operator_work_dir }}"
remote_src: yes
remote_src: true
mode: 0644
when: run_upstream|bool

- name: "Parse operator metadata needed to run the tests (Openshift)"
include_role:
name: parse_operator_metadata

- name: "Run linting tests with operator-courier verify on the deployed operator"
- name: >
"Run linting tests with operator-courier
verify on the deployed operator"
include_role:
name: operator_courier_verify
when: run_lint|bool
Expand All @@ -133,24 +145,37 @@
- run_scorecard|bool
- not run_upstream|bool

- name: "Get all registry images on the OpenShift cluster before deploying the operator"
shell: "{{ oc_bin_path }} get is --all-namespaces -o json | jq '.items[].spec.tags[] | select(.from.kind == \"DockerImage\") | .from.name' --raw-output | sort -u"
- name: >
"Get all registry images on the OpenShift
cluster before deploying the operator"
shell: >
"{{ oc_bin_path }} get is --all-namespaces
-o json | jq '.items[].spec.tags[] |
select(.from.kind == \"DockerImage\") |
.from.name' --raw-output | sort -u"
register: os_registry_is_result_before
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
no_log: true
when: not run_upstream|bool
- name: "Get all pod images on the OpenShift cluster before deploying the operator"
shell: "{{ oc_bin_path }} get pods --all-namespaces -o json | jq '.items[].spec.containers[].image' --raw-output | sort -u"
- name: >
"Get all pod images on the OpenShift
cluster before deploying the operator"
shell: >
"{{ oc_bin_path }} get pods --all-namespaces
-o json | jq '.items[].spec.containers[].image'
--raw-output | sort -u"
register: os_pod_is_result_before
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
no_log: true
when: not run_upstream|bool
- set_fact:
openshift_images_before: " {{ os_registry_is_result_before.stdout_lines }} + {{ os_pod_is_result_before.stdout_lines }}"
openshift_images_before: >
" {{ os_registry_is_result_before.stdout_lines
}} + {{ os_pod_is_result_before.stdout_lines }}"
when: not run_upstream|bool

- name: "Set the deployment start time"
Expand Down Expand Up @@ -186,29 +211,40 @@
- run_upstream|bool

- name: "Get all openshift registry images"
shell: "{{ oc_bin_path }} get is --all-namespaces -o json | jq '.items[].spec.tags[] | select(.from.kind == \"DockerImage\") | .from.name' --raw-output | sort -u"
shell: >
"{{ oc_bin_path }} get is --all-namespaces
-o json | jq '.items[].spec.tags[] |
select(.from.kind == \"DockerImage\") |
.from.name' --raw-output | sort -u"
register: os_registry_is_result_after
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
no_log: true
when: not run_upstream|bool

- name: "Get all OpenShift pod images"
shell: "{{ oc_bin_path }} get pods --all-namespaces -o json | jq '.items[].spec.containers[].image' --raw-output | sort -u"
shell: >
"{{ oc_bin_path }} get pods --all-namespaces
-o json | jq '.items[].spec.containers[].image'
--raw-output | sort -u"
register: os_pod_is_result_after
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
no_log: true
when: not run_upstream|bool

- set_fact:
openshift_images_after: "{{ os_registry_is_result_after.stdout_lines }} + {{ os_pod_is_result_after.stdout_lines }}"
openshift_images_after: >
"{{ os_registry_is_result_after.stdout_lines }}
+ {{ os_pod_is_result_after.stdout_lines }}"
when: not run_upstream|bool

- name: "Scorecard test"
block:
- name: "Find all extracted CRs from alm-examples"
shell: "find \"{{ scorecard_cr_dir }}\" -name \"*.cr.yaml\" -print"
shell: >
"find \"{{ scorecard_cr_dir }}\"
-name \"*.cr.yaml\" -print"
register: scorecard_cr_files_result
when:
- run_scorecard|bool
Expand All @@ -224,8 +260,14 @@
- run_scorecard|bool
- run_deploy|bool
always:
- name: "Get the pod container logs of the operator after running scorecard tests"
shell: "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }}"
- name: >
"Get the pod container logs of the
operator after running scorecard tests"
shell: >
"{{ oc_bin_path }} get --output=name pods
| grep {{ operator_pod_name }} | xargs -I{}
{{ oc_bin_path }} logs {} -c {{
operator_container_name }}"
register: operator_container_result
ignore_errors: true
environment:
Expand All @@ -241,11 +283,15 @@

when: not run_upstream|bool

- name: "Test image sources of containers introduced with the testing operator"
- name: >
"Test image sources of containers
introduced with the testing operator"
include_role:
name: operator_imagesource_test
vars:
operator_images: "{{ openshift_images_after | difference(openshift_images_before) | list }}"
operator_images: >
"{{ openshift_images_after |
difference(openshift_images_before) | list }}"
when:
- run_imagesource|bool
- run_deploy|bool
Expand All @@ -262,8 +308,14 @@
- run_cleanup|bool
- run_deploy|bool

- name: "Remove the quay release of the test operator in the testing namespace"
shell: "curl -s -H \"Authorization: basic {{ quay_token }}\" -X DELETE https://quay.io/cnr/api/v1/packages/{{ quay_namespace }}/{{ package_name }}-test/{{ quay_release }}/helm"
- name: >
"Remove the quay release of the
test operator in the testing namespace"
shell: >
"curl -s -H \"Authorization: basic {{ quay_token }}\"
-X DELETE https://quay.io/cnr/api/v1/packages/{{
quay_namespace }}/{{ package_name }}-test/{{
quay_release }}/helm"
when:
- quay_release is defined
- package_name is defined
Expand Down
Loading

0 comments on commit aafbc79

Please sign in to comment.