mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [Simplify and reduce flakiness of license.public (#215874)](https://github.com/elastic/kibana/pull/215874) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"gerard.soldevila@elastic.co"},"sourceCommit":{"committedDate":"2025-03-25T16:09:30Z","message":"Simplify and reduce flakiness of license.public (#215874)\n\n## Summary\n\n* Factorise logic to fetch latest license.\n* Add an extra `manualRefresh` step, to ensure we get the latest\nemission.\n\nAims at tackling [latest\nfailures](https://github.com/elastic/kibana/issues/53575#issuecomment-2751034614)\non licensing tests.","sha":"359374e78f310ff91e6a13a52245f20fedc03d3c","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","backport:all-open","v9.1.0"],"title":"Simplify and reduce flakiness of license.public","number":215874,"url":"https://github.com/elastic/kibana/pull/215874","mergeCommit":{"message":"Simplify and reduce flakiness of license.public (#215874)\n\n## Summary\n\n* Factorise logic to fetch latest license.\n* Add an extra `manualRefresh` step, to ensure we get the latest\nemission.\n\nAims at tackling [latest\nfailures](https://github.com/elastic/kibana/issues/53575#issuecomment-2751034614)\non licensing tests.","sha":"359374e78f310ff91e6a13a52245f20fedc03d3c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215874","number":215874,"mergeCommit":{"message":"Simplify and reduce flakiness of license.public (#215874)\n\n## Summary\n\n* Factorise logic to fetch latest license.\n* Add an extra `manualRefresh` step, to ensure we get the latest\nemission.\n\nAims at tackling [latest\nfailures](https://github.com/elastic/kibana/issues/53575#issuecomment-2751034614)\non licensing tests.","sha":"359374e78f310ff91e6a13a52245f20fedc03d3c"}}]}] BACKPORT--> Co-authored-by: Gerard Soldevila <gerard.soldevila@elastic.co>
This commit is contained in:
parent
90a161eac4
commit
e9caf3a381
1 changed files with 47 additions and 62 deletions
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { LicensingPluginSetup } from '@kbn/licensing-plugin/public';
|
||||
import { FtrProviderContext } from '../services';
|
||||
import type { ILicense, LicensingPluginStart } from '@kbn/licensing-plugin/public';
|
||||
import type { FtrProviderContext } from '../services';
|
||||
import { createScenario } from '../scenario';
|
||||
import '@kbn/core-provider-plugin/types';
|
||||
|
||||
|
@ -16,78 +16,63 @@ export default function (ftrContext: FtrProviderContext) {
|
|||
const { getService } = ftrContext;
|
||||
const testSubjects = getService('testSubjects');
|
||||
const browser = getService('browser');
|
||||
|
||||
const scenario = createScenario(ftrContext);
|
||||
|
||||
const fetchLatestLicense = async (): Promise<ILicense> => {
|
||||
// make sure license ids are aligned between ES and Kibana
|
||||
await scenario.waitForPluginToDetectLicenseUpdate();
|
||||
|
||||
return await browser.executeAsync(async function refreshAndFetchLicense(cb) {
|
||||
const {
|
||||
start: { core, plugins },
|
||||
testUtils,
|
||||
} = window._coreProvider;
|
||||
const licensing: LicensingPluginStart = plugins.licensing;
|
||||
|
||||
// this call enforces signature check to detect license update and causes license re-fetch
|
||||
await core.http.get('/');
|
||||
|
||||
// trigger a manual refresh, just to be sure
|
||||
await licensing.refresh();
|
||||
|
||||
// wait a bit to make sure any older values have passed through the replay(1)
|
||||
await testUtils.delay(1000);
|
||||
|
||||
cb(await licensing.getLicense());
|
||||
});
|
||||
};
|
||||
|
||||
describe('changes in license types', () => {
|
||||
after(async () => {
|
||||
before(async function setup() {
|
||||
await scenario.setup();
|
||||
});
|
||||
|
||||
after(async function teardown() {
|
||||
await scenario.teardown();
|
||||
});
|
||||
|
||||
it('provides changes in license types', async () => {
|
||||
await scenario.setup();
|
||||
await scenario.waitForPluginToDetectLicenseUpdate();
|
||||
it('are reflected in the start contract', async function updateAndCheckLicense() {
|
||||
// fetch default license
|
||||
let license = await fetchLatestLicense();
|
||||
expect(license.type).to.be('basic');
|
||||
|
||||
expect(
|
||||
await browser.executeAsync(async (cb) => {
|
||||
const { setup, testUtils } = window._coreProvider;
|
||||
// this call enforces signature check to detect license update
|
||||
// and causes license re-fetch
|
||||
await setup.core.http.get('/');
|
||||
await testUtils.delay(1000);
|
||||
|
||||
const licensing: LicensingPluginSetup = setup.plugins.licensing;
|
||||
licensing.license$.subscribe((license) => cb(license.type));
|
||||
})
|
||||
).to.be('basic');
|
||||
|
||||
// license hasn't changed
|
||||
await scenario.waitForPluginToDetectLicenseUpdate();
|
||||
|
||||
expect(
|
||||
await browser.executeAsync(async (cb) => {
|
||||
const { setup, testUtils } = window._coreProvider;
|
||||
// this call enforces signature check to detect license update
|
||||
// and causes license re-fetch
|
||||
await setup.core.http.get('/');
|
||||
await testUtils.delay(1000);
|
||||
|
||||
const licensing: LicensingPluginSetup = setup.plugins.licensing;
|
||||
licensing.license$.subscribe((license) => cb(license.type));
|
||||
})
|
||||
).to.be('basic');
|
||||
// ensure consecutive fetch still yields 'basic'
|
||||
license = await fetchLatestLicense();
|
||||
expect(license.type).to.be('basic');
|
||||
|
||||
// switch to trial (can do it only once)
|
||||
await scenario.startTrial();
|
||||
await scenario.waitForPluginToDetectLicenseUpdate();
|
||||
license = await fetchLatestLicense();
|
||||
expect(license.type).to.be('trial');
|
||||
|
||||
expect(
|
||||
await browser.executeAsync(async (cb) => {
|
||||
const { setup, testUtils } = window._coreProvider;
|
||||
// this call enforces signature check to detect license update
|
||||
// and causes license re-fetch
|
||||
await setup.core.http.get('/');
|
||||
await testUtils.delay(1000);
|
||||
|
||||
const licensing: LicensingPluginSetup = setup.plugins.licensing;
|
||||
licensing.license$.subscribe((license) => cb(license.type));
|
||||
})
|
||||
).to.be('trial');
|
||||
// ensure consecutive fetch still yields 'trial'
|
||||
license = await fetchLatestLicense();
|
||||
expect(license.type).to.be('trial');
|
||||
|
||||
// switch back to basic
|
||||
await scenario.startBasic();
|
||||
await scenario.waitForPluginToDetectLicenseUpdate();
|
||||
|
||||
expect(
|
||||
await browser.executeAsync(async (cb) => {
|
||||
const { setup, testUtils } = window._coreProvider;
|
||||
// this call enforces signature check to detect license update
|
||||
// and causes license re-fetch
|
||||
await setup.core.http.get('/');
|
||||
await testUtils.delay(1000);
|
||||
|
||||
const licensing: LicensingPluginSetup = setup.plugins.licensing;
|
||||
licensing.license$.subscribe((license) => cb(license.type));
|
||||
})
|
||||
).to.be('basic');
|
||||
license = await fetchLatestLicense();
|
||||
expect(license.type).to.be('basic');
|
||||
|
||||
// banner shown only when license expired not just deleted
|
||||
await testSubjects.missingOrFail('licenseExpiredBanner');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue