Skip to content

Commit 6b296f8

Browse files
Tobiko can be executed with test-operator
Before this patch, tobiko tests could only be executed using the ci-fmw's tobiko role and the ci-fmw's test_operator role only supported tempest. With this patch, tobiko tests can be run using the test_operator role as well. TODO: - support tobiko workflows - requires changes in tcib - pass relevant env variables to the tobiko container - requires changes in test-operator
1 parent b12c752 commit 6b296f8

File tree

10 files changed

+446
-209
lines changed

10 files changed

+446
-209
lines changed

deploy-edpm.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,13 @@
4747
tags:
4848
- admin-setup
4949

50-
- name: Import run tempest test playbook
50+
- name: Import run test playbook
5151
ansible.builtin.import_playbook: playbooks/08-run-tests.yml
5252
vars:
5353
pre_tests: "{{ (lookup('vars', 'pre_tempest', default=[])) }}"
5454
post_tests: "{{ (lookup('vars', 'post_tempest', default=[])) }}"
55-
test_fw: "tempest"
5655
when:
5756
- cifmw_run_tests | default('false') | bool
58-
- cifmw_run_tempest | default('true') | bool
59-
tags:
60-
- run-tests
61-
62-
- name: Import run tobiko test playbook
63-
ansible.builtin.import_playbook: playbooks/08-run-tests.yml
64-
vars:
65-
pre_tests: "{{ (lookup('vars', 'pre_tobiko', default=[])) }}"
66-
post_tests: "{{ (lookup('vars', 'post_tobiko', default=[])) }}"
67-
test_fw: "tobiko"
68-
when:
69-
- cifmw_run_tests | default('false') | bool
70-
- cifmw_run_tobiko | default('false') | bool
7157
tags:
7258
- run-tests
7359

playbooks/08-run-tests.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
- name: "Run pre_tests hooks for {{ test_fw | default('tempest') }}"
1+
- name: "Run pre_tests hooks"
22
vars:
33
hooks: "{{ pre_tests | default([]) }}"
44
step: pre_tests
55
ansible.builtin.import_playbook: ./hooks.yml
66

7-
- name: "Test playbook for {{ run_test_fw }}"
8-
vars:
9-
run_test_fw: "{{ test_fw | default('tempest') }}"
7+
- name: "Test playbook"
108
hosts: "{{ cifmw_target_host | default('localhost') }}"
119
gather_facts: false
1210
tasks:
13-
- name: "Run {{ run_test_fw }}"
11+
- name: "Run tests"
12+
vars:
13+
tempest_bool: cifmw_run_tempest | default('true') | bool
14+
tobiko_bool: cifmw_run_tobiko | default('false') | bool
15+
test_role: >-
16+
{{ cifmw_run_test_role |
17+
default('tempest' if tempest_bool
18+
else ('tobiko' if tobiko_bool else None))
19+
}}
1420
tags:
1521
- tests
1622
ansible.builtin.import_role:
17-
name: "{{ run_test_fw }}"
23+
name: "{{ test_role }}"
1824

19-
- name: "Run post_tests hooks for {{ test_fw | default('tempest') }}"
25+
- name: "Run post_tests hooks"
2026
vars:
2127
hooks: "{{ post_tests | default([]) }}"
2228
step: post_tests

