Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Conversation

Dmitriy-kiselyov
Copy link
Contributor

@Dmitriy-kiselyov Dmitriy-kiselyov commented Mar 16, 2018

No description provided.

it('should retry only failed states', async () => {
sandbox.spy(RegularSuiteRunner, 'create');

const suite = makeSuiteTree({suite: ['1st', '2nd', '3rd']}, {browsers: ['bro', 'firefox']}).suite;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Немножко улучшил тест

const childState = suite.children[0].states[0];
if (_.includes(childState.browsers, 'bro')) { //emulate State-runner behaviour
runner.emit(Events.TEST_RESULT, {state: {name: 'childState'}, equal: false});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Долго мучался и страдал, но лучше не придумал. Проблема (исправленная) возникает из-за того, что в RegularSuiteRunner выбирается DisabledStateRunner, который не присылает event'ов. Сколько я ни пытался, расстабать RegularSuiteRunner и застабать StateRunner невозможно, придется переписывать все тесты. Поэтому просто моделирую поведение при выборе одного из StateRunner'ов.

return;
}

const collection = new SuiteCollection([suite]).disableAll();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот он – корень зла. Для тех, кто не в курсе, эта функция обнуляет браузеры всех стейтов, включая дочерние, отчего те в свою очередь, не способны запускаться. При этом........

const browser = this._browserAgent.browserId;
const collection = new SuiteCollection([suite]);
suite.states.forEach((state) => collection.disable(suite, {state: state.name}));
this._statesToRetry.forEach((state) => collection.enable(suite, {state, browser}));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

......в строй возвращаются лишь стейты ТЕКУЩЕГО сьюта, и после завершения функции, стейты дочерних сьютов остаются без браузеров :(

Copy link
Member

@sipayRT sipayRT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно обсудить сам тест - я в нем нифига не понял

.then(() => {
stubWrappedRun_((runner) => {
const childState = suite.children[0].states[0];
if (_.includes(childState.browsers, 'bro')) { //emulate State-runner behaviour
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

childState.browsers.includes('bro')

'state': 'rootState',
child: ['childState']
}
}, {browsers: ['bro', 'firefox']}).suite;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Создаем дерево сьютов

suite: {
    rootState
    browsers: ['bro', 'firefox']
}
     |
     –––> childSuite: {childState}

Самая запутанная часть (как мне кажется) теста, но что поделать, создатель видел функцию makeSuiteTree именно такой

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я, как создатель функции makeSuiteTree, заявляю, что она не должна работать с такими входными параметрами, и не рассчитана на такой кейс.


stubWrappedRun_((runner) => runner.emit(Events.TEST_RESULT, {state: {name: 'rootState'}, equal: false}));

return mkRunnerWithRetries_({suite, browserAgent: mkBrowserAgentStub_('bro')})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Повторяем те действия в точности, как бы их делала gemini на реальном тесте. 2 теста выполняются один за другим –> browsersPerSession = 1, как раз то, что нам нужно воспроизвести.
Тест верхнего сьюта падает с ошибкой

const childState = suite.children[0].states[0];
if (childState.browsers.includes('bro')) { //emulate State-runner behaviour
runner.emit(Events.TEST_RESULT, {state: {name: 'childState'}, equal: false});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Важнецкий момент! После прохождения первого теста программа оказывается в этой строчке, где решает, что же в итоге выбрать для дочернего сьюта: нормальный runner или disabled. DisabledStateRunner не прокидывает событий, нужно этот момент в точности повторить, что я и делаю. Если убрать строчку childState.browsers.includes('bro'), оригинальную проблему не возможно было бы воспроизвести

}
});

return mkRunnerWithRetries_({suite: suite.children[0], browserAgent: mkBrowserAgentStub_('bro')}).run();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вызываем дочерний state

assert.equal(RegularSuiteRunner.create.callCount, 4);
const retriedChildSuite = RegularSuiteRunner.create.getCall(3).args[0];
assert.deepEqual(retriedChildSuite.states[0].browsers, ['bro']);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Собственно, проверочки, что state вызвался, при чем с нормальными аргументами

@Dmitriy-kiselyov Dmitriy-kiselyov merged commit 34b0c18 into master Mar 23, 2018
@Dmitriy-kiselyov Dmitriy-kiselyov deleted the child_suites_retry branch March 23, 2018 09:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants