Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run system tests in parallel #1909

Merged
merged 46 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ecfe60c
Prepare RunSuite to trigger tests in parallel
mrodm Jun 12, 2024
bc822c7
Reduce log from container status - temporal
mrodm Jun 12, 2024
ef1383c
Add debug message
mrodm Jun 13, 2024
85eb196
Rename field - default parallel false
mrodm Jun 13, 2024
4e928a0
Avod checking agent logs if test is skipped
mrodm Jun 13, 2024
7719ea8
Show agent data instead of JSON
mrodm Jun 13, 2024
cfb1905
Move pkgManifest and dataStreamManifest to constructor tester
mrodm Jun 13, 2024
a68f6fd
Remove extra parameter in Debugf
mrodm Jun 13, 2024
ac95e8b
Update package-spec dep
mrodm Jun 13, 2024
fa31ae5
Ensure routines finished if context cancelled or signal received
mrodm Jun 13, 2024
4c926bf
Reorder where handlers are defined
mrodm Jun 13, 2024
ae89c2e
Return service to be able to set the shutdown service handler
mrodm Jun 13, 2024
c36f4bd
Add license header
mrodm Jun 13, 2024
3213751
Revert reorder of checkEnrolledAgents and handlers
mrodm Jun 13, 2024
06d5b77
Restore debug message
mrodm Jun 13, 2024
74bdd72
Update comments
mrodm Jun 17, 2024
b50f5cd
Rename function and set private struct
mrodm Jun 17, 2024
37f8d44
Enable parallel tests in apache and nginx
mrodm Jun 17, 2024
f608d06
Remove duplicated debug log (shown in system runner)
mrodm Jun 17, 2024
e642460
Fix format global config
mrodm Jun 17, 2024
6107bca
Test duplicating configuration files in nginx - to be removed
mrodm Jun 17, 2024
d6113ba
Use channel to loop for results
mrodm Jun 17, 2024
2cdeacf
Reverted changes in service deployer
mrodm Jun 17, 2024
5c8f500
Move reading global config to cmd
mrodm Jun 17, 2024
b84c8dc
Read global config in commands for all runners
mrodm Jun 17, 2024
a8e1ee1
Add support to skip tests with global config in all runners
mrodm Jun 17, 2024
80c231c
Add comment about runners wihtout parallel system test support
mrodm Jun 17, 2024
37ee89a
Merge remote-tracking branch 'upstream/main' into system-tests-parallel
mrodm Jun 17, 2024
c933c0d
Update debug messages
mrodm Jun 17, 2024
9758666
Update package-spec to elastic/main 572e54732
mrodm Jun 17, 2024
1c4b9cf
Update log message
mrodm Jun 17, 2024
419f8ea
Update docs
mrodm Jun 17, 2024
d579fb7
Update docs
mrodm Jun 18, 2024
d8a16e9
Return just the error from tests
mrodm Jun 18, 2024
94b533f
Run system tests in parallel for sql_input
mrodm Jun 18, 2024
7b52032
Update variable name
mrodm Jun 18, 2024
a3c7288
Set maximum routines dynamically
mrodm Jun 18, 2024
3cc537d
Sort test results
mrodm Jun 18, 2024
e891842
Remove duplicated test config files
mrodm Jun 18, 2024
5f04b26
Add function to check if there is any skip configuration
mrodm Jun 18, 2024
59f7ef9
Check if test config is nil
mrodm Jun 18, 2024
ec7cb78
Remove TODO comments
mrodm Jun 19, 2024
8d8fb5d
Rename variable
mrodm Jun 19, 2024
9a228b9
Add notes about running system tests in parallel
mrodm Jun 19, 2024
a47379e
Remove package-spec replace in go.mod
mrodm Jun 19, 2024
f9ffd44
Merge remote-tracking branch 'upstream/main' into system-tests-parallel
mrodm Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
env:
SETUP_GVM_VERSION: 'v0.5.2' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
ELASTIC_PACKAGE_COMPOSE_DISABLE_VERBOSE_OUTPUT: "true"
ELASTIC_PACKAGE_MAXIMUM_NUMBER_PARALLEL_TESTS: 3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If package has enabled system tests in parallel, those tests will be triggered using 3 routines as maximum.

