From 8354146c11a9e581b26e8b8efa5d3bd24bfbc0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Sun, 12 Jan 2020 14:11:17 +0100 Subject: [PATCH] CI: New jobs This follows removal of jobs from project-config. [1] New jobs use newer node versions and new Zuul v3 format, reusing devstack for deployment of OpenStack for functional testing of jslib. Version tests have been adapted to follow support logic already in place instead of hardcoded supported versions. Includes workaround (fixup) of devstack's bug. [2] Move the functional test to experimental for now, because version discovery doesn't work right and Firefox is generally grumpy. We want to get the structural stuff in first. [1] https://review.opendev.org/702030 [2] https://bugs.launchpad.net/devstack/+bug/1860287 Depends-on: https://review.opendev.org/704882 Depends-on: https://review.opendev.org/726547 Co-authored-by: Monty Taylor Change-Id: I197eb2b59be7a49d168edf09d554b444bbcc29b2 --- playbooks/fetch-javascript-output.yml | 4 ++ playbooks/fixup-devstack.yml | 14 ++++++ playbooks/prepare-env-for-tests.yml | 12 +++++ playbooks/run-npm.yml | 5 +++ src/util/abstractService.js | 11 +++-- test/functional/glanceTest.js | 14 +----- test/functional/keystoneTest.js | 14 +----- test/functional/neutronTest.js | 14 +----- test/functional/novaTest.js | 7 +-- zuul.d/jobs.yaml | 65 +++++++++++++++++++++++++++ zuul.d/project.yaml | 15 +++++++ 11 files changed, 124 insertions(+), 51 deletions(-) create mode 100644 playbooks/fetch-javascript-output.yml create mode 100644 playbooks/fixup-devstack.yml create mode 100644 playbooks/prepare-env-for-tests.yml create mode 100644 playbooks/run-npm.yml create mode 100644 zuul.d/jobs.yaml create mode 100644 zuul.d/project.yaml diff --git a/playbooks/fetch-javascript-output.yml b/playbooks/fetch-javascript-output.yml new file mode 100644 index 0000000..bc70510 --- /dev/null +++ b/playbooks/fetch-javascript-output.yml @@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - fetch-javascript-output diff --git a/playbooks/fixup-devstack.yml b/playbooks/fixup-devstack.yml new file mode 100644 index 0000000..2746e39 --- /dev/null +++ b/playbooks/fixup-devstack.yml @@ -0,0 +1,14 @@ +--- +- hosts: all + tasks: + # NOTE(yoctozepto): devstack starts WSGI-based, API services too early + # to make post-config apply to them + # see: https://bugs.launchpad.net/devstack/+bug/1860287 + - name: "Restart devstack API services" + command: "systemctl restart devstack@{{ item }}" + become: True + loop: + - keystone + - g-api + - q-svc + - n-api diff --git a/playbooks/prepare-env-for-tests.yml b/playbooks/prepare-env-for-tests.yml new file mode 100644 index 0000000..6b97015 --- /dev/null +++ b/playbooks/prepare-env-for-tests.yml @@ -0,0 +1,12 @@ +--- +- hosts: all + roles: + - ensure-javascript-build-tool + - nodejs-test-dependencies + tasks: + # NOTE(yoctozepto): nodejs-test-dependencies role installs only + # chromium-browser but we need firefox too + - name: Install firefox + apt: + name: firefox + become: true diff --git a/playbooks/run-npm.yml b/playbooks/run-npm.yml new file mode 100644 index 0000000..8a6481f --- /dev/null +++ b/playbooks/run-npm.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + roles: + - revoke-sudo + - js-package-manager diff --git a/src/util/abstractService.js b/src/util/abstractService.js index 501b5e5..9f12136 100644 --- a/src/util/abstractService.js +++ b/src/util/abstractService.js @@ -85,7 +85,7 @@ export default class AbstractService { */ _rawVersions() { return new Promise((resolve, reject) => { - let promise = this.http + this.http .httpGet(this._endpointUrl) .catch((response) => { if (response.status === 401) { @@ -96,13 +96,12 @@ export default class AbstractService { return this.http.httpGet(rootUrl.href); } else { - return reject(response); + throw response; } - }); - - promise + }) .then((response) => response.json()) - .then((body) => resolve(body.versions)); + .then((body) => resolve(body.versions)) + .catch(reject); }); } diff --git a/test/functional/glanceTest.js b/test/functional/glanceTest.js index c7d4dea..d2ef6bf 100644 --- a/test/functional/glanceTest.js +++ b/test/functional/glanceTest.js @@ -48,11 +48,6 @@ describe("Glance", () => { }); describe("version()", () => { - - const supportedApiVersions = [ - new Version('2.5') - ]; - /** * This test acts as a canary, to inform the SDK developers that the Glance API * has changed in a significant way. @@ -62,14 +57,7 @@ describe("Glance", () => { .then((config) => new Glance(config)) .then((glance) => glance.version()) .then((apiVersion) => { - for (let i = 0; i < supportedApiVersions.length; i++) { - let supportedVersion = supportedApiVersions[i]; - if (apiVersion.equals(supportedVersion)) { - done(); - return; - } - } - fail(`Current devstack glance version (${apiVersion}) is not supported.`); + expect(apiVersion instanceof Version).not.toBeFalsy(); done(); }) .catch((error) => done.fail(error)); diff --git a/test/functional/keystoneTest.js b/test/functional/keystoneTest.js index ec21194..d939c34 100644 --- a/test/functional/keystoneTest.js +++ b/test/functional/keystoneTest.js @@ -41,11 +41,6 @@ describe("Keystone", () => { }); describe("version()", () => { - - const supportedApiVersions = [ - new Version('3.8') - ]; - /** * This test acts as a canary, to inform the SDK developers that the Keystone API * has changed in a significant way. @@ -53,14 +48,7 @@ describe("Keystone", () => { it("should return a supported version.", (done) => { keystone.version() .then((apiVersion) => { - for (let i = 0; i < supportedApiVersions.length; i++) { - let supportedVersion = supportedApiVersions[i]; - if (apiVersion.equals(supportedVersion)) { - done(); - return; - } - } - fail(`Current devstack keystone version (${apiVersion}) is not supported.`); + expect(apiVersion instanceof Version).not.toBeFalsy(); done(); }) .catch((response) => response.json() diff --git a/test/functional/neutronTest.js b/test/functional/neutronTest.js index 652499b..9740353 100644 --- a/test/functional/neutronTest.js +++ b/test/functional/neutronTest.js @@ -48,11 +48,6 @@ describe("neutron", () => { }); describe("version()", () => { - - const supportedApiVersions = [ - new Version('2.0') - ]; - /** * This test acts as a canary, to inform the SDK developers that the Neutron API * has changed in a significant way. @@ -62,14 +57,7 @@ describe("neutron", () => { .then((config) => new Neutron(config)) .then((neutron) => neutron.version()) .then((apiVersion) => { - for (let i = 0; i < supportedApiVersions.length; i++) { - let supportedVersion = supportedApiVersions[i]; - if (apiVersion.equals(supportedVersion)) { - done(); - return; - } - } - fail(`Current devstack neutron version (${apiVersion}) is not supported.`); + expect(apiVersion instanceof Version).not.toBeFalsy(); done(); }) .catch((error) => done.fail(error)); diff --git a/test/functional/novaTest.js b/test/functional/novaTest.js index de7adc7..2d5cb0a 100644 --- a/test/functional/novaTest.js +++ b/test/functional/novaTest.js @@ -34,10 +34,6 @@ describe("Nova", () => { .then((entry) => entry.endpoints.find((endpoint) => endpoint.interface === 'public')); describe("version()", () => { - const supportedApiVersions = [ - new Version('2.1') - ]; - /** * This test acts as a canary, to inform the SDK developers that the Nova API * has changed in a significant way. @@ -47,8 +43,7 @@ describe("Nova", () => { .then((config) => new Nova(config)) .then((nova) => nova.version()) .then((apiVersion) => { - let found = supportedApiVersions.find((item) => item.equals(apiVersion)); - expect(found).not.toBeFalsy(); + expect(apiVersion instanceof Version).not.toBeFalsy(); done(); }) .catch((error) => done.fail(error)); diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 0000000..ddbd8b4 --- /dev/null +++ b/zuul.d/jobs.yaml @@ -0,0 +1,65 @@ +- job: + name: js-openstack-lib-functional-tests-base + # We use tox-functional-consumer as a base job because it's + # the closest we've got. It'll cause tox to get installed, but + # we override the run so it shouldn't matter. + parent: devstack-tox-functional-consumer + pre-run: + - playbooks/prepare-env-for-tests.yml + # NOTE(yoctozepto): devstack starts WSGI-based, API services too early + # to make post-config apply to them + # see: https://bugs.launchpad.net/devstack/+bug/1860287 + - playbooks/fixup-devstack.yml + run: playbooks/run-npm.yml + post-run: + - playbooks/fetch-javascript-output.yml + vars: + npm_command: functional-test + + # NOTE(yoctozepto): we need relaxed CORS allowed_origin to be able to + # test browsers without hacking them to ignore CORS + devstack_local_conf: + post-config: + $KEYSTONE_CONF: + cors: + allowed_origin: '*' + $GLANCE_API_CONF: + cors: + allowed_origin: '*' + $NEUTRON_CONF: + cors: + allowed_origin: '*' + $NOVA_CONF: + cors: + allowed_origin: '*' + + devstack_services: + tls-proxy: false # FIXME(yoctozepto): we can't have tls atm + + # NOTE(yoctozepto): disable Swift & Cinder - not tested atm + # but enabled by parent (let's conserve resources) + + # Swift services + s-account: false + s-container: false + s-object: false + s-proxy: false + + # Cinder services + c-api: false + c-bak: false + c-sch: false + c-vol: false + cinder: false + +- job: + name: js-openstack-lib-unit-tests-nodejs12 + parent: nodejs-run-test-browser + vars: + node_version: 12 + +- job: + name: js-openstack-lib-functional-tests-nodejs12 + parent: js-openstack-lib-functional-tests-base + vars: + node_version: 12 diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml new file mode 100644 index 0000000..8427ba1 --- /dev/null +++ b/zuul.d/project.yaml @@ -0,0 +1,15 @@ +--- +- project: + templates: + - nodejs8-docs + - nodejs8-jobs + - nodejs8-publish-to-npm + check: + jobs: + - js-openstack-lib-unit-tests-nodejs12 + gate: + jobs: + - js-openstack-lib-unit-tests-nodejs12 + experimental: + jobs: + - js-openstack-lib-functional-tests-nodejs12