| Andrea Frittoli | f32f3f5 | 2018-02-19 21:45:22 +0000 | [diff] [blame] | 1 | =============================== | 
 | 2 | Migrating Zuul V2 CI jobs to V3 | 
 | 3 | =============================== | 
 | 4 |  | 
 | 5 | The OpenStack CI system moved from Zuul v2 to Zuul v3, and all CI jobs moved to | 
 | 6 | the new CI system. All jobs have been migrated automatically to a format | 
 | 7 | compatible with Zuul v3; the jobs produced in this way however are suboptimal | 
 | 8 | and do not use the capabilities introduced by Zuul v3, which allow for re-use of | 
 | 9 | job parts, in the form of Ansible roles, as well as inheritance between jobs. | 
 | 10 |  | 
 | 11 | DevStack hosts a set of roles, plays and jobs that can be used by other | 
 | 12 | repositories to define their DevStack based jobs. To benefit from them, jobs | 
 | 13 | must be migrated from the legacy v2 ones into v3 native format. | 
 | 14 |  | 
 | 15 | This document provides guidance and examples to make the migration process as | 
 | 16 | painless and smooth as possible. | 
 | 17 |  | 
 | 18 | Where to host the job definitions. | 
 | 19 | ================================== | 
 | 20 |  | 
 | 21 | In Zuul V3 jobs can be defined in the repository that contains the code they | 
 | 22 | excercise. If you are writing CI jobs for an OpenStack service you can define | 
 | 23 | your DevStack based CI jobs in one of the repositories that host the code for | 
 | 24 | your service. If you have a branchless repo, like a Tempest plugin, that is | 
 | 25 | a convenient choice to host the job definitions since job changes do not have | 
 | 26 | to be backported. For example, see the beginning of the ``.zuul.yaml`` from the | 
 | 27 | sahara Tempest plugin repo: | 
 | 28 |  | 
 | 29 | .. code:: yaml | 
 | 30 |  | 
 | 31 |   # In http://git.openstack.org/cgit/openstack/sahara-tests/tree/.zuul.yaml: | 
 | 32 |   - job: | 
 | 33 |       name: sahara-tests-tempest | 
 | 34 |       description: | | 
 | 35 |         Run Tempest tests from the Sahara plugin. | 
 | 36 |       parent: devstack-tempest | 
 | 37 |  | 
 | 38 | Which base job to start from | 
 | 39 | ============================ | 
 | 40 |  | 
 | 41 | If your job needs an OpenStack cloud deployed via DevStack, but you don't plan | 
 | 42 | on running Tempest tests, you can start from one of the base | 
 | 43 | :doc:`jobs <zuul_jobs>` defined in the DevStack repo. | 
 | 44 |  | 
 | 45 | The ``devstack`` job can be used for both single-node jobs and multi-node jobs, | 
 | 46 | and it includes the list of services used in the integrated gate (keystone, | 
 | 47 | glance, nova, cinder, neutron and swift). Different topologies can be achieved | 
 | 48 | by switching the nodeset used in the child job. | 
 | 49 |  | 
 | 50 | The ``devstack-base`` job is similar to ``devstack`` but it does not specify any | 
 | 51 | required repo or service to be run in DevStack. It can be useful to setup | 
 | 52 | children jobs that use a very narrow DevStack setup. | 
 | 53 |  | 
 | 54 | If your job needs an OpenStack cloud deployed via DevStack, and you do plan | 
 | 55 | on running Tempest tests, you can start from one of the base jobs defined in the | 
 | 56 | Tempest repo. | 
 | 57 |  | 
 | 58 | The ``devstack-tempest`` job can be used for both single-node jobs and | 
 | 59 | multi-node jobs. Different topologies can be achieved by switching the nodeset | 
 | 60 | used in the child job. | 
 | 61 |  | 
 | 62 | Jobs can be customized as follows without writing any Ansible code: | 
 | 63 |  | 
 | 64 | - add and/or remove DevStack services | 
 | 65 | - add or modify DevStack and services configuration | 
 | 66 | - install DevStack plugins | 
 | 67 | - extend the number of sub-nodes (multinode only) | 
 | 68 | - define extra log files and/or directories to be uploaded on logs.o.o | 
 | 69 | - define extra log file extensions to be rewritten to .txt for ease of access | 
 | 70 |  | 
 | 71 | Tempest jobs can be further customized as follows: | 
 | 72 |  | 
 | 73 | - define the Tempest tox environment to be used | 
 | 74 | - define the test concurrency | 
 | 75 | - define the test regular expression | 
 | 76 |  | 
 | 77 | Writing Ansible code, or importing existing custom roles, jobs can be further | 
 | 78 | extended by: | 
 | 79 |  | 
 | 80 | - adding pre and/or post playbooks | 
 | 81 | - overriding the run playbook, add custom roles | 
 | 82 |  | 
 | 83 | The (partial) example below extends a Tempest single node base job | 
 | 84 | "devstack-tempest" in the Kuryr repository. The parent job name is defined in | 
 | 85 | job.parent. | 
 | 86 |  | 
 | 87 | .. code:: yaml | 
 | 88 |  | 
 | 89 |   # https://git.openstack.org/cgit/openstack/kuryr-kubernetes/tree/.zuul.yaml: | 
 | 90 |   - job: | 
 | 91 |       name: kuryr-kubernetes-tempest-base | 
 | 92 |       parent: devstack-tempest | 
 | 93 |       description: Base kuryr-kubernetes-job | 
 | 94 |       required-projects: | 
 | 95 |         - openstack/devstack-plugin-container | 
 | 96 |         - openstack/kuryr | 
 | 97 |         - openstack/kuryr-kubernetes | 
 | 98 |         - openstack/kuryr-tempest-plugin | 
 | 99 |         - openstack/neutron-lbaas | 
 | 100 |       vars: | 
 | 101 |         tempest_test_regex: '^(kuryr_tempest_plugin.tests.)' | 
 | 102 |         tox_envlist: 'all' | 
 | 103 |         devstack_localrc: | 
 | 104 |           KURYR_K8S_API_PORT: 8080 | 
 | 105 |           TEMPEST_PLUGINS: '/opt/stack/kuryr-tempest-plugin' | 
 | 106 |         devstack_services: | 
 | 107 |           kubernetes-api: true | 
 | 108 |           kubernetes-controller-manager: true | 
 | 109 |           kubernetes-scheduler: true | 
 | 110 |           kubelet: true | 
 | 111 |           kuryr-kubernetes: true | 
 | 112 |           (...) | 
 | 113 |         devstack_plugins: | 
 | 114 |           kuryr-kubernetes: https://git.openstack.org/openstack/kuryr | 
 | 115 |           devstack-plugin-container: https://git.openstack.org/openstack/devstack-plugin-container | 
 | 116 |           neutron-lbaas: https://git.openstack.org/openstack/neutron-lbaas | 
 | 117 |         (...) | 
 | 118 |  | 
 | 119 | Job variables | 
 | 120 | ============= | 
 | 121 |  | 
 | 122 | Variables can be added to the job in three different places: | 
 | 123 |  | 
 | 124 | - job.vars: these are global variables available to all node in the nodeset | 
 | 125 | - job.host-vars.[HOST]: these are variables available only to the specified HOST | 
 | 126 | - job.group-vars.[GROUP]: these are variables available only to the specified | 
 | 127 |   GROUP | 
 | 128 |  | 
 | 129 | Zuul merges dict variables through job inheritance. Host and group variables | 
 | 130 | override variables with the same name defined as global variables. | 
 | 131 |  | 
 | 132 | In the example below, for the sundaes job, hosts that are not part of the | 
 | 133 | subnode group will run vanilla and chocolate. Hosts in the subnode group will | 
 | 134 | run stracciatella and strawberry. | 
 | 135 |  | 
 | 136 | .. code:: yaml | 
 | 137 |  | 
 | 138 |   - job: | 
 | 139 |       name: ice-creams | 
 | 140 |       vars: | 
 | 141 |         devstack_service: | 
 | 142 |           vanilla: true | 
 | 143 |           chocolate: false | 
 | 144 |       group-vars: | 
 | 145 |         subnode: | 
 | 146 |           devstack_service: | 
 | 147 |             pistacchio: true | 
 | 148 |             stracciatella: true | 
 | 149 |  | 
 | 150 |   - job: | 
 | 151 |       name: sundaes | 
 | 152 |       parent: ice-creams | 
 | 153 |       vars: | 
 | 154 |         devstack_service: | 
 | 155 |           chocolate: true | 
 | 156 |       group-vars: | 
 | 157 |         subnode: | 
 | 158 |           devstack_service: | 
 | 159 |             strawberry: true | 
 | 160 |             pistacchio: false | 
 | 161 |  | 
 | 162 |  | 
 | 163 | DevStack Gate Flags | 
 | 164 | =================== | 
 | 165 |  | 
 | 166 | The old CI system worked using a combination of DevStack, Tempest and | 
 | 167 | devstack-gate to setup a test environment and run tests against it. With Zuul | 
 | 168 | V3, the logic that used to live in devstack-gate is moved into different repos, | 
 | 169 | including DevStack, Tempest and grenade. | 
 | 170 |  | 
 | 171 | DevStack-gate exposes an interface for job definition based on a number of | 
 | 172 | DEVSTACK_GATE_* environment variables, or flags. This guide shows how to map | 
 | 173 | DEVSTACK_GATE flags into the new | 
 | 174 | system. | 
 | 175 |  | 
 | 176 | The repo column indicates in which repository is hosted the code that replaces | 
 | 177 | the devstack-gate flag. The new implementation column explains how to reproduce | 
 | 178 | the same or a similar behaviour in Zuul v3 jobs. For localrc settings, | 
 | 179 | devstack-gate defined a default value. In ansible jobs the default is either the | 
 | 180 | value defined in the parent job, or the default from DevStack, if any. | 
 | 181 |  | 
 | 182 | ==============================================  ============= ================== | 
 | 183 | DevStack gate flag                              Repo          New implementation | 
 | 184 | ==============================================  ============= ================== | 
 | 185 | OVERRIDE_ZUUL_BRANCH                            zuul          override-checkout: | 
 | 186 |                                                               [branch] | 
 | 187 |                                                               in the job definition. | 
 | 188 | DEVSTACK_GATE_NET_OVERLAY                       zuul-jobs     A bridge called | 
 | 189 |                                                               br-infra is set up for | 
 | 190 |                                                               all jobs that inherit | 
 | 191 |                                                               from multinode with | 
 | 192 |                                                               a dedicated `bridge role <https://docs.openstack.org/infra/zuul-jobs/roles.html#role-multi-node-bridge>`_. | 
 | 193 | DEVSTACK_GATE_FEATURE_MATRIX                    devstack-gate ``test_matrix_features`` | 
 | 194 |                                                               variable of the | 
 | 195 |                                                               test-matrix role in | 
 | 196 |                                                               devstack-gate. This | 
 | 197 |                                                               is a temporary | 
 | 198 |                                                               solution, feature | 
 | 199 |                                                               matrix will go away. | 
 | 200 |                                                               In the future services | 
 | 201 |                                                               will be defined in | 
 | 202 |                                                               jobs only. | 
 | 203 | DEVSTACK_CINDER_VOLUME_CLEAR                    devstack      *CINDER_VOLUME_CLEAR: true/false* | 
 | 204 |                                                               in devstack_localrc | 
 | 205 |                                                               in the job vars. | 
 | 206 | DEVSTACK_GATE_NEUTRON                           devstack      True by default. To | 
 | 207 |                                                               disable, disable all | 
 | 208 |                                                               neutron services in | 
 | 209 |                                                               devstack_services in | 
 | 210 |                                                               the job definition. | 
 | 211 | DEVSTACK_GATE_CONFIGDRIVE                       devstack      *FORCE_CONFIG_DRIVE: true/false* | 
 | 212 |                                                               in devstack_localrc | 
 | 213 |                                                               in the job vars. | 
 | 214 | DEVSTACK_GATE_INSTALL_TESTONLY                  devstack      *INSTALL_TESTONLY_PACKAGES: true/false* | 
 | 215 |                                                               in devstack_localrc | 
 | 216 |                                                               in the job vars. | 
 | 217 | DEVSTACK_GATE_VIRT_DRIVER                       devstack      *VIRT_DRIVER: [virt driver]* | 
 | 218 |                                                               in devstack_localrc | 
 | 219 |                                                               in the job vars. | 
 | 220 | DEVSTACK_GATE_LIBVIRT_TYPE                      devstack      *LIBVIRT_TYPE: [libvirt type]* | 
 | 221 |                                                               in devstack_localrc | 
 | 222 |                                                               in the job vars. | 
 | 223 | DEVSTACK_GATE_TEMPEST                           devstack      Defined by the job | 
 | 224 |                                                 tempest       that is used. The | 
 | 225 |                                                               ``devstack`` job only | 
 | 226 |                                                               runs devstack. | 
 | 227 |                                                               The ``devstack-tempest`` | 
 | 228 |                                                               one triggers a Tempest | 
 | 229 |                                                               run as well. | 
 | 230 | DEVSTACK_GATE_TEMPEST_FULL                      tempest       *tox_envlist: full* | 
 | 231 |                                                               in the job vars. | 
 | 232 | DEVSTACK_GATE_TEMPEST_ALL                       tempest       *tox_envlist: all* | 
 | 233 |                                                               in the job vars. | 
 | 234 | DEVSTACK_GATE_TEMPEST_ALL_PLUGINS               tempest       *tox_envlist: all-plugin* | 
 | 235 |                                                               in the job vars. | 
 | 236 | DEVSTACK_GATE_TEMPEST_SCENARIOS                 tempest       *tox_envlist: scenario* | 
 | 237 |                                                               in the job vars. | 
 | 238 | TEMPEST_CONCURRENCY                             tempest       *tempest_concurrency: [value]* | 
 | 239 |                                                               in the job vars. This | 
 | 240 |                                                               is available only on | 
 | 241 |                                                               jobs that inherit from | 
 | 242 |                                                               ``devstack-tempest`` | 
 | 243 |                                                               down. | 
 | 244 | DEVSTACK_GATE_TEMPEST_NOTESTS                   tempest       *tox_envlist: venv-tempest* | 
 | 245 |                                                               in the job vars. This | 
 | 246 |                                                               will create Tempest | 
 | 247 |                                                               virtual environment | 
 | 248 |                                                               but run no tests. | 
 | 249 | DEVSTACK_GATE_SMOKE_SERIAL                      tempest       *tox_envlist: smoke-serial* | 
 | 250 |                                                               in the job vars. | 
 | 251 | DEVSTACK_GATE_TEMPEST_DISABLE_TENANT_ISOLATION  tempest       *tox_envlist: full-serial* | 
 | 252 |                                                               in the job vars. | 
 | 253 |                                                               *TEMPEST_ALLOW_TENANT_ISOLATION: false* | 
 | 254 |                                                               in devstack_localrc in | 
 | 255 |                                                               the job vars. | 
 | 256 | ==============================================  ============= ================== | 
 | 257 |  | 
 | 258 | The following flags have not been migrated yet or are legacy and won't be | 
 | 259 | migrated at all. | 
 | 260 |  | 
 | 261 | =====================================  ======  ========================== | 
 | 262 | DevStack gate flag                     Status  Details | 
 | 263 | =====================================  ======  ========================== | 
 | 264 | DEVSTACK_GATE_TOPOLOGY                 WIP     The topology depends on the base | 
 | 265 |                                                job that is used and more | 
 | 266 |                                                specifically on the nodeset | 
 | 267 |                                                attached to it. The new job | 
 | 268 |                                                format allows project to define | 
 | 269 |                                                the variables to be passed to | 
 | 270 |                                                every node/node-group that exists | 
 | 271 |                                                in the topology. Named topologies | 
 | 272 |                                                that include the nodeset and the | 
 | 273 |                                                matching variables can be defined | 
 | 274 |                                                in the form of base jobs. | 
 | 275 | DEVSTACK_GATE_GRENADE                  TBD     Grenade Zuul V3 jobs will be | 
 | 276 |                                                hosted in the grenade repo. | 
 | 277 | GRENADE_BASE_BRANCH                    TBD     Grenade Zuul V3 jobs will be | 
 | 278 |                                                hosted in the grenade repo. | 
 | 279 | DEVSTACK_GATE_NEUTRON_DVR              TBD     Depends on multinode support. | 
 | 280 | DEVSTACK_GATE_EXERCISES                TBD     Can be done on request. | 
 | 281 | DEVSTACK_GATE_IRONIC                   TBD     This will probably be implemented | 
 | 282 |                                                on ironic side. | 
 | 283 | DEVSTACK_GATE_IRONIC_DRIVER            TBD     This will probably be implemented | 
 | 284 |                                                on ironic side. | 
 | 285 | DEVSTACK_GATE_IRONIC_BUILD_RAMDISK     TBD     This will probably be implemented | 
 | 286 |                                                on ironic side. | 
 | 287 | DEVSTACK_GATE_POSTGRES                 Legacy  This flag exists in d-g but the | 
 | 288 |                                                only thing that it does is | 
 | 289 |                                                capture postgres logs. This is | 
 | 290 |                                                already supported by the roles in | 
 | 291 |                                                post, so the flag is useless in | 
 | 292 |                                                the new jobs. postgres itself can | 
 | 293 |                                                be enabled via the | 
 | 294 |                                                devstack_service job variable. | 
 | 295 | DEVSTACK_GATE_ZEROMQ                   Legacy  This has no effect in d-g. | 
 | 296 | DEVSTACK_GATE_MQ_DRIVER                Legacy  This has no effect in d-g. | 
 | 297 | DEVSTACK_GATE_TEMPEST_STRESS_ARGS      Legacy  Stress is not in Tempest anymore. | 
 | 298 | DEVSTACK_GATE_TEMPEST_HEAT_SLOW        Legacy  This is not used anywhere. | 
 | 299 | DEVSTACK_GATE_CELLS                    Legacy  This has no effect in d-g. | 
 | 300 | DEVSTACK_GATE_NOVA_API_METADATA_SPLIT  Legacy  This has no effect in d-g. | 
 | 301 | =====================================  ======  ========================== |