Skip to content

Commit

Permalink
[Archive Migration] batch 2 of removing es_archives/empty_kibana (ela…
Browse files Browse the repository at this point in the history
…stic#138208)

* replace es_archives/empty_kibana with kibanaServer.savedObjects.cleanStandardList

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* add missing kibanaServer

* add a tearDown

* revert changes that don't pass

* revert fleet_setup, delete spaces in tearDown

* Don't fail on deleting spaces

* revert file for failing test

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Lee Drengenberg and kibanamachine authored Aug 23, 2022
1 parent 50821db commit f2c20b7
Show file tree
Hide file tree
Showing 26 changed files with 82 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function setupSpacesAndUsers(getService: FtrProviderContext['getSer

export async function tearDown(getService: FtrProviderContext['getService']) {
const securityService = getService('security');
const esArchiver = getService('esArchiver');
const spacesService = getService('spaces');

for (const user of Users) {
await securityService.user.delete(user.username);
Expand All @@ -52,5 +52,7 @@ export async function tearDown(getService: FtrProviderContext['getService']) {
}
}

await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
for (const space of Spaces) {
await spacesService.delete(space.id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ const COMMON_HEADERS = {
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
const kibanaServer = getService('kibanaServer');

describe('log highlight apis', () => {
before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/simple_logs'));
after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/simple_logs'));

describe('/log_entries/highlights', () => {
describe('with the default source', () => {
before(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'));
after(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'));
before(() => kibanaServer.savedObjects.cleanStandardList());
after(() => kibanaServer.savedObjects.cleanStandardList());

it('Handles empty responses', async () => {
const { body } = await supertest
Expand Down
5 changes: 3 additions & 2 deletions x-pack/test/api_integration/apis/metrics_ui/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
const SOURCE_API_URL = '/api/metrics/source/default';
const kibanaServer = getService('kibanaServer');
const patchRequest = async (
body: PartialMetricsSourceConfigurationProperties
): Promise<MetricsSourceConfigurationResponse | undefined> => {
Expand All @@ -32,8 +33,8 @@ export default function ({ getService }: FtrProviderContext) {
describe('sources', () => {
before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'));
after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'));
beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'));
afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'));
before(() => kibanaServer.savedObjects.cleanStandardList());
after(() => kibanaServer.savedObjects.cleanStandardList());

describe('patch request', () => {
it('applies all top-level field updates to an existing source', async () => {
Expand Down
8 changes: 4 additions & 4 deletions x-pack/test/api_integration/apis/ml/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const ml = getService('ml');

const fleetPackages = ['apache', 'nginx'];
const installedPackages: Array<{ pkgName: string; version: string }> = [];

describe('modules', function () {
before(async () => {
// use empty_kibana to make sure the fleet setup is removed correctly after the tests
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
// use await kibanaServer.savedObjects.cleanStandardList(); to make sure the fleet setup is removed correctly after the tests
await kibanaServer.savedObjects.cleanStandardList();

// Fleet need to be setup to be able to setup packages
await ml.testResources.setupFleet();
Expand All @@ -32,7 +32,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
for (const fleetPackage of installedPackages) {
await ml.testResources.removeFleetPackage(fleetPackage.pkgName, fleetPackage.version);
}
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});

loadTestFile(require.resolve('./get_module'));
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/api_integration/apis/osquery/packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export default function ({ getService }: FtrProviderContext) {
let hostedPolicy: Record<string, any>;
let packagePolicyId: string;
before(async () => {
await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana');
await getService('kibanaServer').savedObjects.cleanStandardList();
await getService('esArchiver').load(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
});
after(async () => {
await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana');
await getService('kibanaServer').savedObjects.cleanStandardList();
await getService('esArchiver').unload(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const supertest = getService('supertest');

describe('Note - Saved Objects', () => {
beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'));
afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'));
before(() => kibanaServer.savedObjects.cleanStandardList());
after(() => kibanaServer.savedObjects.cleanStandardList());

describe('create a note', () => {
it('should return a timelineId, timelineVersion, noteId and version', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const supertest = getService('supertest');

describe('Pinned Events - Saved Objects', () => {
beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'));
afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'));
before(() => kibanaServer.savedObjects.cleanStandardList());
after(() => kibanaServer.savedObjects.cleanStandardList());

describe('Pinned an event', () => {
it('return a timelineId, timelineVersion, pinnedEventId and version', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
import { createBasicTimeline } from './helpers';

export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const supertest = getService('supertest');

describe('Timeline - Saved Objects', () => {
beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'));
afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'));
beforeEach(() => kibanaServer.savedObjects.cleanStandardList());
afterEach(() => kibanaServer.savedObjects.cleanStandardList());

describe('Persist a timeline', () => {
it('Create a timeline just with a title', async () => {
Expand Down
10 changes: 5 additions & 5 deletions x-pack/test/common/services/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ export function SpacesServiceProvider({ getService }: FtrProviderContext) {

return new (class SpacesService {
public async create(space: any) {
log.debug('creating space');
log.debug(`creating space ${space.name}`);
const { data, status, statusText } = await axios.post('/api/spaces/space', space);

if (status !== 200) {
throw new Error(
`Expected status code of 200, received ${status} ${statusText}: ${util.inspect(data)}`
);
}
log.debug('created space');
log.debug(`created space ${space}`);
}

public async delete(spaceId: string) {
log.debug(`deleting space: ${spaceId}`);
log.debug(`deleting space id: ${spaceId}`);
const { data, status, statusText } = await axios.delete(`/api/spaces/space/${spaceId}`);

if (status !== 204) {
throw new Error(
log.debug(
`Expected status code of 204, received ${status} ${statusText}: ${util.inspect(data)}`
);
}
log.debug(`deleted space: ${spaceId}`);
log.debug(`deleted space id: ${spaceId}`);
}
})();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function (providerContext: FtrProviderContext) {
let systemPkgVersion: string;
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});
setupFleetAndAgents(providerContext);
let packagePoliciesToDeleteIds: string[] = [];
Expand All @@ -41,7 +41,7 @@ export default function (providerContext: FtrProviderContext) {
}

await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});
it('should work with valid minimum required values', async () => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

describe('fleet_download_sources_crud', async function () {
skipIfNoDockerRegistry(providerContext);
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});
setupFleetAndAgents(providerContext);
Expand All @@ -38,7 +39,7 @@ export default function (providerContext: FtrProviderContext) {
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { setupFleetAndAgents } from '../agents/services';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const pkgName = 'error_handling';
const goodPackageVersion = '0.1.0';
const badPackageVersion = '0.2.0';
const kibanaServer = getService('kibanaServer');

const installPackage = async (pkg: string, version: string) => {
await supertest
Expand All @@ -33,10 +33,10 @@ export default function (providerContext: FtrProviderContext) {
skipIfNoDockerRegistry(providerContext);
setupFleetAndAgents(providerContext);
beforeEach(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});
afterEach(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});

it('on a fresh install, it should uninstall a broken package during rollback', async function () {
Expand Down
5 changes: 3 additions & 2 deletions x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

let agentCount = 0;
let pkgVersion: string;
describe('fleet_telemetry', () => {
skipIfNoDockerRegistry(providerContext);
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});

setupFleetAndAgents(providerContext);

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
if (pkgVersion) {
await supertest.delete(`/api/fleet/epm/packages/fleet_server/${pkgVersion}`);
Expand Down
5 changes: 3 additions & 2 deletions x-pack/test/fleet_api_integration/apis/outputs/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

describe('fleet_output_crud', async function () {
skipIfNoDockerRegistry(providerContext);
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});
setupFleetAndAgents(providerContext);
Expand All @@ -37,7 +38,7 @@ export default function (providerContext: FtrProviderContext) {
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const es: Client = getService('es');
const supertest = getService('supertest');
const kibanaServer = getService('kibanaServer');

const getPackagePolicyById = async (id: string) => {
const { body } = await supertest.get(`/api/fleet/package_policies/${id}`);
Expand All @@ -27,13 +28,13 @@ export default function (providerContext: FtrProviderContext) {
skipIfNoDockerRegistry(providerContext);
let agentPolicyId: string;
before(async () => {
await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await getService('esArchiver').load(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
});
after(async () => {
await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await getService('esArchiver').unload(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
Expand Down
5 changes: 3 additions & 2 deletions x-pack/test/fleet_api_integration/apis/package_policy/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default function (providerContext: FtrProviderContext) {
skipIfNoDockerRegistry(providerContext);

before(async () => {
await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana');
await getService('kibanaServer').savedObjects.cleanStandardList();

await getService('esArchiver').load(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
Expand All @@ -33,7 +34,7 @@ export default function (providerContext: FtrProviderContext) {
await getService('esArchiver').unload(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana');
await getService('kibanaServer').savedObjects.cleanStandardList();
});

describe('get by id', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

function withTestPackageVersion(version: string) {
before(async function () {
Expand All @@ -42,12 +43,12 @@ export default function (providerContext: FtrProviderContext) {
let packagePolicyId: string;

before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server');
});

after(async () => {
await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
await getService('esArchiver').unload(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default function (providerContext: FtrProviderContext) {
describe('Preconfiguration', async () => {
skipIfNoDockerRegistry(providerContext);
before(async () => {
await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana');
await getService('kibanaServer').savedObjects.cleanStandardList();

await getService('esArchiver').load(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
Expand All @@ -31,7 +32,7 @@ export default function (providerContext: FtrProviderContext) {
await getService('esArchiver').unload(
'x-pack/test/functional/es_archives/fleet/empty_fleet_server'
);
await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana');
await getService('kibanaServer').savedObjects.cleanStandardList();
});

// Basic health check for the API; functionality is covered by the unit tests
Expand Down
6 changes: 3 additions & 3 deletions x-pack/test/fleet_api_integration/apis/service_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const esClient = getService('es');

describe('fleet_service_tokens', async () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
await kibanaServer.savedObjects.cleanStandardList();
});

describe('POST /api/fleet/service_tokens', () => {
Expand Down
Loading

0 comments on commit f2c20b7

Please sign in to comment.