-
Notifications
You must be signed in to change notification settings - Fork 11
Switch context by test #204
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
Conversation
07417a7
to
9e97791
Compare
9e97791
to
7e77ef4
Compare
description: The MongoDB Controllers for Kubernetes enable easy deploys of | ||
MongoDB into Kubernetes clusters, using our management, monitoring and | ||
backup platforms, Ops Manager and Cloud Manager. | ||
description: The MongoDB Controllers for Kubernetes enable easy deploys of MongoDB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason it started to format it differently despite being up-to-date on master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try updating your python packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that did the trick, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes it: #210
|
||
# shellcheck disable=1091 | ||
source scripts/funcs/errors | ||
|
||
script_name=$(readlink -f "${BASH_SOURCE[0]}") | ||
script_dir=$(dirname "${script_name}") | ||
context_file="${script_dir}/../../.generated/context.export.env" | ||
context_file="$(realpath "${script_dir}/../../.generated/context.export.env")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this resolves to the physical path and avoids huge paths with multiple /../../ when debugging with -x
fb08643
to
9a76e72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome PR ! I like that it doesn't break anything to existing workflows
Nice demo gif as well
Thanks for this improvement 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work -
lets merge mine first #210
@@ -116,3 +116,8 @@ export MDB_SEARCH_COMMUNITY_VERSION | |||
|
|||
export MDB_SEARCH_COMMUNITY_NAME="mongodb-search-community" | |||
export MDB_SEARCH_COMMUNITY_REPO_URL="quay.io/mongodb" | |||
|
|||
|
|||
if [[ ${MDB_BASH_DEBUG:-0} == 1 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a small comment? I actually have no clue what this does :D
@@ -49,5 +50,3 @@ else | |||
fi | |||
|
|||
title "E2e test ${test} is finished" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eof new line?
@@ -2,6 +2,7 @@ | |||
|
|||
set -Eeou pipefail | |||
|
|||
test "${MDB_BASH_DEBUG:-0}" -eq 1 && set -x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a small comment for the non bash users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to put comment to each that line, because that line should be present in all of our bash scripts.
It's allowing us to debug deeply nested shell scripts, e.g.
MDB_BASH_DEBUG=1 make e2e ...
will just propagate set -x in all scripts that declare this
9a76e72
to
ca7d2d3
Compare
Summary
This PR helps in switching to a proper context/variant by specifying a test mark or full task's evergreen url.
It solves a source of friction in our day-to-day workflows, which is finding which context to switch to in order to run a particular test. And by being able to switch context by specifying evergreen task's url we're a step closer to having automation that reruns a failed script locally.
Current workflow
To find a context to run the test locally we often start from two places:
make switch context=<copied variant>
or use interactive fzf-poweredmake switch
(without args), paste or type the variant and press enter.@pytest.mark
in the file, copy it, go to evergreen.yml, find a task group containing that file, copy its name, then find a variant where that task group is used, copy variant name, runmake switch context=<copied variant>
...Proposed workflow
make switcht
is a new tool which is a superchargedmake switch
. It's named similarly (typingmake switch
is kind of a muscle memory now) and works in two modes:test=
argument:make switcht test=<test>
, where<test>
is a pytest mark (e.g.e2e_replica_set
) - it will list all the variants that this test is running in to be picked withfzf
make switcht test=<task url>
, where<task url>
is a full url to the evergreen test - it will switch directly to the variant from that testmake switch
, but lists first all test files with their marks to fuzzy-find the test, which then is used to list pick its variants:make switcht
Requirements
It requires:
make switch
)scripts/dev/contexts/private-context
Changes
Majority of the implementation is in two places:
scripts/dev/switch_context_by_test.sh
- it's mostly forfzf
, finding pytest marks usingrg
. It calls scripts/python/find_test_variants.py--task-name
) or a variant from a full evg task url (--task-url
)Proof of Work
Here are some examples for the most common use cases:
With explicit test= parameter
make switcht test=e2e_replica_set
make switcht test='https://spruce.mongodb.com/task/[...]/logs?execution=0'
Without any parameters (fully interactive)
make switcht
make switcht
make switcht
Afterwards, if the context needs to be regenerated again just run
make switch
(without t) + enter - it will remember last switched context and be selected first.Checklist
Reminder (Please remove this when merging)