Skip to content
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

test: Add e2e test for streaming updates python client #8901

Merged
merged 4 commits into from
Mar 4, 2024

Conversation

gt2345
Copy link
Contributor

@gt2345 gt2345 commented Feb 26, 2024

Description

Add e2e test for streaming updates python client

Test Plan

e2e tests pass

Commentary (optional)

Checklist

  • Changes have been manually QA'd
  • User-facing API changes need the "User-facing API Change" label.
  • Release notes should be added as a separate file under docs/release-notes/.
    See Release Note for details.
  • Licenses should be included for new code which was copied and/or modified from any external code.

Ticket

MD-282

Copy link

netlify bot commented Feb 26, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit 6239e0c
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/65e612cb861f6c0008930971

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.21%. Comparing base (f997cd8) to head (6239e0c).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8901      +/-   ##
==========================================
- Coverage   47.21%   47.21%   -0.01%     
==========================================
  Files        1162     1162              
  Lines      175913   175913              
  Branches     2237     2235       -2     
==========================================
- Hits        83062    83059       -3     
- Misses      92693    92696       +3     
  Partials      158      158              
Flag Coverage Δ
backend 42.07% <ø> (-0.01%) ⬇️
harness 63.93% <ø> (ø)
web 42.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes

@@ -13,6 +13,7 @@ markers =
e2e_cpu_postgres: end to end CPU tests for testing basic database functionality
e2e_cpu_cross_version: end to end CPU tests for testing basic cluster functionality with differing master/agent versions
e2e_cpu_agent_connection_loss: end to end CPU tests for testing agent functionality on connection loss
e2e_cpu_streaming: end to end streaming updates tests
Copy link
Member

Choose a reason for hiding this comment

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

why add a new kind of test? Why not include this in the normal cpu test suite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder what is the rule for splitting tests? I saw rbac, elastic being tested separately

Copy link
Member

Choose a reason for hiding this comment

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

there really isn't a rule.

The rbac tests are EE only, so that makes sense.

The elastic tests require a special cluster, so that also makes sense.

But these tests aren't very special, they shouldn't get their own suite.


from determined.common.api import bindings
from determined.common.streams import wire
from determined.common.streams._client import LomondStreamWebSocket, ProjectSpec, Stream, Sync
Copy link
Member

Choose a reason for hiding this comment

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

don't import symbols directly; only import modules.

In this case, from determined.common import streams and use streams.LomondStreamWebSocket, streams.ProjectSpec, etc.

newProjectName = "streaming_project_1"

resp_w = bindings.post_PostWorkspace(
sess, body=bindings.v1PostWorkspaceRequest(name=f"workspace_aug_{uuid.uuid4().hex[:8]}")
Copy link
Member

Choose a reason for hiding this comment

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

how about codecs.encode(random.randbytes(4), 'hex') instead?

Using uuid.uuid4() to get random bytes is odd.

assert event == wire.ProjectsDeleted(str(p.id))
break
else:
raise Exception("Unexpected message from stream.")
Copy link
Member

Choose a reason for hiding this comment

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

don't raise a bare Exception. Use a ValueError if you have to do something whose meaning doesn't convey much.

Also, please include the message in the exception, so that if anybody were to hit the error in CI they'd see the message that caused the problem in its entirety.


from determined.common import streams
from determined.common.api import bindings
from determined.common.streams import _client
Copy link
Member

Choose a reason for hiding this comment

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

You are importing the modules, yes, but in the case of the streams._client module, there is nothing that calling code should be importing directly.

The full code layout rfc is here if you want to read it.

TL;DR is: you can generally assume that any of our python files that start with an underscore are not meant to be imported directly, and the relevant symbols should be available in their parent namespace.

So in this case, all the symbols you get from _client.* should actually be accessed as stream.*.

You can think of this as a way to separate the organization of source code (which code goes in which _-prefixed files) from the import path for accessing exported symbols.

rb-determined-ai
rb-determined-ai approved these changes Mar 4, 2024
@gt2345 gt2345 merged commit a5b425a into main Mar 4, 2024
73 of 85 checks passed
@gt2345 gt2345 deleted the gt/282-py-client-test branch March 4, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants