Skip to content

GODRIVER-2114 Fix failing KMS TLS tests #712

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

Merged
merged 3 commits into from
Aug 4, 2021
Merged

GODRIVER-2114 Fix failing KMS TLS tests #712

merged 3 commits into from
Aug 4, 2021

Conversation

benjirewis
Copy link
Contributor

Uses the new kms_http_server.py instead of the now-removed, trivial mock_kms.js.

EOF
mongo --nodb mock_kms.js
. ./activate_venv.sh
- command: shell.exec
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much like the mock OCSP functions, the first command sets up the local environment in the foreground, and the second command starts the Python mock server in the background. These need to be separated for the tests to consistently find the mock KMS server.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. https://github.com/evergreen-ci/evergreen/wiki/Project-Commands#shellexec notes:

background: if set to true, does not wait for the script to exit before running the next commands

My new hypothesis for the cause of the connection refused errors:

  • Evergreen would run start-kms-mock-server and proceed before the script completed.
  • The Go driver tests started before the mock KMS server started.

Starting the virtual environment in a non-background command before helps. But I think this is still hiding a race.

If the mock KMS server does not establish listening sockets before the Go driver tests run, I suspect the same issue will occur. But, given that the OCSP tasks have a similar setup, I bet the likelihood of the KMS server not starting before the Go tests run is slim to none. If we see it failing in the future, we could consider appending a foreground command to loop until it can establish a connection on port 8000. That seems unnecessary for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds exactly right. I think all the current mock servers in testing (KMS, OCSP and maybe load balancer?) have this racey behavior. It seems that if you only have the server-starting call in the background function, the tests pretty much never start before the server. So, if we start to see failures we can consider something like a foreground loop.

@benjirewis benjirewis requested a review from kevinAlbs August 3, 2021 17:59
@benjirewis benjirewis marked this pull request as ready for review August 3, 2021 17:59
Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM! Will this need to be cherry-picked on to the 1.7 branch to have tests passing on that branch? If so, can you create a ticket to track this change (description can be brief). That will tie those commits together.

@@ -827,20 +827,18 @@ functions:

start-kms-mock-server:
- command: shell.exec
type: test
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing type: test seems right here. The default command_type on L13 is setup. If this task fails it will indicate a setup failure, rather than a test failure (https://github.com/evergreen-ci/evergreen/wiki/Project-Configuration-Files#command-failure-colors)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah setup definitely seems like the right type; not sure why I had test before.

EOF
mongo --nodb mock_kms.js
. ./activate_venv.sh
- command: shell.exec
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. https://github.com/evergreen-ci/evergreen/wiki/Project-Commands#shellexec notes:

background: if set to true, does not wait for the script to exit before running the next commands

My new hypothesis for the cause of the connection refused errors:

  • Evergreen would run start-kms-mock-server and proceed before the script completed.
  • The Go driver tests started before the mock KMS server started.

Starting the virtual environment in a non-background command before helps. But I think this is still hiding a race.

If the mock KMS server does not establish listening sockets before the Go driver tests run, I suspect the same issue will occur. But, given that the OCSP tasks have a similar setup, I bet the likelihood of the KMS server not starting before the Go tests run is slim to none. If we see it failing in the future, we could consider appending a foreground command to loop until it can establish a connection on port 8000. That seems unnecessary for now.

@benjirewis benjirewis changed the title Fix failing KMS TLS tests GODRIVER-2114 Fix failing KMS TLS tests Aug 4, 2021
Copy link
Contributor Author

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

Filed GODRIVER-2114. Let's backport to both release/1.7 and release/1.6 since they both have KMS TLS tests and corresponding Evergreen waterfall tasks.

@@ -827,20 +827,18 @@ functions:

start-kms-mock-server:
- command: shell.exec
type: test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah setup definitely seems like the right type; not sure why I had test before.

EOF
mongo --nodb mock_kms.js
. ./activate_venv.sh
- command: shell.exec
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds exactly right. I think all the current mock servers in testing (KMS, OCSP and maybe load balancer?) have this racey behavior. It seems that if you only have the server-starting call in the background function, the tests pretty much never start before the server. So, if we start to see failures we can consider something like a foreground loop.

@benjirewis benjirewis merged commit e78e29b into mongodb:master Aug 4, 2021
@benjirewis benjirewis deleted the kmsTlsFix branch August 4, 2021 20:29
benjirewis added a commit that referenced this pull request Aug 4, 2021
benjirewis added a commit that referenced this pull request Aug 4, 2021
faem pushed a commit to kubedb/mongo-go-driver that referenced this pull request Mar 17, 2022
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.

2 participants