DOCKER_COMPOSE_VERSION: "v2.24.1"
DOCKER_VERSION: "26.1.2"
KIND_VERSION: 'v0.20.0'
Expand Down
47 changes: 45 additions & 2 deletions cmd/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"slices"
"sort"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -165,9 +166,15 @@ func testRunnerAssetCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("can't create Kibana client: %w", err)
}

globalTestConfig, err := testrunner.ReadGlobalTestConfig(packageRootPath)
if err != nil {
return fmt.Errorf("failed to read global config: %w", err)
}

runner := asset.NewAssetTestRunner(asset.AssetTestRunnerOptions{
PackageRootPath: packageRootPath,
KibanaClient: kibanaClient,
PackageRootPath: packageRootPath,
KibanaClient: kibanaClient,
GlobalTestConfig: globalTestConfig.Asset,
})

results, err := testrunner.RunSuite(ctx, runner)
Expand Down Expand Up @@ -247,10 +254,16 @@ func testRunnerStaticCommandAction(cmd *cobra.Command, args []string) error {
ctx, stop := signal.Enable(cmd.Context(), logger.Info)
defer stop()

globalTestConfig, err := testrunner.ReadGlobalTestConfig(packageRootPath)
if err != nil {
return fmt.Errorf("failed to read global config: %w", err)
}

runner := static.NewStaticTestRunner(static.StaticTestRunnerOptions{
PackageRootPath: packageRootPath,
DataStreams: dataStreams,
FailOnMissingTests: failOnMissing,
GlobalTestConfig: globalTestConfig.Static,
})

results, err := testrunner.RunSuite(ctx, runner)
Expand Down Expand Up @@ -355,6 +368,11 @@ func testRunnerPipelineCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("reading package manifest failed (path: %s): %w", packageRootPath, err)
}

globalTestConfig, err := testrunner.ReadGlobalTestConfig(packageRootPath)
if err != nil {
return fmt.Errorf("failed to read global config: %w", err)
}

runner := pipeline.NewPipelineTestRunner(pipeline.PipelineTestRunnerOptions{
Profile: profile,
PackageRootPath: packageRootPath,
Expand All @@ -365,6 +383,7 @@ func testRunnerPipelineCommandAction(cmd *cobra.Command, args []string) error {
WithCoverage: testCoverage,
CoverageType: testCoverageFormat,
DeferCleanup: deferCleanup,
GlobalTestConfig: globalTestConfig.Pipeline,
})

results, err := testrunner.RunSuite(ctx, runner)
Expand Down Expand Up @@ -532,6 +551,11 @@ func testRunnerSystemCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("reading package manifest failed (path: %s): %w", packageRootPath, err)
}

globalTestConfig, err := testrunner.ReadGlobalTestConfig(packageRootPath)
if err != nil {
return fmt.Errorf("failed to read global config: %w", err)
}

