Skip to content

Backport of Introduce randomized timings and reproducible randomization into controller integration tests. into release/1.17.x#19575

Merged
mkeeler merged 1 commit into
release/1.17.xfrom
backport/chaos-controller-testing/freely-civil-pug
Nov 8, 2023
Merged

Backport of Introduce randomized timings and reproducible randomization into controller integration tests. into release/1.17.x#19575
mkeeler merged 1 commit into
release/1.17.xfrom
backport/chaos-controller-testing/freely-civil-pug

Conversation

@hc-github-team-consul-core
Copy link
Copy Markdown
Collaborator

Backport

This PR is auto-generated from #19393 to be assessed for backporting due to the inclusion of the label backport/1.17.

🚨

Warning automatic cherry-pick of commits failed. If the first commit failed,
you will see a blank no-op commit below. If at least one commit succeeded, you
will see the cherry-picked commits up to, not including, the commit where
the merge conflict occurred.

The person who merged in the original PR is:
@mkeeler
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.

merge conflict error: POST https://api.github.com/repos/hashicorp/consul/merges: 409 Merge conflict []

The below text is copied from the body of the original PR.


Description

As the V2 architecture hinges on eventual consistency and controllers reconciling the existing state in response to writes, there are potential issues we could run into regarding ordering and timing of operations. We want to be able to guarantee that given a set of resources the system will always eventually get to the desired correct state. The order of resource writes and delays in performing those writes should not alter the final outcome of reaching the desired state.

To that end, this commit introduces arbitrary randomized delays before performing resources writes into the resourcetest.Client. Its PublishResources method was already randomizing the order of resource writes. By default, no delay is added to normal writes and deletes but tests can opt-in via either passing hard coded options when creating the resourcetest.Client or using the resourcetest.ConfigureTestCLIFlags function to allow processing of CLI parameters.

In addition to allowing configurability of the request delay min and max, the client also has a configurable random number generator seed. When Using the CLI parameter helpers, a test log will be written noting the currently used settings. If the test fails then you can reproduce the same delays and order randomizations by providing the seed during the previous test failure.

Testing & Reproduction steps

  • go test -min-request-delay 100 -max-request-delay 2000 . ran multiple times within both the internal/catalog/catalogtest and test/integration/consul-container/test/catalog packages. All runs were successful and it takes about 5m for each run with these settings. * The default delay settings of 10ms/50ms run in about 7s on my laptop where they previously took ~2.5s.

Overview of commits

@hc-github-team-consul-core hc-github-team-consul-core force-pushed the backport/chaos-controller-testing/freely-civil-pug branch from 5b6e6d4 to 21379c8 Compare November 8, 2023 15:45
@hc-github-team-consul-core hc-github-team-consul-core force-pushed the backport/chaos-controller-testing/freely-civil-pug branch from 21379c8 to 5b6e6d4 Compare November 8, 2023 15:45
@hashicorp-cla
Copy link
Copy Markdown

hashicorp-cla commented Nov 8, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Auto approved Consul Bot automated PR

…roller integration tests.

As the V2 architecture hinges on eventual consistency and controllers reconciling the existing state in response to writes, there are potential issues we could run into regarding ordering and timing of operations. We want to be able to guarantee that given a set of resources the system will always eventually get to the desired correct state. The order of resource writes and delays in performing those writes should not alter the final outcome of reaching the desired state.

To that end, this commit introduces arbitrary randomized delays before performing resources writes into the `resourcetest.Client`. Its `PublishResources` method was already randomizing the order of resource writes. By default, no delay is added to normal writes and deletes but tests can opt-in via either passing hard coded options when creating the `resourcetest.Client` or using the `resourcetest.ConfigureTestCLIFlags` function to allow processing of CLI parameters.

In addition to allowing configurability of the request delay min and max, the client also has a configurable random number generator seed. When Using the CLI parameter helpers, a test log will be written noting the currently used settings. If the test fails then you can reproduce the same delays and order randomizations by providing the seed during the previous test failure.

# Conflicts:
#	internal/catalog/catalogtest/run_test.go
#	internal/catalog/catalogtest/test_integration_v2beta1.go
#	test/integration/consul-container/test/catalog/catalog_test.go
@mkeeler mkeeler force-pushed the backport/chaos-controller-testing/freely-civil-pug branch from 290e2d8 to 64a48e4 Compare November 8, 2023 15:51
@mkeeler mkeeler marked this pull request as ready for review November 8, 2023 15:51
@mkeeler mkeeler requested a review from a team as a code owner November 8, 2023 15:51
@mkeeler mkeeler merged commit da2a572 into release/1.17.x Nov 8, 2023
@mkeeler mkeeler deleted the backport/chaos-controller-testing/freely-civil-pug branch November 8, 2023 21:39
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.

4 participants