Skip to content

Commit

Permalink
Add debug logging for flaky session tests (elastic#193279)
Browse files Browse the repository at this point in the history
## Summary

Add settings to the ES Test cluster to enable debug logs so that if this
test fails in the future, we will have more logs to investigate the
issue.

__Related:__ elastic#152260

(cherry picked from commit de51a1a)
  • Loading branch information
SiddharthMantri committed Sep 19, 2024
1 parent 5a522bf commit 64e4e1b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertestWithoutAuth');
const esSupertest = getService('esSupertest');
const es = getService('es');
const security = getService('security');
const esDeleteAllIndices = getService('esDeleteAllIndices');
Expand Down Expand Up @@ -150,6 +151,15 @@ export default function ({ getService }: FtrProviderContext) {
});
}

async function addESDebugLoggingSettings() {
const addLogging = {
persistent: {
'logger.org.elasticsearch.xpack.security.authc': 'debug',
},
};
await esSupertest.put('/_cluster/settings').send(addLogging).expect(200);
}

describe('Session Concurrent Limit cleanup', () => {
before(async () => {
await security.user.create('anonymous_user', {
Expand All @@ -166,6 +176,7 @@ export default function ({ getService }: FtrProviderContext) {
beforeEach(async function () {
this.timeout(120000);
await es.cluster.health({ index: '.kibana_security_session*', wait_for_status: 'green' });
await addESDebugLoggingSettings();
await esDeleteAllIndices('.kibana_security_session*');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertestWithoutAuth');
const esSupertest = getService('esSupertest');
const es = getService('es');
const security = getService('security');
const config = getService('config');
Expand Down Expand Up @@ -116,6 +117,15 @@ export default function ({ getService }: FtrProviderContext) {
.expect(200);
}

async function addESDebugLoggingSettings() {
const addLogging = {
persistent: {
'logger.org.elasticsearch.xpack.security.authc': 'debug',
},
};
await esSupertest.put('/_cluster/settings').send(addLogging).expect(200);
}

describe('Session Global Concurrent Limit', () => {
before(async function () {
this.timeout(120000);
Expand All @@ -138,6 +148,7 @@ export default function ({ getService }: FtrProviderContext) {
await security.testUser.setRoles(['kibana_admin']);
await es.indices.refresh({ index: '.kibana_security_session*' });
await es.cluster.health({ index: '.kibana_security_session*', wait_for_status: 'green' });
await addESDebugLoggingSettings();
await supertest
.post('/api/security/session/_invalidate')
.set('kbn-xsrf', 'xxx')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertestWithoutAuth');
const esSupertest = getService('esSupertest');
const es = getService('es');
const security = getService('security');
const esDeleteAllIndices = getService('esDeleteAllIndices');
Expand Down Expand Up @@ -88,9 +89,19 @@ export default function ({ getService }: FtrProviderContext) {
return cookie;
}

async function addESDebugLoggingSettings() {
const addLogging = {
persistent: {
'logger.org.elasticsearch.xpack.security.authc': 'debug',
},
};
await esSupertest.put('/_cluster/settings').send(addLogging).expect(200);
}

describe('Session Invalidate', () => {
beforeEach(async () => {
await es.cluster.health({ index: '.kibana_security_session*', wait_for_status: 'green' });
await addESDebugLoggingSettings();
await esDeleteAllIndices('.kibana_security_session*');
await security.testUser.setRoles(['kibana_admin']);
});
Expand Down

0 comments on commit 64e4e1b

Please sign in to comment.