-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ftr] add fleetAndAgents service (#191448)
## Summary This PR refactors the `setupFleetAndAgents` helper function into a `FleetAndAgents` FTR service, which is now initialized during the config file loading. Reason: The previous implementation of `setupFleetAndAgents` wrapped a Mocha `before` hook, which is considered an anti-pattern according to the Mocha ESLint rules that the Operations and QA teams have agreed to enable in the Kibana repo. It's best practice to avoid duplicating hooks, as this can lead to inconsistent test results and make debugging difficult. Ensuring a single before and after hook sequence guarantees that the associated logic runs in a predictable and sequential manner. This change also unblocks #191267, where we plan to enforce the same recommended Mocha ESLint rules that were previously enabled for UI tests in #190690. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
9f01f73
commit 069c158
Showing
65 changed files
with
264 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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 { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; | ||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
export async function FleetAndAgents({ getService }: FtrProviderContext) { | ||
// Use elastic/fleet-server service account to execute setup to verify privilege configuration | ||
const es = getService('es'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
|
||
return { | ||
async setup() { | ||
const { token } = await es.security.createServiceToken({ | ||
namespace: 'elastic', | ||
service: 'fleet-server', | ||
}); | ||
|
||
await supertestWithoutAuth | ||
.post(`/api/fleet/setup`) | ||
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') | ||
.set('kbn-xsrf', 'xxx') | ||
.set('Authorization', `Bearer ${token.value}`) | ||
.send() | ||
.expect(200); | ||
await supertestWithoutAuth | ||
.post(`/api/fleet/agents/setup`) | ||
.set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') | ||
.set('kbn-xsrf', 'xxx') | ||
.set('Authorization', `Bearer ${token.value}`) | ||
.send({ forceRecreate: true }) | ||
.expect(200); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.