runner := system.NewSystemTestRunner(system.SystemTestRunnerOptions{
Profile: profile,
PackageRootPath: packageRootPath,
Expand All @@ -547,6 +571,7 @@ func testRunnerSystemCommandAction(cmd *cobra.Command, args []string) error {
GenerateTestResult: generateTestResult,
DeferCleanup: deferCleanup,
RunIndependentElasticAgent: false,
GlobalTestConfig: globalTestConfig.System,
})

logger.Debugf("Running suite...")
Expand Down Expand Up @@ -646,12 +671,18 @@ func testRunnerPolicyCommandAction(cmd *cobra.Command, args []string) error {
return fmt.Errorf("reading package manifest failed (path: %s): %w", packageRootPath, err)
}

globalTestConfig, err := testrunner.ReadGlobalTestConfig(packageRootPath)
if err != nil {
return fmt.Errorf("failed to read global config: %w", err)
}

runner := policy.NewPolicyTestRunner(policy.PolicyTestRunnerOptions{
PackageRootPath: packageRootPath,
KibanaClient: kibanaClient,
DataStreams: dataStreams,
FailOnMissingTests: failOnMissing,
GenerateTestResult: generateTestResult,
GlobalTestConfig: globalTestConfig.Policy,
})

results, err := testrunner.RunSuite(ctx, runner)
Expand All @@ -663,6 +694,18 @@ func testRunnerPolicyCommandAction(cmd *cobra.Command, args []string) error {
}

func processResults(results []testrunner.TestResult, testType testrunner.TestType, reportFormat, reportOutput, packageRootPath, packageName, packageType, testCoverageFormat string, testCoverage bool) error {
sort.Slice(results, func(i, j int) bool {
if results[i].Package != results[j].Package {
return results[i].Package < results[j].Package
}
if results[i].TestType != results[j].TestType {
return results[i].TestType < results[j].TestType
}
if results[i].DataStream != results[j].DataStream {
return results[i].DataStream < results[j].DataStream
}
return results[i].Name < results[j].Name
})
format := testrunner.TestReportFormat(reportFormat)
report, err := testrunner.FormatReport(format, results)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions docs/howto/asset_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ Finally, when you are done running all asset loading tests, bring down the Elast
```
elastic-package stack down
```

## Global test configuration

Each package could define a configuration file in `_dev/test/config.yml` to skip all the asset tests.

```yaml
asset:
skip:
reason: <reason>
link: <link_to_issue>
```
11 changes: 11 additions & 0 deletions docs/howto/pipeline_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,14 @@ Finally, when you are done running all pipeline tests, bring down the Elastic St
```
elastic-package stack down
```

## Global test configuration

Each package could define a configuration file in `_dev/test/config.yml` to skip all the pipeline tests.

```yaml
pipeline:
skip:
reason: <reason>
link: <link_to_issue>
```
11 changes: 11 additions & 0 deletions docs/howto/policy_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ It is possible, and encouraged, to define multiple policy tests for each package
or data stream.


## Global test configuration

Each package could define a configuration file in `_dev/test/config.yml` to skip all the policy tests.

```yaml
policy:
skip:
reason: <reason>
link: <link_to_issue>
```

### Defining the configuration of the policy

Test configuration for the policy is defined in a YAML file prefixed with
Expand Down
11 changes: 11 additions & 0 deletions docs/howto/static_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ If you want to run pipeline tests for **specific data streams** in a package, na
```
elastic-package test static --data-streams <data stream 1>[,<data stream 2>,...]
```

## Global test configuration

Each package could define a configuration file in `_dev/test/config.yml` to skip all the static tests.

```yaml
static:
skip:
reason: <reason>
link: <link_to_issue>
```
39 changes: 38 additions & 1 deletion docs/howto/system_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ Placeholders used in the `test-<test_name>-config.yml` must be enclosed in `{{{`

**NOTE**: Terraform variables in the form of environment variables (prefixed with `TF_VAR_`) are not injected and cannot be used as placeholder (their value will always be empty).

## Global test configuration

Each package could define a configuration file in `_dev/test/config.yml` that allows to:
- skip all the system tests defined.
- set if these system tests should be running in parallel or not.

```yaml
system:
parallel: true
skip:
reason: <reason>
link: <link_to_issue>
```

## Running a system test

Once the two levels of configurations are defined as described in the previous section, you are ready to run system tests for a package's data streams.
Expand Down Expand Up @@ -761,11 +775,34 @@ Considerations for this mode of running Elastic Agents:
- Create a new `_dev/deploy/docker` adding the service container if needed.
- Define the settings required for your Elastic Agents in all the test configuration files.

#### Running system tests in parallel (technical preview)

By default, `elatic-package` runs every system test defined in the package sequentially.
This could be changed to allow running in parallel tests. For that it is needed:
- running tests using independent Elastic Agents (see [section](#running-system-tests-with-independent-elastic-agents-in-each-test-technical-preview)).
- package must define the global test configuration file with these contents to enable system test parallelization:
```yaml
system:
parallel: true
```
- define how many tests in parallel should be running
- This is done defining the environment variable `ELASTIC_PACKAGE_MAXIMUM_NUMBER_PARALLEL_TESTS`


Given those requirements, this is an example to run system tests in parallel:
```shell
ELASTIC_PACKAGE_MAXIMUM_NUMBER_PARALLEL_TESTS=5 \
ELASTIC_PACKAGE_TEST_ENABLE_INDEPENDENT_AGENT=true \
elastic-package test system -v
```

**NOTE**: Currently, just system tests support to run the tests in parallel.

### Detecting ignored fields

As part of the system test, `elastic-package` checks whether any documents couldn't successfully map any fields. Common issues are the configured field limit being exceeded or keyword fields receiving values longer than `ignore_above`. You can learn more in the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-ignored-field.html).

In this case, `elastic-package test system` will fail with an error and print a sample of affected documents. To fix the issue, check which fields got ignored and the `ignored_field_values` and either adapt the mapping or the ingest pipeline to accomodate for the problematic values. In case an ignored field can't be meaningfully mitigated, it's possible to skip the check by listing the field under the `skip_ignored_fields` property in the system test config of the data stream:
In this case, `elastic-package test system` will fail with an error and print a sample of affected documents. To fix the issue, check which fields got ignored and the `ignored_field_values` and either adapt the mapping or the ingest pipeline to accommodate for the problematic values. In case an ignored field can't be meaningfully mitigated, it's possible to skip the check by listing the field under the `skip_ignored_fields` property in the system test config of the data stream:
```
# data_stream/<data stream name>/_dev/test/system/test-default-config.yml
skip_ignored_fields:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/elastic/package-spec/v3 => github.com/elastic/package-spec/v3 v3.1.6-0.20240617154842-572e54732385
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ github.com/elastic/gojsonschema v1.2.1 h1:cUMbgsz0wyEB4x7xf3zUEvUVDl6WCz2RKcQPul
github.com/elastic/gojsonschema v1.2.1/go.mod h1:biw5eBS2Z4T02wjATMRSfecfjCmwaDPvuaqf844gLrg=
github.com/elastic/kbncontent v0.1.4 h1:GoUkJkqkn2H6iJTnOHcxEqYVVYyjvcebLQVaSR1aSvU=
github.com/elastic/kbncontent v0.1.4/go.mod h1:kOPREITK9gSJsiw/WKe7QWSO+PRiZMyEFQCw+CMLAHI=
github.com/elastic/package-spec/v3 v3.1.5 h1:BoUvKZI3WhbxsWAvsOqIasgpCo8fmjmj7lZgO1JyB2s=
github.com/elastic/package-spec/v3 v3.1.5/go.mod h1:kHltfTMhDn9Whp3LZluVwI0WFW5uHwqtlByx6+c8ZHE=
github.com/elastic/package-spec/v3 v3.1.6-0.20240617154842-572e54732385 h1:nZcfkILwSR+OkQujlke73NjlFw2KSFcKV5LyvE7hI8s=
github.com/elastic/package-spec/v3 v3.1.6-0.20240617154842-572e54732385/go.mod h1:dH3ca6UEfn4c4LX3SwznyOEV8ZJN/YJ2PE+x0WeNHvM=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
Expand Down
6 changes: 5 additions & 1 deletion internal/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,29 +370,33 @@ func (p *Project) WaitForHealthy(ctx context.Context, opts CommandOptions) error
}

for _, containerDescription := range descriptions {
logger.Debugf("Container status: %s", containerDescription.String())

// No healthcheck defined for service
if containerDescription.State.Status == "running" && containerDescription.State.Health == nil {
logger.Debugf("Container %s status: %s (no health status)", containerDescription.ID, containerDescription.State.Status)
continue
}

// Service is up and running and it's healthy
if containerDescription.State.Status == "running" && containerDescription.State.Health.Status == "healthy" {
logger.Debugf("Container %s status: %s (health: %s)", containerDescription.ID, containerDescription.State.Status, containerDescription.State.Health.Status)
continue
}

// Container started and finished with exit code 0
if containerDescription.State.Status == "exited" && containerDescription.State.ExitCode == 0 {
logger.Debugf("Container %s status: %s (exit code: %d)", containerDescription.ID, containerDescription.State.Status, containerDescription.State.ExitCode)
continue
}

// Container exited with code > 0
if containerDescription.State.Status == "exited" && containerDescription.State.ExitCode > 0 {
logger.Debugf("Container %s status: %s (exit code: %d)", containerDescription.ID, containerDescription.State.Status, containerDescription.State.ExitCode)
return fmt.Errorf("container (ID: %s) exited with code %d", containerDescription.ID, containerDescription.State.ExitCode)
}

// Any different status is considered unhealthy
logger.Debugf("Container %s status: unhealthy", containerDescription.ID)
Comment on lines +376 to +399
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples of logs withthese changes:

2024/06/13 19:32:35 DEBUG Wait for healthy containers: 8f38b80e7a6b5638fd3e53bc250f49f5c2e27fa10810de506e4495d7169d4a5c
2024/06/13 19:32:35 DEBUG output command: /usr/bin/docker inspect 8f38b80e7a6b5638fd3e53bc250f49f5c2e27fa10810de506e4495d7169d4a5c
2024/06/13 19:32:35 DEBUG Container 8f38b80e7a6b5638fd3e53bc250f49f5c2e27fa10810de506e4495d7169d4a5c status: unhealthy
2024/06/13 19:32:36 DEBUG Wait for healthy containers: 8f38b80e7a6b5638fd3e53bc250f49f5c2e27fa10810de506e4495d7169d4a5c
2024/06/13 19:32:36 DEBUG output command: /usr/bin/docker inspect 8f38b80e7a6b5638fd3e53bc250f49f5c2e27fa10810de506e4495d7169d4a5c
2024/06/13 19:32:36 DEBUG Container 8f38b80e7a6b5638fd3e53bc250f49f5c2e27fa10810de506e4495d7169d4a5c status: running (health: healthy)

Previously:

2024/06/13 15:43:06 DEBUG Wait for healthy containers: 2306f9dd160408ce2e26b72565d1d3037153de14167052733f2cfd553f212de4
2024/06/13 15:43:06 DEBUG output command: /usr/bin/docker inspect 2306f9dd160408ce2e26b72565d1d3037153de14167052733f2cfd553f212de4
2024/06/13 15:43:06 DEBUG Container status: {"Config":{"Image":"elastic-package-service-87356-nginx","Labels":{"com.docker.compose.config-hash":"07b2d6403034e11414161c6489c787924e32ab36e7d12c69b977e184cf40e3c3","com.docker.compose.container-number":"1","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:106ba62762b92ccdde0edf49e09063ee28a3be98e9342dfcd3980314b0e4c192","com.docker.compose.oneoff":"False","com.docker.compose.project":"elastic-package-service-87356","com.docker.compose.project.config_files":"/opt/buildkite-agent/builds/bk-agent-prod-gcp-1718292959927056914/elastic/elastic-package/test/packages/parallel/nginx/_dev/deploy/docker/docker-compose.yml","com.docker.compose.project.working_dir":"/opt/buildkite-agent/builds/bk-agent-prod-gcp-1718292959927056914/elastic/elastic-package/test/packages/parallel/nginx/_dev/deploy/docker","com.docker.compose.service":"nginx","com.docker.compose.version":"2.24.1","maintainer":"NGINX Docker Maintainers \u003cdocker-maint@nginx.com\u003e"}},"ID":"2306f9dd160408ce2e26b72565d1d3037153de14167052733f2cfd553f212de4","State":{"Status":"running","ExitCode":0,"Health":{"Status":"healthy","Log":[{"Start":"2024-06-13T15:43:05.983549466Z","ExitCode":0,"Output":"  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r100    97  100    97    0     0  97000      0 --:--:-- --:--:-- --:--:-- 97000\nActive connections: 1 \nserver accepts handled requests\n 1 1 1 \nReading: 0 Writing: 1 Waiting: 0 \n"}]}}}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these logs are too verbose? But we can leave them and update later when/if we add the trace debug level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to keep the previous log messages ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean to leave it as is now in the PR, and reduce later when we have more log levels.

healthy = false
}

Expand Down
3 changes: 2 additions & 1 deletion internal/kibana/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (c *Client) waitUntilPolicyAssigned(ctx context.Context, a Agent, p Policy)
if err != nil {
return fmt.Errorf("can't get the agent: %w", err)
}
logger.Debugf("Agent data: %s", agent.String())
logger.Debugf("Agent %s (Host: %s): Policy ID %s LogLevel: %s Status: %s",
Copy link
Contributor Author

@mrodm mrodm Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it could be improved better these logs (removing some field?)

Example of new logs:

2024/06/13 19:33:21 DEBUG Wait until the policy (ID: 1355408f-6518-4bbd-8b39-cded15bba61d, revision: 2) is assigned to the agent (ID: ca20edcb-a929-434d-b226-9138be510e80)...
2024/06/13 19:33:23 DEBUG GET https://127.0.0.1:5601/api/fleet/agents/ca20edcb-a929-434d-b226-9138be510e80
2024/06/13 19:33:23 DEBUG Agent ca20edcb-a929-434d-b226-9138be510e80 (Host: elastic-agent-12113): Policy ID 1355408f-6518-4bbd-8b39-cded15bba61d LogLevel: debug Status: updating

Previously:

2024/06/13 15:43:12 DEBUG Wait until the policy (ID: c9f48c54-c30e-4bb7-a17a-a66f6c1776b0, revision: 2) is assigned to the agent (ID: 8bf156ea-30b2-4714-8e99-d09059f0fe54)...
2024/06/13 15:43:14 DEBUG GET https://127.0.0.1:5601/api/fleet/agents/8bf156ea-30b2-4714-8e99-d09059f0fe54
2024/06/13 15:43:14 DEBUG Agent data: {"id":"8bf156ea-30b2-4714-8e99-d09059f0fe54","policy_id":"c9f48c54-c30e-4bb7-a17a-a66f6c1776b0","local_metadata":{"host":{"name":"docker-fleet-agent"},"elastic":{"agent":{"log_level":"info"}}},"status":"updating"}

agent.ID, agent.LocalMetadata.Host.Name, agent.PolicyID, agent.LocalMetadata.Elastic.Agent.LogLevel, agent.Status)

if agent.PolicyID == p.ID && agent.PolicyRevision >= p.Revision {
logger.Debugf("Policy revision assigned to the agent (ID: %s)...", a.ID)
Expand Down
51 changes: 51 additions & 0 deletions internal/testrunner/globaltestconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package testrunner

import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/elastic/go-ucfg"
"github.com/elastic/go-ucfg/yaml"
)

type globalTestConfig struct {
Asset GlobalRunnerTestConfig `config:"asset"`
Pipeline GlobalRunnerTestConfig `config:"pipeline"`
Policy GlobalRunnerTestConfig `config:"policy"`
Static GlobalRunnerTestConfig `config:"static"`
System GlobalRunnerTestConfig `config:"system"`
}

type GlobalRunnerTestConfig struct {
Parallel bool `config:"parallel"`
SkippableConfig `config:",inline"`
}

func ReadGlobalTestConfig(packageRootPath string) (*globalTestConfig, error) {
configFilePath := filepath.Join(packageRootPath, "_dev", "test", "config.yml")

data, err := os.ReadFile(configFilePath)
if errors.Is(err, os.ErrNotExist) {
return &globalTestConfig{}, nil
}
if err != nil {
return nil, fmt.Errorf("failed to read %s: %w", configFilePath, err)
}

var c globalTestConfig
cfg, err := yaml.NewConfig(data, ucfg.PathSep("."))
if err != nil {
return nil, fmt.Errorf("unable to load global test configuration file: %s: %w", configFilePath, err)
}
if err := cfg.Unpack(&c); err != nil {
return nil, fmt.Errorf("unable to unpack global test configuration file: %s: %w", configFilePath, err)
}

return &c, nil
}
Loading