Skip to content

Commit

Permalink
chore(#8592): stabilize unknown transition test (#8623)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianabarsan committed Oct 9, 2023
1 parent f3e285e commit 4ff307d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
const utils = require('@utils');
const { expect } = require('chai');

describe('Sentinel transition error log', async function() {

after(async () => await utils.revertSettings(true));

it('log error for unkown transition', async () => {
it('log error for unknown transition', async () => {
const unknownTransitionPattern = /Unknown transition "something"/;
const settings = {
transitions: {
something: true
}
};
const collectLogs = await utils.collectSentinelLogs(unknownTransitionPattern);

const waitForLogs = await utils.waitForSentinelLogs(unknownTransitionPattern);
await utils.updateSettings(settings, 'sentinel');
const logs = await collectLogs();
expect(logs).to.have.lengthOf(1);
await waitForLogs.promise;
});
});

8 changes: 5 additions & 3 deletions tests/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const updateCustomSettings = updates => {

const waitForSettingsUpdateLogs = (type) => {
if (type === 'sentinel') {
return waitForDockerLogs('sentinel', /Reminder messages allowed between/);
return waitForSentinelLogs( /Reminder messages allowed between/);
}
return waitForApiLogs(/Settings updated/);
};
Expand Down Expand Up @@ -1067,7 +1067,7 @@ const waitForDockerLogs = (container, ...regex) => {
// It takes a while until the process actually starts tailing logs, and initiating next test steps immediately
// after watching results in a race condition, where the log is created before watching started.
// As a fix, watch the logs with tail=1, so we always receive one log line immediately, then proceed with next
// steps of testing afterwards.
// steps of testing afterward.
const params = `logs ${container} -f --tail=1`;
const proc = spawn('docker', params.split(' '), { stdio: ['ignore', 'pipe', 'pipe'] });
let receivedFirstLine;
Expand Down Expand Up @@ -1111,6 +1111,7 @@ const waitForDockerLogs = (container, ...regex) => {
};

const waitForApiLogs = (...regex) => waitForDockerLogs('api', ...regex);
const waitForSentinelLogs = (...regex) => waitForDockerLogs('sentinel', ...regex);

/**
* Collector that listens to the given container logs and collects lines that match at least one of the
Expand All @@ -1133,7 +1134,7 @@ const collectLogs = (container, ...regex) => {
// It takes a while until the process actually starts tailing logs, and initiating next test steps immediately
// after watching results in a race condition, where the log is created before watching started.
// As a fix, watch the logs with tail=1, so we always receive one log line immediately, then proceed with next
// steps of testing afterwards.
// steps of testing afterward.
const params = `logs ${container} -f --tail=1`;
const proc = spawn('docker', params.split(' '), { stdio: ['ignore', 'pipe', 'pipe'] });
let receivedFirstLine;
Expand Down Expand Up @@ -1277,6 +1278,7 @@ module.exports = {
saveBrowserLogs,
tearDownServices,
waitForApiLogs,
waitForSentinelLogs,
collectSentinelLogs,
collectApiLogs,
collectHaproxyLogs,
Expand Down

0 comments on commit 4ff307d

Please sign in to comment.