-
Notifications
You must be signed in to change notification settings - Fork 455
IMDS Mock Server Testing #1108
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
IMDS Mock Server Testing #1108
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ac41e86
Python 3.5 compat for fake_azure
vector-of-bool c40539a
proc-ctl controls child processes
vector-of-bool 0daee53
Reorder test cases to behave better with Bottle
vector-of-bool 2a5c648
Defining CTest fixtures, including a fake IMDS server
vector-of-bool f9f3574
Missing dist file
vector-of-bool 108f797
Tweaks:
vector-of-bool f573d39
XXX -> TODO
vector-of-bool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
find_package (Python3 COMPONENTS Interpreter) | ||
|
||
if (NOT TARGET Python3::Interpreter) | ||
message (STATUS "Python3 was not found, so test fixtures will not be defined") | ||
return () | ||
endif () | ||
|
||
get_filename_component(_MONGOC_BUILD_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) | ||
set (_MONGOC_PROC_CTL_COMMAND "$<TARGET_FILE:Python3::Interpreter>" -u -- "${_MONGOC_BUILD_SCRIPT_DIR}/proc-ctl.py") | ||
|
||
|
||
function (mongo_define_subprocess_fixture name) | ||
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "SPAWN_WAIT;STOP_WAIT;WORKING_DIRECTORY" "COMMAND") | ||
string (MAKE_C_IDENTIFIER ident "${name}") | ||
if (NOT ARG_SPAWN_WAIT) | ||
set (ARG_SPAWN_WAIT 1) | ||
endif () | ||
if (NOT ARG_STOP_WAIT) | ||
set (ARG_STOP_WAIT 5) | ||
endif () | ||
if (NOT ARG_WORKING_DIRECTORY) | ||
set (ARG_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") | ||
endif () | ||
if (NOT ARG_COMMAND) | ||
message (SEND_ERROR "mongo_define_subprocess_fixture(${name}) requires a COMMAND") | ||
return () | ||
endif () | ||
get_filename_component (ctl_dir "${CMAKE_CURRENT_BINARY_DIR}/${ident}.ctl" ABSOLUTE) | ||
add_test (NAME "${name}/start" | ||
COMMAND ${_MONGOC_PROC_CTL_COMMAND} start | ||
"--ctl-dir=${ctl_dir}" | ||
"--cwd=${ARG_WORKING_DIRECTORY}" | ||
"--spawn-wait=${ARG_SPAWN_WAIT}" | ||
-- ${ARG_COMMAND}) | ||
add_test (NAME "${name}/stop" | ||
COMMAND ${_MONGOC_PROC_CTL_COMMAND} stop "--ctl-dir=${ctl_dir}" --if-not-running=ignore) | ||
set_property (TEST "${name}/start" PROPERTY FIXTURES_SETUP "${name}") | ||
set_property (TEST "${name}/stop" PROPERTY FIXTURES_CLEANUP "${name}") | ||
endfunction () | ||
|
||
# Create a fixture that runs a fake Azure IMDS server | ||
mongo_define_subprocess_fixture( | ||
mongoc/fixtures/fake_imds | ||
SPAWN_WAIT 0.2 | ||
COMMAND | ||
"$<TARGET_FILE:Python3::Interpreter>" -u -- | ||
"${_MONGOC_BUILD_SCRIPT_DIR}/bottle.py" fake_azure:imds | ||
--bind localhost:14987 # Port 14987 chosen arbitrarily | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What does the
XXX
mean?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've use this convention as a weaker form of "
TODO
". Some editors will mark it as such an annotation. I'm fine to change it, since it isn't obvious what it means.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.
TODO
, or another alternative may be preferable. This is the first I have seen ofXXX
.