Repository navigation
Migrate pynessie testing to testcontainers - #8
Conversation
1b06813 to
b65a7e1
Compare
Also adopt tests to (not so) recent changes: * require common ancestor for merges * remove expected content code (was required for global state)
XN137
left a comment
There was a problem hiding this comment.
nice work!
some minor questions/suggestions
the assert len(logs) == 2 change seems the most problematic
| @@ -0,0 +1,3 @@ | |||
| [pytest] | |||
| markers = | |||
| nessie: Test run against a Nessie container | |||
There was a problem hiding this comment.
nit: localserver, nessieserver or the like? just nessie seems confusing since every test is about (py)nessie
| assert_that(logs[0]["message"]).starts_with("Merged dev at ") | ||
| logs = simplejson.loads(execute_cli_command(["--json", "log", "dev"])) | ||
| assert len(logs) == 1 | ||
| assert_that(logs).is_length(2) |
There was a problem hiding this comment.
nit: pytest has smart asserts that provide full context on failure:
https://docs.pytest.org/en/6.2.x/assert.html
so personally dont see necessity for assert_that usage tbh
| main_hash = ref_hash("main") | ||
|
|
||
| merge_output = execute_cli_command(["merge", "dev", "-c", main_hash]) | ||
| assert_that(merge_output).is_equal_to("Merge succeeded but legacy server did not respond with additional details.\n") |
There was a problem hiding this comment.
if we remove the test, should we also remove the code around it?
if we keep the code, would it be worth to add a mechanism to run this specific test against an older docker image?
| assert len(merge_response.source_commits) == 1 | ||
| assert len(merge_response.details) == 1 | ||
| assert_that(merge_response.details[0].source_commits[0]).is_equal_to(dev_hash) | ||
| assert_that(merge_response.details).is_length(1) |
There was a problem hiding this comment.
just wondering:
why can we longer assert dev_hash here?
There was a problem hiding this comment.
source_commits + target_commits are no longer populated (removed in v2)
| logs = simplejson.loads(execute_cli_command(["--json", "log", branch])) | ||
|
|
||
| assert len(logs) == 1 | ||
| assert len(logs) == 2 |
There was a problem hiding this comment.
doesnt this change now violate the comment 3 lines above i.e. "no commit to happen"?
There was a problem hiding this comment.
Yea - the comment's wrong. Removed
|
|
||
| @pytest.mark.vcr(record_mode="none") | ||
| @pytest.mark.nessie | ||
| @pytest.mark.skip("Test is no longer valid?") |
There was a problem hiding this comment.
if we can no longer inject error responses like this, then we might want to remove the tests instead of skipping
| def pytest_runtest_setup(item: pytest.Item) -> None: | ||
| """Starts a Nessie container, if needed.""" | ||
| if nessie_test_config.nessie_container is None and item.get_closest_marker("nessie") is not None: | ||
| nessie_test_config.nessie_container = NessieContainer(image=NessieContainer.DEFAULT_TEST_IMAGE) |
There was a problem hiding this comment.
is DEFAULT_TEST_IMAGE the latest "snapshot release" of the nessie image?
because DEFAULT_IMAGE is the latest official release (which we dont use in these tests now it seems).
i am wondering whether this may cause issues in the following cases:
- snapshot is broken for some reason (suddenly pynessie PRs cant pass CI)
- snapshot has an intentional breaking change (suddenly pynessie PRs cant pass CI even though they might be unrelated)
so just thinking out loud: maybe PR CI should run against a known good image version and on main branch we have scheduled CI run against unstable
but we can also figure out the issues once they actually happen
There was a problem hiding this comment.
thinking about this again:
it may also be a question about compatibility guarantees i.e. what pynessie versions are working with what nessie server versions?
if we have some backwards compatibility guarantees we might want to run against those versions in CI.
previously both were released at the same time (but potentially broken due to VCR stuff not getting updated) but now with a separate repos (and versions?) it may be even less clear
There was a problem hiding this comment.
The reason was actually the 2nd point: identify breaking changes w/ Nessie snapshot releases.
I was quite surprised how much stuff was actually no longer working - were just/mostly tests, but still.
There was a problem hiding this comment.
Yea, we'd need CI against multiple release incl "latest main". But that can be done later, WDYT?
|
|
||
| def pytest_runtest_teardown(item: pytest.Item, nextitem: Optional[pytest.Item]) -> None: | ||
| """Stops the Nessie container, if one was started.""" | ||
| if item.get_closest_marker("nessie") is not None and nessie_test_config.nessie_container is not None: |
There was a problem hiding this comment.
nit: the is not None is often unnecessarily verbose and can be omited here for example
since we dont have 0 or the empty string here ever
|
|
||
| Run the Quarkus server with `-Dnessie.server.send-stacktrace-to-client=false` (this is the default) to reduce | ||
| the size of the vcr cassettes and create less noise in updates related to REST api changes. | ||
| PyNessie uses released Nessie Docker containers to execute tests. |
There was a problem hiding this comment.
nit: maybe mention NessieContainer class
XN137
left a comment
There was a problem hiding this comment.
latest commits lgtm
but CI fails linting:
pynessie/commands/merge.py:18:1: F401 'json' imported but unused
feel free to merge if that is the only change required to pass CI
Also adopt tests to (not so) recent changes: