Skip to content

Commit

Permalink
test: Start lorax-composer from UI and add test to check its status
Browse files Browse the repository at this point in the history
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
  • Loading branch information
henrywang committed May 24, 2019
1 parent 2f40eba commit f56d631
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 23 deletions.
16 changes: 0 additions & 16 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")

Expand Down
27 changes: 23 additions & 4 deletions test/end-to-end/pages/blueprints.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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}`
);
Expand Down Expand Up @@ -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();
10 changes: 10 additions & 0 deletions test/end-to-end/specs/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/blueprints.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Blueprint = require("../components/Blueprint.component");
describe("Blueprints Page", function() {
before(function() {
commands.login();
commands.startLoraxIfItDoesNotStart();
});

let name, description, blueprintComponent;
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/createBlueprint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/createImage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/createUserAccount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/editBlueprint1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("Edit Blueprint Page", function() {

before(function() {
commands.login();
commands.startLoraxIfItDoesNotStart();
});

after(function() {
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/editBlueprint2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe("Edit Blueprint Page", function() {

before(function() {
commands.login();
commands.startLoraxIfItDoesNotStart();
commands.newBlueprint(name, description);
blueprintComponent.editBlueprintButton.click();
editBlueprintPage.loading();
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/sources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/specs/viewBlueprint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("View Blueprint Page", function() {

before(function() {
commands.login();
commands.startLoraxIfItDoesNotStart();
});

after(function() {
Expand Down
11 changes: 11 additions & 0 deletions test/end-to-end/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
//
Expand Down
4 changes: 2 additions & 2 deletions test/vm.install
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f56d631

Please sign in to comment.