roles/test_operator/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,32 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
4646
externalPlugin: "{{ cifmw_test_operator_tempest_external_plugin | default([]) }}"
4747
tempestconfRun: "{{ cifmw_tempest_tempestconf_config | default(omit) }}"
4848
```
49+
50+
## Tobiko specific parameters
51+
* `cifmw_test_operator_tobiko_registry`: (String) The registry where to pull tobiko container. Default value: `quay.io`
52+
* `cifmw_test_operator_tobiko_namespace`: (String) Registry's namespace where to pull tobiko container. Default value: `podified-antelope-centos9`
53+
* `cifmw_test_operator_tobiko_container`: (String) Name of the tobiko container. Default value: `openstack-tobiko`
54+
* `cifmw_test_operator_tobiko_image`: (String) Tobiko image to be used. Default value: `{{ cifmw_test_operator_tobiko_registry }}/{{ cifmw_test_operator_tobiko_namespace }}/{{ cifmw_test_operator_tobiko_container }}`
55+
* `cifmw_test_operator_tobiko_image_tag`: (String) Tag for the `cifmw_test_operator_tobiko_image`. Default value: `current-podified`
56+
* `cifmw_test_operator_tobiko_testenv`: (String) Executed tobiko testenv. See tobiko `tox.ini` file for further details. Some allowed values: scenario, sanity, faults, neutron, octavia, py3, etc. Default value: `scenario`
57+
* `cifmw_test_operator_tobiko_version`: (String) Tobiko version to install. It could refer to a branch (master, osp-16.2), a tag (0.6.x, 0.7.x) or an sha-1. Default value: `master`
58+
* `cifmw_test_operator_tobiko_kubeconfig_secret`: (String) Name of the Openshift Secret required to use Openshift Client from the Tobiko pod. Default value: `tobiko-secret`
59+
* `cifmw_test_operator_tobiko_override_conf`: (Dict) Overrides the default configuration from `cifmw_test_operator_tobiko_default_conf` that is used to generate the tobiko.conf file. Default value: empty dictionary
60+
* `cifmw_test_operator_tobiko_ssh_keytype`: (String) Type of ssh key that tobiko will use to connect to the VM instances it creates. Defaults to `cifmw_ssh_keytype` which default to `ecdsa`.
61+
* `cifmw_test_operator_tobiko_ssh_keysize`: (Integer) Size of ssh key that tobiko will use to connect to the VM instances it creates. Defaults to `cifmw_ssh_keysize` which defaults to 521.
62+
* `cifmw_test_operator_tobiko_config`: (Dict) Definition of Tobiko CRD instance that is passed to the test-operator (see [the test-operator documentation](https://openstack-k8s-operators.github.io/test-operator/crds.html#tobiko-custom-resource)). Default value:
63+
```
64+
apiVersion: test.openstack.org/v1beta1
65+
kind: Tobiko
66+
metadata:
67+
name: tobiko-tests
68+
namespace: "{{ cifmw_test_operator_namespace }}"
69+
spec:
70+
kubeconfigSecretName: "{{ cifmw_test_operator_tobiko_kubeconfig_secret }}"
71+
containerImage: "{{ cifmw_test_operator_tobiko_image }}:{{ cifmw_test_operator_tobiko_image_tag }}"
72+
testenv: "{{ cifmw_test_operator_tobiko_testenv }}"
73+
version: "{{ cifmw_test_operator_tobiko_version }}"
74+
# privateKey: privateKey is automatically generated by the test_operator role
75+
# publicKey: publicKey is automatically generated by the test_operator role
76+
# config: config is generated combining cifmw_test_operator_tobiko_default_conf and cifmw_test_operator_tobiko_override_conf
77+
```

roles/test_operator/defaults/main.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
# defaults file for test_operator
1919
# All variables within this role should have a prefix of "cifmw_test_operator"
20+
21+
# Section 1: generic parameters (applied to all supported test frameworks)
2022
cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator"
2123
cifmw_test_operator_namespace: openstack
2224
cifmw_test_operator_index: quay.io/openstack-k8s-operators/test-operator-index:latest
@@ -25,12 +27,19 @@ cifmw_test_operator_logs_image: quay.io/quay/busybox
2527
cifmw_test_operator_concurrency: 8
2628
cifmw_test_operator_cleanup: false
2729
cifmw_test_operator_dry_run: false
30+
cifmw_test_operator_default_groups:
31+
- default
32+
cifmw_test_operator_default_jobs:
33+
- default
34+
35+
# Section 2: tempest parameters - used when run_test_fw is 'tempest'
2836
cifmw_test_operator_tempest_registry: quay.io
2937
cifmw_test_operator_tempest_namespace: podified-antelope-centos9
3038
cifmw_test_operator_tempest_container: openstack-tempest
3139
cifmw_test_operator_tempest_image: "{{ cifmw_test_operator_tempest_registry }}/{{ cifmw_test_operator_tempest_namespace }}/{{ cifmw_test_operator_tempest_container }}"
3240
cifmw_test_operator_tempest_image_tag: current-podified
33-
41+
cifmw_test_operator_tempest_tests_include_override_scenario: false
42+
cifmw_test_operator_tempest_tests_exclude_override_scenario: false
3443
# Please refer to https://openstack-k8s-operators.github.io/test-operator/guide.html#executing-tempest-tests
3544
cifmw_test_operator_tempest_config:
3645
apiVersion: test.openstack.org/v1beta1
@@ -51,9 +60,29 @@ cifmw_test_operator_tempest_config:
5160
externalPlugin: "{{ cifmw_test_operator_tempest_external_plugin | default([]) }}"
5261
tempestconfRun: "{{ cifmw_tempest_tempestconf_config | default(omit) }}"
5362

54-
cifmw_test_operator_default_groups:
55-
- default
56-
cifmw_test_operator_default_jobs:
57-
- default
58-
cifmw_test_operator_tempest_tests_include_override_scenario: false
59-
cifmw_test_operator_tempest_tests_exclude_override_scenario: false
63+
# Section 3: tobiko parameters - used when run_test_fw is 'tobiko'
64+
cifmw_test_operator_tobiko_registry: quay.io
65+
cifmw_test_operator_tobiko_namespace: podified-antelope-centos9
66+
cifmw_test_operator_tobiko_container: openstack-tobiko
67+
cifmw_test_operator_tobiko_image: "{{ cifmw_test_operator_tobiko_registry }}/{{ cifmw_test_operator_tobiko_namespace }}/{{ cifmw_test_operator_tobiko_container }}"
68+
cifmw_test_operator_tobiko_image_tag: current-podified
69+
cifmw_test_operator_tobiko_testenv: scenario
70+
cifmw_test_operator_tobiko_version: master
71+
cifmw_test_operator_tobiko_override_conf: {}
72+
cifmw_test_operator_tobiko_kubeconfig_secret: tobiko-secret
73+
cifmw_test_operator_tobiko_ssh_keytype: "{{ cifmw_ssh_keytype | default('ecdsa') }}"
74+
cifmw_test_operator_tobiko_ssh_keysize: "{{ cifmw_ssh_keysize | default(521) }}"
75+
cifmw_test_operator_tobiko_config:
76+
apiVersion: test.openstack.org/v1beta1
77+
kind: Tobiko
78+
metadata:
79+
name: tobiko-tests
80+
namespace: "{{ cifmw_test_operator_namespace }}"
81+
spec:
82+
kubeconfigSecretName: "{{ cifmw_test_operator_tobiko_kubeconfig_secret }}"
83+
containerImage: "{{ cifmw_test_operator_tobiko_image }}:{{ cifmw_test_operator_tobiko_image_tag }}"
84+
testenv: "{{ cifmw_test_operator_tobiko_testenv }}"
85+
version: "{{ cifmw_test_operator_tobiko_version }}"
86+
# privateKey: privateKey is automatically by the test_operator role
87+
# publicKey: publicKey is automatically generated by the test_operator role
88+
# config: config is generated combining cifmw_test_operator_tobiko_default_conf and cifmw_test_operator_tobiko_override_conf

roles/test_operator/tasks/cleanup.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,6 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
- name: Delete Tempest
18-
kubernetes.core.k8s:
19-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
20-
api_key: "{{ cifmw_openshift_token | default(omit)}}"
21-
context: "{{ cifmw_openshift_context | default(omit)}}"
22-
kind: Tempest
23-
state: absent
24-
api_version: test.openstack.org/v1beta1
25-
name: "{{ cifmw_test_operator_tempest_name }}"
26-
namespace: "{{ cifmw_test_operator_namespace }}"
27-
wait: true
28-
29-
- name: Delete Tempest CRD
30-
kubernetes.core.k8s:
31-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
32-
api_key: "{{ cifmw_openshift_token | default(omit)}}"
33-
context: "{{ cifmw_openshift_context | default(omit)}}"
34-
kind: CustomResourceDefinition
35-
state: absent
36-
api_version: v1
37-
name: tempests.test.openstack.org
38-
namespace: "{{ cifmw_test_operator_namespace }}"
39-
wait: true
40-
4117
- name: Delete Subscription
4218
kubernetes.core.k8s:
4319
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
@@ -97,15 +73,3 @@
9773
name: test-operator.openstack
9874
namespace: "{{ cifmw_test_operator_namespace }}"
9975
wait: true
100-
101-
- name: Delete test-operator-logs-pod
102-
kubernetes.core.k8s:
103-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
104-
api_key: "{{ cifmw_openshift_token | default(omit)}}"
105-
context: "{{ cifmw_openshift_context | default(omit)}}"
106-
kind: Pod
107-
state: absent
108-
api_version: v1
109-
name: test-operator-logs-pod
110-
namespace: "{{ cifmw_test_operator_namespace }}"
111-
wait: true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
#
17+
- name: Create tobiko.conf section by section
18+
community.general.ini_file:
19+
path: "{{ cifmw_test_operator_artifacts_basedir }}/tobiko.conf"
20+
section: "{{ tobikoconf_section.key }}"
21+
option: "{{ tobikoconf_option.key }}"
22+
value: "{{ tobikoconf_option.value }}"
23+
loop: "{{ tobikoconf_section.value | dict2items }}"
24+
loop_control:
25+
loop_var: tobikoconf_option

0 commit comments

Comments
 (0)