Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Nov 27, 2023

This PR avoids creating the kibana client for the pipeline and static tests.

These pipeline tests just need the Simulate API from elasticsearch, so it is not required there to have a Kibana client. And the static tests are verifying the sample events.

Related docs about pipeline and static tests:

@mrodm mrodm self-assigned this Nov 27, 2023
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

👍

}
}

var results []testrunner.TestResult
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should early check in the runners that need a kibana client if it is not nil, to avoid panics, but I guess we will find these panics during tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just checked for the other test commands, and these are the example of outputs (static does not require neither the kibana client).

 $ elastic-package test asset -v
2023/11/27 17:22:15 DEBUG Enable verbose logging
2023/11/27 17:22:15 DEBUG Distribution built without a version tag, can't determine release chronology. Please consider using official releases at https://github.com/elastic/elastic-package/releases
Run asset tests for the package
2023/11/27 17:22:15 DEBUG installing package...
Error: error running package asset tests: could not complete test run: can't create the package installer: missing kibana client

 $ elastic-package test system -v
2023/11/27 17:23:36 DEBUG Enable verbose logging
2023/11/27 17:23:36 DEBUG Distribution built without a version tag, can't determine release chronology. Please consider using official releases at https://github.com/elastic/elastic-package/releases
Run system tests for the package
2023/11/27 17:23:36 DEBUG Running system tests for data stream
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x2ee7d0c]

goroutine 1 [running]:
github.com/elastic/elastic-package/internal/kibana.(*Client).Version(...)
	/home/mariorodriguez/Coding/work/elastic-package/internal/kibana/status.go:42
github.com/elastic/elastic-package/internal/testrunner/runners/system.(*runner).run(0xc0001bb740)
	/home/mariorodriguez/Coding/work/elastic-package/internal/testrunner/runners/system/runner.go:213 +0x32c
github.com/elastic/elastic-package/internal/testrunner/runners/system.(*runner).Run(0x39bdfc0?, {0xc000542720, {{0xc000374980, 0x74}, {0xc00005809b, 0x18}, {0xc0003749dc, 0x7}}, {0xc000058064, 0x4f}, ...})
	/home/mariorodriguez/Coding/work/elastic-package/internal/testrunner/runners/system/runner.go:135 +0x5d
github.com/elastic/elastic-package/internal/testrunner.Run({0x35c0750, 0x6}, {0xc000542720, {{0xc000374980, 0x74}, {0xc00005809b, 0x18}, {0xc0003749dc, 0x7}}, {0xc000058064, ...}, ...})
	/home/mariorodriguez/Coding/work/elastic-package/internal/testrunner/testrunner.go:271 +0x95
github.com/elastic/elastic-package/cmd.testTypeCommandActionFactory.func1(0xc000625200, {0xc0002be530?, 0x0?, 0x1?})
	/home/mariorodriguez/Coding/work/elastic-package/cmd/testrunner.go:239 +0xff8
github.com/spf13/cobra.(*Command).execute(0xc000625200, {0xc0002be510, 0x1, 0x1})
	/home/mariorodriguez/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0xc000636000)
	/home/mariorodriguez/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x12cfc1a?)
	/home/mariorodriguez/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x13
main.main()
	/home/mariorodriguez/Coding/work/elastic-package/main.go:23 +0x65


 $ elastic-package test static -v
2023/11/27 17:23:24 DEBUG Enable verbose logging
2023/11/27 17:23:24 DEBUG Distribution built without a version tag, can't determine release chronology. Please consider using official releases at https://github.com/elastic/elastic-package/releases
Run static tests for the package
--- Test results for package: elastic_package_registry - START ---
╭──────────────────────────┬─────────────┬───────────┬──────────────────────────┬────────┬──────────────╮
│ PACKAGE                  │ DATA STREAM │ TEST TYPE │ TEST NAME                │ RESULT │ TIME ELAPSED │
├──────────────────────────┼─────────────┼───────────┼──────────────────────────┼────────┼──────────────┤
│ elastic_package_registry │ metrics     │ static    │ Verify sample_event.json │ PASS   │  36.873029ms │
╰──────────────────────────┴─────────────┴───────────┴──────────────────────────┴────────┴──────────────╯
--- Test results for package: elastic_package_registry - END   ---
Done

As for static is not required neither a kibana client, I will also remove it.

Copy link
Contributor Author

@mrodm mrodm Nov 27, 2023

Choose a reason for hiding this comment

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

Added to each runner a check at the beginning of the execution to ensure that the required clients are created. That would avoid also panic errors too.

@mrodm mrodm marked this pull request as ready for review November 27, 2023 16:20
@mrodm mrodm requested a review from jsoriano November 27, 2023 17:05
@mrodm mrodm changed the title Do not create kibana client for pipeline tests Do not create kibana client for pipeline and static tests Nov 27, 2023
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm merged commit 08ea257 into elastic:main Nov 28, 2023
@mrodm mrodm deleted the remove_kibana_client_pipeline_tests branch November 28, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants