mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
## Summary Part of https://github.com/elastic/kibana-team/issues/1503 This PR is mostly about moving platform tests from x-pack/test/ Before: ``` x-pack/test/ | - ftr_apis/ | - load/ | - plugin_api_perf/ | - fleet_packages/ | - fleet_tasks/ | - scalability/ | - task_manager_claimer_update_by_query/ ``` After: ``` x-pack/platform/test/ | - ftr_apis/ | - load/ | - plugin_api_perf/ | - fleet_packages/ | - fleet_tasks/ | - scalability/ | - task_manager_claimer_update_by_query/ --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
/*
|
|
* 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 { AGENTS_INDEX } from '@kbn/fleet-plugin/common';
|
|
import { FtrProviderContext } from '../api_integration/ftr_provider_context';
|
|
|
|
export async function createAgentDoc(
|
|
providerContext: FtrProviderContext,
|
|
id: string,
|
|
policyId: string,
|
|
version: string,
|
|
active: boolean = true,
|
|
additionalData: any = {}
|
|
) {
|
|
const { getService } = providerContext;
|
|
const es = getService('es');
|
|
const lastCheckin = active
|
|
? new Date().toISOString()
|
|
: new Date(new Date().getTime() - 21 * 24 * 60 * 60 * 1000).toISOString(); // 3 weeks ago
|
|
|
|
await es.index({
|
|
index: AGENTS_INDEX,
|
|
id,
|
|
document: {
|
|
id,
|
|
type: 'PERMANENT',
|
|
active: true,
|
|
enrolled_at: new Date().toISOString(),
|
|
last_checkin: lastCheckin,
|
|
policy_id: policyId,
|
|
policy_revision: 1,
|
|
policy_revision_idx: 1,
|
|
agent: {
|
|
id,
|
|
version,
|
|
},
|
|
local_metadata: {
|
|
elastic: {
|
|
agent: {
|
|
version,
|
|
upgradeable: true,
|
|
},
|
|
},
|
|
},
|
|
...additionalData,
|
|
},
|
|
refresh: 'wait_for',
|
|
});
|
|
}
|
|
|
|
export async function cleanupAgentDocs(providerContext: FtrProviderContext) {
|
|
const { getService } = providerContext;
|
|
const es = getService('es');
|
|
|
|
try {
|
|
await es.deleteByQuery({
|
|
index: AGENTS_INDEX,
|
|
refresh: true,
|
|
query: {
|
|
match_all: {},
|
|
},
|
|
});
|
|
} catch (err) {
|
|
// index doesn't exist
|
|
}
|
|
}
|