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

Support multiple system tests per data_stream #209

Merged
merged 10 commits into from
Jan 12, 2021
Merged

Support multiple system tests per data_stream #209

merged 10 commits into from
Jan 12, 2021

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Dec 21, 2020

Updates the system tests runner so that multiple test-*-config.yml files can be included in <data_stream>/_dev/tests/system. This allows testing multiple inputs and/or different configuration options per data stream.

Example test for two inputs:

test-tcp-input.yml:

  input: tcp
  service: bluecoat-director-tcp
  vars: ~
  data_stream:
    vars:
      tcp_host: 0.0.0.0
      tcp_port: 9514

test-udp-input.yml:

  input: udp
  service: bluecoat-director-udp
  vars: ~
  data_stream:
    vars:
      udp_host: 0.0.0.0
      udp_port: 9514

The service tags allows to uses different containers for the tests. In this case, to generate traffic using different protocols.

Sample docker-compose.yml in <package>/_dev/deploy/docker:

version: '2.3'
services:
  bluecoat-director-tcp:
    tty: true
    build: .
    volumes:
      - ./logs:/logs/:ro
    command: /stream -proto tcp -dest elastic-agent:9514 /logs/generated.log
  bluecoat-director-udp:
    tty: true
    build: .
    volumes:
      - ./logs:/logs/:ro
    command: /stream -proto udp -delay 100ms -dest elastic-agent:9514 /logs/generated.log 

Related #208
Related elastic/package-spec#101

@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 21, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #209 updated

  • Start Time: 2021-01-12T15:22:18.551+0000

  • Duration: 11 min 42 sec

Test stats 🧪

Test Results
Failed 0
Passed 11
Skipped 0
Total 11

@adriansr adriansr marked this pull request as draft December 21, 2020 19:51
@adriansr adriansr marked this pull request as ready for review December 22, 2020 15:49
@adriansr
Copy link
Contributor Author

/test

@adriansr adriansr added the enhancement New feature or request label Dec 22, 2020
@ycombinator
Copy link
Contributor

ycombinator commented Dec 28, 2020

This is a great addition, @adriansr. I was wondering how long before we needed it 🙂 .

I was on PTO all last week so I'm only seeing this PR now. I should be able to review it today or tomorrow at the latest.

// Determine test name
name := config.Name
if name == "" {
name = config.Input
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that the use case for this change is to test with different inputs but I think your solution is more generic than that. So I would not fallback to config.Input if config.Name is not defined. I think we can require developers to specify config.Name always, so if it's empty I think we should error out.

}
c = append(c, single)
}
return c, nil
Copy link
Contributor

@ycombinator ycombinator Dec 29, 2020

Choose a reason for hiding this comment

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

This is nice but I'm wondering if we should simplify and require that the test config should always be a list of cases. That way it's also a hint to package developers that multiple test cases are allowed. Of course, this would mean updating existing system test configurations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this PR has been started too early. It's nice to have a PoC showing the concept, but ideally we kick off with a proposal in package-spec, as it should be adjusted first.

What do you think about keeping the same order as in pipeline tests, which support multiple test cases per data_stream? See: https://github.com/elastic/integrations/tree/master/packages/apache/data_stream/access/_dev/test/pipeline
I'm referring to the name pattern: test-name.config.yml.

Regarding the config.yml, I think we have to adjust all integrations, but as there is dependency versioning in place, I don't think we need to rollout changes synchronically.

IMHO the order of steps is the following:

  1. PR to the package-spec introducing new config.yml.
  2. This PR with updated package-spec dependency.
  3. PR to the Integrations repository polishing all config.ymls

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

Just left a couple of minor comments.

Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

left a general comment

The <data_stream>/_dev/tests/system/config.yml can now be a list of
tests, so that multiple inputs and / or multiple configurations can be
tested.
Some tests configuration needs variables from the docker-compose, so
it's necessary to regenerate the test config.yml after starting the
project.
@mtojek mtojek self-requested a review January 12, 2021 09:28
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

@adriansr I'm afraid that changes you pushed to the package-spec blocked the other team (#216) and will be a problem in Integrations as the elastic-package with new spec won't accept any existing config.yml files.

I'm afraid we need to solve it ASAP.

@adriansr
Copy link
Contributor Author

@mtojek this PR is ready for review and incorporates the changes from #216 (because it also needs to update the package-spec dependency).

@mtojek
Copy link
Contributor

mtojek commented Jan 12, 2021

I see it's ready for review, but once you push this, you will also block updating the elastic-package in Integrations without adjusting multiple files. I'm not convinced about the timeline and wouldn't like to block people. Do you plan to adjust all integrations immediately?

I'm referring to this line:

var systemTestConfigFilePattern = regexp.MustCompile(`^test-([a-z0-9_.-]+)-config.yml$`)

@ycombinator ycombinator self-requested a review January 12, 2021 12:47

type testConfig struct {
Input string `config:"input"`
Service string `config:"service"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@mtojek This is more of a note for us for the future: as we add more service deployers we will need to make sure this field continues to work as expected with the new service deployers as well (not just the Docker compose one that we have today).

@mtojek mtojek self-requested a review January 12, 2021 12:54
@@ -0,0 +1,22 @@
tcp:
host: "{{tcp_host}}:{{tcp_port}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the indentation here correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out is not an indentation problem. That tcp key is just meaningless. Seems like a few packages include this mistake and we've just been repeating it in some places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, thanks. Can you make an issue (or PR, whatever is easier), probably in the integrations repo to clean up the meaningless keys?

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

Left a couple of minor comments/questions on indentation. Besides those, this PR LGTM.

Would be nice to have a sister PR ready to go in https://github.com/elastic/integrations that updates all existing system test configs per the new naming convention and syntax introduced in this PR. That way you can just update that PR with the elastic-package dependency once this PR here is merged and we can quickly get all integrations updated as well.

@adriansr adriansr merged commit 783d466 into elastic:master Jan 12, 2021
adriansr added a commit to elastic/integrations that referenced this pull request Jan 12, 2021
Updates the system tests for the packages that use them to conform to
the new format introduced in elastic/package-spec#101 and incorporated
in elastic-package tool in elastic/elastic-package#209.

This also disables 3 tests that are failing:
- cef
- crowdstrike
- nats/route
mtojek pushed a commit that referenced this pull request Jan 14, 2021
This reverts part of the changes in #209 as some tests may require more
than one container running at the same time.
eyalkraft pushed a commit to build-security/integrations that referenced this pull request Mar 30, 2022
Updates the system tests for the packages that use them to conform to
the new format introduced in elastic/package-spec#101 and incorporated
in elastic-package tool in elastic/elastic-package#209.

This also disables 3 tests that are failing:
- cef
- crowdstrike
- nats/route
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants