[Upgrade Assistant] Fix functional test for shards check (#163438)

## Summary
Create a new functional config file that sets up elasticsearch configs
to have a low disk threshold and a low number of shards per node to test
for health checks and deprecations.

Previously this test failed because it seems that ES takes some time to
calculate the health checks hence the indicator critical issues are not
showing during the testing period (now we don't have flakiness since we
started the server with the indicators already in place) it also means
less `before` and `after` work inside the test cases.

Closes https://github.com/elastic/kibana/issues/160833

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Ahmad Bamieh 2023-08-08 23:05:27 +03:00 committed by GitHub
parent 7e234b1a78
commit b8841bcbfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 55 deletions

View file

@ -328,6 +328,7 @@ enabled:
- x-pack/test/functional/config_security_basic.ts
- x-pack/test/functional/config.ccs.ts
- x-pack/test/functional/config.firefox.js
- x-pack/test/functional/config.upgrade_assistant.ts
- x-pack/test/functional_cloud/config.ts
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts

View file

@ -6,7 +6,6 @@
*/
import expect from '@kbn/expect';
import { setTimeout } from 'timers/promises';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function upgradeAssistantFunctionalTests({
@ -20,50 +19,27 @@ export default function upgradeAssistantFunctionalTests({
const security = getService('security');
const log = getService('log');
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/160833
describe.skip('Deprecation pages', function () {
this.tags('skipFirefox');
describe('Deprecation pages', function () {
this.tags(['skipFirefox', 'upgradeAssistant']);
before(async () => {
await security.testUser.setRoles(['superuser']);
// Cluster readiness checks
try {
// Trigger "Total shards" ES Upgrade readiness check
/**
* Trigger "Total shards" ES Upgrade readiness check
* the number of shards in the test cluster is 25-27
* so 5 max shards per node should trigger this check
* on both local and CI environments.
*/
await es.cluster.putSettings({
body: {
persistent: {
cluster: {
max_shards_per_node: '9',
max_shards_per_node: 5,
},
},
},
});
// Trigger "Low disk watermark" ES Upgrade readiness check
await es.cluster.putSettings({
body: {
persistent: {
cluster: {
// push allocation changes to nodes quickly during tests
info: {
update: { interval: '10s' },
},
routing: {
allocation: {
disk: {
threshold_enabled: true,
watermark: { low: '30%' },
},
},
},
},
},
},
});
// Wait for the cluster settings to be reflected to the ES nodes
await setTimeout(12000);
} catch (e) {
log.debug('[Setup error] Error updating cluster settings');
throw e;
@ -76,18 +52,8 @@ export default function upgradeAssistantFunctionalTests({
body: {
persistent: {
cluster: {
info: {
update: { interval: null },
},
max_shards_per_node: null,
routing: {
allocation: {
disk: {
threshold_enabled: false,
watermark: { low: null },
},
},
},
// initial cluster setting from x-pack/test/functional/config.upgrade_assistant.js
max_shards_per_node: 27,
},
},
},
@ -96,7 +62,6 @@ export default function upgradeAssistantFunctionalTests({
log.debug('[Cleanup error] Error reseting cluster settings');
throw e;
}
await security.testUser.restoreDefaults();
});
@ -111,10 +76,13 @@ export default function upgradeAssistantFunctionalTests({
it('renders the Elasticsearch upgrade readiness deprecations', async () => {
const deprecationMessages = await testSubjects.getVisibleTextAll('defaultTableCell-message');
const healthIndicatorsCriticalMessages = await testSubjects.getVisibleTextAll(
'healthIndicatorTableCell-message'
);
expect(deprecationMessages).to.contain('Disk usage exceeds low watermark');
expect(deprecationMessages).to.contain(
'The cluster has too many shards to be able to upgrade'
expect(healthIndicatorsCriticalMessages).to.contain(
'Elasticsearch is about to reach the maximum number of shards it can host, based on your current settings.'
);
});

View file

@ -17,7 +17,7 @@ export default function upgradeAssistantESDeprecationLogsPageFunctionalTests({
const es = getService('es');
describe('ES deprecation logs page', function () {
this.tags('skipFirefox');
this.tags(['skipFirefox', 'upgradeAssistant']);
before(async () => {
await security.testUser.setRoles(['superuser']);

View file

@ -15,6 +15,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const managementMenu = getService('managementMenu');
describe('security', function () {
this.tags('upgradeAssistant');
before(async () => {
await PageObjects.common.navigateToApp('home');
});

View file

@ -16,7 +16,7 @@ export default function upgradeAssistantOverviewPageFunctionalTests({
const testSubjects = getService('testSubjects');
describe('Overview Page', function () {
this.tags('skipFirefox');
this.tags(['skipFirefox', 'upgradeAssistant']);
before(async () => {
await security.testUser.setRoles(['superuser']);

View file

@ -35,11 +35,7 @@ export default async function ({ readConfigFile }) {
esTestCluster: {
license: 'trial',
from: 'snapshot',
serverArgs: [
'path.repo=/tmp/',
'xpack.security.authc.api_key.enabled=true',
'cluster.routing.allocation.disk.threshold_enabled=true', // make sure disk thresholds are enabled for UA cluster testing
],
serverArgs: ['path.repo=/tmp/', 'xpack.security.authc.api_key.enabled=true'],
},
kbnTestServer: {
@ -183,6 +179,11 @@ export default async function ({ readConfigFile }) {
},
},
suiteTags: {
...kibanaCommonConfig.get('suiteTags'),
exclude: [...kibanaCommonConfig.get('suiteTags').exclude, 'upgradeAssistant'],
},
// choose where screenshots should be saved
screenshots: {
directory: resolve(__dirname, 'screenshots'),

View file

@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrConfigProviderContext } from '@kbn/test';
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('./config.base.js'));
return {
...functionalConfig.getAll(),
testFiles: [require.resolve('./apps/upgrade_assistant')],
junit: {
reportName: 'Chrome X-Pack UI Upgrade Assistant Functional Tests',
},
suiteTags: {
include: ['upgradeAssistant'],
},
esTestCluster: {
...functionalConfig.get('esTestCluster'),
serverArgs: [
'path.repo=/tmp/',
'xpack.security.authc.api_key.enabled=true',
'cluster.routing.allocation.disk.threshold_enabled=true', // make sure disk thresholds are enabled for UA cluster testing
'cluster.routing.allocation.disk.watermark.low=30%',
'cluster.info.update.interval=10s',
'cluster.max_shards_per_node=27',
],
},
};
}