From f56d6311a5328891bc413065e1cdadbc44892153 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Thu, 23 May 2019 12:58:47 +0800 Subject: [PATCH] test: Start lorax-composer from UI and add test to check its status 1. Remove "enable lorax-composer" in vm.install to start it from UI 2. Remove wait for lorax start from check-application 3. Add one more step to start lorax-composer from UI if it does not start 4. Add test case to check lorax-composer.socket enabled or not 5. Increase mocha and element wait timeout because starting lorax-composer takes more time on RHEL7 --- test/check-application | 16 ----------- test/end-to-end/pages/blueprints.page.js | 27 ++++++++++++++++--- test/end-to-end/specs/api.test.js | 10 +++++++ test/end-to-end/specs/blueprints.test.js | 1 + test/end-to-end/specs/createBlueprint.test.js | 1 + test/end-to-end/specs/createImage.test.js | 1 + .../specs/createUserAccount.test.js | 1 + test/end-to-end/specs/editBlueprint1.test.js | 1 + test/end-to-end/specs/editBlueprint2.test.js | 1 + test/end-to-end/specs/sources.test.js | 1 + test/end-to-end/specs/viewBlueprint.test.js | 1 + test/end-to-end/utils/commands.js | 11 ++++++++ test/end-to-end/wdio.conf.js | 2 +- test/vm.install | 4 +-- 14 files changed, 55 insertions(+), 23 deletions(-) diff --git a/test/check-application b/test/check-application index aaabe092e..3c2498b17 100755 --- a/test/check-application +++ b/test/check-application @@ -32,21 +32,6 @@ done; machine.execute(script=WAIT_EDGE_RUNNING) -# lorax-composer in Fedora retruns: "db_supported":true -# lorax-composer in RHEL returns: "db_supported": true -def wait_for_composer_running(machine): - WAIT_COMPOSER_RUNNING = """#!/bin/sh -until curl --unix-socket /run/weldr/api.socket \ -http://localhost:4000/api/status | grep '"db_supported": *true'; do -sleep 1; -done; -""" - with testvm.Timeout( - seconds=300, - error_message="Timeout while waiting for composer to start"): - machine.execute(script=WAIT_COMPOSER_RUNNING) - - def run_webdriver_tests(machine, env=[]): """ Execute end to end test on the machine with the passed environment variables. For example: @@ -112,7 +97,6 @@ def run_e2e(verbose, image, browser, cpus, memory, sit): composer.dhcp_server(range=['10.111.112.10', '10.111.112.10']) wait_for_selenium_running(composer, "10.111.112.10") - wait_for_composer_running(composer) if selenium and 'MicrosoftEdge' in browser: wait_for_edge_running(composer, "10.111.112.10") diff --git a/test/end-to-end/pages/blueprints.page.js b/test/end-to-end/pages/blueprints.page.js index 44e5d027c..873218c79 100644 --- a/test/end-to-end/pages/blueprints.page.js +++ b/test/end-to-end/pages/blueprints.page.js @@ -9,7 +9,7 @@ class BlueprintsPage { } loading() { - $(this.blueprintListView).waitForExist(timeout); + $(this.blueprintListView).waitForExist(timeout * 4); browser.waitUntil(() => $$(this.blueprintListView).length >= 3, timeout, "Loading Blueprints page failed"); } @@ -39,10 +39,9 @@ class BlueprintsPage { } get createBlueprintButton() { - // const selector = '[data-target="#cmpsr-modal-crt-blueprint"]'; - const selector = "span=Create Blueprint"; + const selector = '[id="cmpsr-btn-crt-blueprint"]'; browser.waitUntil( - () => browser.isVisible(selector), + () => browser.isExisting(selector), timeout, `Create Blueprint button in Blueprints page cannot be found by selector ${selector}` ); @@ -119,6 +118,26 @@ class BlueprintsPage { waitForActiveFiltersNotExist() { browser.waitForExist("p=Active Filters:", timeout, true); } + + get serviceStartButton() { + const selector = ".blank-slate-pf-main-action button"; + browser.waitUntil( + () => browser.isExisting(selector), + timeout, + `Start button in Blueprints page cannot be found by selector ${selector}` + ); + return $(selector); + } + + get autostartCheckbox() { + const selector = ".blank-slate-pf .checkbox label input"; + browser.waitUntil( + () => browser.isExisting(selector), + timeout, + `Autostart on boot checkbox in Blueprints page cannot be found by selector ${selector}` + ); + return $(selector); + } } module.exports = new BlueprintsPage(); diff --git a/test/end-to-end/specs/api.test.js b/test/end-to-end/specs/api.test.js index f08084001..a0ee8027d 100644 --- a/test/end-to-end/specs/api.test.js +++ b/test/end-to-end/specs/api.test.js @@ -9,11 +9,21 @@ const acceptable = 10000; describe("lorax-composer api sanity test", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); // Edge does not support the following command so have to keep default timeout(3 seconds) // browser.timeouts({ script: timeout }); blueprintsPage.loading(); }); + it("lorax-composer.socket should be enabled", function() { + const status = browser.executeAsync(function(done) { + cockpit + .script("systemctl is-enabled lorax-composer.socket", { superuser: "require", err: "message" }) + .then(data => done(data)); + }); + expect(status.value.trim()).to.equal("enabled"); + }); + it("/api/v0/blueprints/list", function() { const endpoint = "/api/v0/blueprints/list"; const result = commands.apiFetchTest(endpoint).value; diff --git a/test/end-to-end/specs/blueprints.test.js b/test/end-to-end/specs/blueprints.test.js index b7528a5c7..ed0e6e433 100644 --- a/test/end-to-end/specs/blueprints.test.js +++ b/test/end-to-end/specs/blueprints.test.js @@ -8,6 +8,7 @@ const Blueprint = require("../components/Blueprint.component"); describe("Blueprints Page", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); }); let name, description, blueprintComponent; diff --git a/test/end-to-end/specs/createBlueprint.test.js b/test/end-to-end/specs/createBlueprint.test.js index fcebe6f41..f85f96591 100644 --- a/test/end-to-end/specs/createBlueprint.test.js +++ b/test/end-to-end/specs/createBlueprint.test.js @@ -8,6 +8,7 @@ describe("Create Blueprints Page", function() { let blueprintNameList; // used by duplicated blueprint name checking before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); blueprintsPage.loading(); blueprintNameList = $$(blueprintsPage.blueprintListView).map(item => item.getAttribute("data-blueprint")); }); diff --git a/test/end-to-end/specs/createImage.test.js b/test/end-to-end/specs/createImage.test.js index e2ce33e33..81d113a6b 100644 --- a/test/end-to-end/specs/createImage.test.js +++ b/test/end-to-end/specs/createImage.test.js @@ -15,6 +15,7 @@ describe("Create Image Page", function() { const createImagePage = new CreateImagePage(name); before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); addContext(this, `create new blueprint with name, ${name}, and description, ${description}`); commands.newBlueprint(name, description); blueprintComponent.createImageButton.click(); diff --git a/test/end-to-end/specs/createUserAccount.test.js b/test/end-to-end/specs/createUserAccount.test.js index 6ba4dcf83..32d935fc3 100644 --- a/test/end-to-end/specs/createUserAccount.test.js +++ b/test/end-to-end/specs/createUserAccount.test.js @@ -15,6 +15,7 @@ describe("Create User Account Page", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); commands.newBlueprint(name, description); blueprintComponent.blueprintNameLink.click(); viewBlueprintPage.loading(); diff --git a/test/end-to-end/specs/editBlueprint1.test.js b/test/end-to-end/specs/editBlueprint1.test.js index 59bf85f10..be0511b2e 100644 --- a/test/end-to-end/specs/editBlueprint1.test.js +++ b/test/end-to-end/specs/editBlueprint1.test.js @@ -16,6 +16,7 @@ describe("Edit Blueprint Page", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); }); after(function() { diff --git a/test/end-to-end/specs/editBlueprint2.test.js b/test/end-to-end/specs/editBlueprint2.test.js index 198e8b862..318a115dc 100644 --- a/test/end-to-end/specs/editBlueprint2.test.js +++ b/test/end-to-end/specs/editBlueprint2.test.js @@ -17,6 +17,7 @@ describe("Edit Blueprint Page", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); commands.newBlueprint(name, description); blueprintComponent.editBlueprintButton.click(); editBlueprintPage.loading(); diff --git a/test/end-to-end/specs/sources.test.js b/test/end-to-end/specs/sources.test.js index 054cc8252..dca747643 100644 --- a/test/end-to-end/specs/sources.test.js +++ b/test/end-to-end/specs/sources.test.js @@ -6,6 +6,7 @@ const sourcesPage = require("../pages/sources.page"); describe("Sources Page", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); blueprintsPage.moreButton.click(); blueprintsPage.viewSourcesItem.click(); sourcesPage.loading(); diff --git a/test/end-to-end/specs/viewBlueprint.test.js b/test/end-to-end/specs/viewBlueprint.test.js index 4fe438387..e331f82e8 100644 --- a/test/end-to-end/specs/viewBlueprint.test.js +++ b/test/end-to-end/specs/viewBlueprint.test.js @@ -14,6 +14,7 @@ describe("View Blueprint Page", function() { before(function() { commands.login(); + commands.startLoraxIfItDoesNotStart(); }); after(function() { diff --git a/test/end-to-end/utils/commands.js b/test/end-to-end/utils/commands.js index 63d8327ab..ee54d5c0f 100644 --- a/test/end-to-end/utils/commands.js +++ b/test/end-to-end/utils/commands.js @@ -22,6 +22,17 @@ module.exports = { browser.frame(loginPage.imageBuilderIframe); }, + startLoraxIfItDoesNotStart: function() { + if (blueprintsPage.createBlueprintButton.getAttribute("disabled") === "true") { + const isAutostart = blueprintsPage.autostartCheckbox.isSelected(); + if (!isAutostart) { + blueprintsPage.autostartCheckbox.click(); + } + blueprintsPage.serviceStartButton.click(); + blueprintsPage.loading(); + } + }, + newBlueprint: function(name, description) { // on Blueprints page blueprintsPage.loading(); diff --git a/test/end-to-end/wdio.conf.js b/test/end-to-end/wdio.conf.js index d2ebe9b5f..0268027ac 100644 --- a/test/end-to-end/wdio.conf.js +++ b/test/end-to-end/wdio.conf.js @@ -5,7 +5,7 @@ const crypto = require("crypto"); // const commands = require('./utils/commands'); -const mochaTimeout = parseInt(process.env.MOCHA_TIMEOUT) || 120000; +const mochaTimeout = parseInt(process.env.MOCHA_TIMEOUT) || 1200000; exports.config = { // diff --git a/test/vm.install b/test/vm.install index d8fd4bf64..22dfdca5f 100755 --- a/test/vm.install +++ b/test/vm.install @@ -23,7 +23,7 @@ sed -i "s|\"/api/v0/compose\"|\"/api/v0/compose?test=2\"|" /usr/share/cockpit/we # disable https in cockpit and use http instead printf "[WebService]\\nAllowUnencrypted=true\\n" > /etc/cockpit/cockpit.conf -# Make cockpit.socket and lorax-composer auto-start when system started +# Make cockpit.socket auto-start when system started # Do not start it during image generation +# Do not auto start lorax-composer because it will be enabled in test systemctl enable cockpit.socket -systemctl enable lorax-composer