From 1a4d4ee293c087a849ea25f53bc7c2a939ccfe32 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 13 Jul 2018 12:39:23 +0200 Subject: [PATCH 1/3] storaged: Fix unhandled promise rejection when cancelling NFS install dialog --- pkg/storaged/optional-panel.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/storaged/optional-panel.jsx b/pkg/storaged/optional-panel.jsx index 5604448851d5..147cbb18c192 100644 --- a/pkg/storaged/optional-panel.jsx +++ b/pkg/storaged/optional-panel.jsx @@ -81,7 +81,8 @@ export class OptionalPanel extends React.Component { self.setState({ just_installed: "just-installed" }); window.setTimeout(() => { self.setState({ just_installed: "just-installed faded" }); }, 4000); - }); + }, + () => null /* ignore cancel */); } var heading_right = null; From 8a574a38a882aa25166c358b8a7c7ce243f52a17 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 11 Jul 2018 09:58:06 +0200 Subject: [PATCH 2/3] test: Fail CDP commands on unhandled exceptions Install a Chrome Devtools Protocol handler for unhandled exceptions, and fail the next CDP command with it. This got lost with the move from PhantomJS to Chrome. Some of our tests rely on failed ph_* function invocations, so we must not log failures of ph_wait_cond(); these are also technically unhandled exceptions. So turn this into a proper `PhWaitCondTimeout` error class, so that it can be identified reliably. Handle cases where undefined value is passed to fail/success in cdp-driver.js. Adjust the naughty override for the XTerm.js crash (#9641) as this now shows the actual underlying crash instead of just the followup element wait timeout. Closes #9639 --- .../9641-xtermjs-dimensions-crash | 3 +- .../9641-xtermjs-dimensions-crash | 3 +- .../fedora-27/9641-xtermjs-dimensions-crash | 3 +- .../fedora-28/9641-xtermjs-dimensions-crash | 3 +- .../rhel-7/9641-xtermjs-dimensions-crash | 3 +- .../rhel-x/9641-xtermjs-dimensions-crash | 3 +- .../ubuntu-1604/9641-xtermjs-dimensions-crash | 3 +- .../9641-xtermjs-dimensions-crash | 3 +- test/common/cdp-driver.js | 31 +++++++++++++++++-- test/common/test-functions.js | 8 ++++- 10 files changed, 44 insertions(+), 19 deletions(-) diff --git a/bots/naughty/debian-stable/9641-xtermjs-dimensions-crash b/bots/naughty/debian-stable/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/debian-stable/9641-xtermjs-dimensions-crash +++ b/bots/naughty/debian-stable/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/debian-testing/9641-xtermjs-dimensions-crash b/bots/naughty/debian-testing/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/debian-testing/9641-xtermjs-dimensions-crash +++ b/bots/naughty/debian-testing/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/fedora-27/9641-xtermjs-dimensions-crash b/bots/naughty/fedora-27/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/fedora-27/9641-xtermjs-dimensions-crash +++ b/bots/naughty/fedora-27/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/fedora-28/9641-xtermjs-dimensions-crash b/bots/naughty/fedora-28/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/fedora-28/9641-xtermjs-dimensions-crash +++ b/bots/naughty/fedora-28/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/rhel-7/9641-xtermjs-dimensions-crash b/bots/naughty/rhel-7/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/rhel-7/9641-xtermjs-dimensions-crash +++ b/bots/naughty/rhel-7/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/rhel-x/9641-xtermjs-dimensions-crash b/bots/naughty/rhel-x/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/rhel-x/9641-xtermjs-dimensions-crash +++ b/bots/naughty/rhel-x/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/ubuntu-1604/9641-xtermjs-dimensions-crash b/bots/naughty/ubuntu-1604/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/ubuntu-1604/9641-xtermjs-dimensions-crash +++ b/bots/naughty/ubuntu-1604/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/bots/naughty/ubuntu-stable/9641-xtermjs-dimensions-crash b/bots/naughty/ubuntu-stable/9641-xtermjs-dimensions-crash index 086fd234110b..92d68521e068 100644 --- a/bots/naughty/ubuntu-stable/9641-xtermjs-dimensions-crash +++ b/bots/naughty/ubuntu-stable/9641-xtermjs-dimensions-crash @@ -1,5 +1,4 @@ Traceback (most recent call last): File "test/verify/check-machines", line *, in testSerialConsole - b.wait_not_present("div.terminal canvas.xterm-text-layer") * -Error: timeout +RuntimeError: TypeError: Cannot read property 'dimensions' of undefined diff --git a/test/common/cdp-driver.js b/test/common/cdp-driver.js index 72dfbd81d5ae..018fbe3ec73f 100755 --- a/test/common/cdp-driver.js +++ b/test/common/cdp-driver.js @@ -47,11 +47,15 @@ function fatal() { } function fail(err) { + if (typeof err === 'undefined') + err = null; process.stdout.write(JSON.stringify({"error": err}) + '\n'); } function success(result) { - process.stdout.write(JSON.stringify({"result": result === undefined ? null : result}) + '\n'); + if (typeof result === 'undefined') + result = null; + process.stdout.write(JSON.stringify({"result": result}) + '\n'); } /** @@ -61,6 +65,7 @@ function success(result) { var messages = []; var logPromiseResolver; var nReportedLogMessages = 0; +var unhandledExceptions = []; function setupLogging(client) { client.Runtime.enable(); @@ -72,6 +77,16 @@ function setupLogging(client) { resolveLogPromise(); }); + client.Runtime.exceptionThrown(info => { + let details = info.exceptionDetails; + // don't log test timeouts, they already get handled + if (details.exception && details.exception.className === "PhWaitCondTimeout") + return; + + unhandledExceptions.push(details) + process.stderr.write(details.description || JSON.stringify(details) + "\n"); + }); + client.Log.enable(); client.Log.entryAdded(entry => { let msg = entry["entry"]; @@ -288,7 +303,19 @@ CDP.New(options) pageLoadPromise = new Promise((resolve, reject) => { pageLoadResolve = resolve; pageLoadReject = reject; }); // run the command - eval(command).then(success, fail); + eval(command).then(reply => { + if (unhandledExceptions.length === 0) { + success(reply); + } else { + let details = unhandledExceptions[0]; + let message = details.exception.message || + details.exception.description || + details.exception.value || + JSON.stringify(details.exception); + fail(message.split("\n")[0]); + unhandledExceptions.length = 0; + } + }, fail); input_buf = input_buf.slice(i+1); } diff --git a/test/common/test-functions.js b/test/common/test-functions.js index 93d1caf4a4f1..0d5816cd9d67 100644 --- a/test/common/test-functions.js +++ b/test/common/test-functions.js @@ -184,6 +184,12 @@ function ph_focus(sel) ph_find(sel).focus(); } +class PhWaitCondTimeout extends Error { + constructor() { + super("condition did not become true"); + } +} + function ph_wait_cond(cond, timeout) { return new Promise((resolve, reject) => { // poll every 100 ms for now; FIXME: poll less often and re-check on mutations using @@ -192,7 +198,7 @@ function ph_wait_cond(cond, timeout) { let tm = window.setTimeout( () => { if (stepTimer) window.clearTimeout(stepTimer); - reject("condition did not become true"); + reject(new PhWaitCondTimeout()); }, timeout); function step() { try { From 6fb1ba7c99003df91c73f99a205f252e7f1b6597 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 23 Jul 2018 12:01:59 +0200 Subject: [PATCH 3/3] test: Ignore c3 data_types null crashes This gets triggered by the CPUUsage DonutChart in pkg/kubernetes/scripts/virtual-machines/components/VmMetricsTab.jsx. This seems to be some race condition when switching pages, which supposedly also means "(un)render in React". Cockpit code has no control over this, and it also does not break the user experience, so ignore the exception. See https://github.com/c3js/c3/issues/2187 and simlilar issues https://github.com/bcbcarl/react-c3js/issues/22 or https://github.com/c3js/c3/issues/1205. --- test/common/cdp-driver.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/common/cdp-driver.js b/test/common/cdp-driver.js index 018fbe3ec73f..006d1a1bb2e1 100755 --- a/test/common/cdp-driver.js +++ b/test/common/cdp-driver.js @@ -83,8 +83,15 @@ function setupLogging(client) { if (details.exception && details.exception.className === "PhWaitCondTimeout") return; - unhandledExceptions.push(details) process.stderr.write(details.description || JSON.stringify(details) + "\n"); + + // ignore c3 crashes (https://github.com/c3js/c3/issues/2187) + if (details.exception && details.exception.description && + details.exception.description.indexOf("TypeError: Cannot read property 'data_types' of null") >= 0 && + details.exception.description.indexOf("/kubernetes.js") >= 0) + return; + + unhandledExceptions.push(details) }); client.Log.enable();