Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize x-pack-ciGroup6 #31368

Closed
wants to merge 12 commits into from
4 changes: 4 additions & 0 deletions test/common/services/retry/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function RetryProvider({ getService }) {
const log = getService('log');

return new class Retry {
async forSuccess(options) {
return await retryForSuccess(log, options);
}

async tryForTime(timeout, block) {
return await retryForSuccess(log, {
timeout,
Expand Down
7 changes: 3 additions & 4 deletions test/common/services/retry/retry_for_success.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const delay = ms => new Promise(resolve => (

const returnTrue = () => true;

const defaultOnFailure = (methodName) => (lastError) => {
const defaultOnTimeout = (methodName) => (lastError) => {
throw new Error(`${methodName} timeout: ${lastError.stack || lastError.message}`);
};

Expand All @@ -51,7 +51,7 @@ export async function retryForSuccess(log, {
timeout,
methodName,
block,
onFailure = defaultOnFailure(methodName),
onTimeout = defaultOnTimeout(methodName),
accept = returnTrue
}) {
const start = Date.now();
Expand All @@ -60,8 +60,7 @@ export async function retryForSuccess(log, {

while (true) {
if (Date.now() - start > timeout) {
await onFailure(lastError);
throw new Error('expected onFailure() option to throw an error');
return await onTimeout(lastError);
}

const { result, error } = await runAttempt(block);
Expand Down
4 changes: 2 additions & 2 deletions test/common/services/retry/retry_for_truthy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function retryForTruthy(log, {

const accept = result => Boolean(result);

const onFailure = lastError => {
const onTimeout = lastError => {
let msg = `timed out waiting for ${description}`;

if (lastError) {
Expand All @@ -43,7 +43,7 @@ export async function retryForTruthy(log, {
timeout,
methodName,
block,
onFailure,
onTimeout,
accept
});
}
17 changes: 13 additions & 4 deletions test/functional/services/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,19 @@ export async function FindProvider({ getService }) {

async existsByDisplayedByCssSelector(selector, timeout = WAIT_FOR_EXISTS_TIME) {
log.debug(`Find.existsByDisplayedByCssSelector('${selector}') with timeout=${timeout}`);
return await this.exists(async (driver) => {
const elements = wrapAll(await driver.findElements(By.css(selector)));
return await this.filterElementIsDisplayed(elements);
}, timeout);
return await retry.forSuccess({
timeout,
methodName: `Find.existsByDisplayedByCssSelector('${selector}')`,
accept: result => !!result,
onTimeout: () => false,
block: async () => {
const elements = await this.filterElementIsDisplayed(
wrapAll(await driver.findElements(By.css(selector)))
);

return elements.length > 0;
},
});
}

async existsByCssSelector(selector, timeout = WAIT_FOR_EXISTS_TIME) {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/api_integration/apis/uptime/graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default function ({ getService, loadTestFile }) {
const esArchiver = getService('esArchiver');
const archive = 'uptime/full_heartbeat';

describe('graphql', () => {
// FLAKY: https://github.com/elastic/kibana/pull/31368
describe.skip('graphql', () => {
before('load heartbeat data', () => esArchiver.load(archive));
after('unload heartbeat index', () => esArchiver.unload(archive));
// each of these test files imports a GQL query from
Expand Down