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

align test session id format with cli command #52

Merged
merged 4 commits into from
Aug 24, 2021

Conversation

Konboi
Copy link
Collaborator

@Konboi Konboi commented Aug 24, 2021

launchableinc/cli outputs session builds/{build number}/test_sessions/{test session id} format. like below)

$ launchable record session --build cli
builds/cli/test_sessions/310

However, nose-launchable handle test session id as test_sessions/{test session id}, the cli will fail to parse session https://github.com/launchableinc/cli/blob/1df90eb8ffe42ae6f7deb3f2e1fb6482ec8613f4/launchable/utils/session.py#L102-L111. So, I fixed it.

Before fixing it, the cli only used the base so this issue didn't become a problem https://github.com/launchableinc/cli/blob/1df90eb8ffe42ae6f7deb3f2e1fb6482ec8613f4/launchable/commands/subset.py#L189-L191

@Konboi Konboi force-pushed the fix-align-test-session-id-format branch from c1f1bde to 83beb53 Compare August 24, 2021 01:50
@Konboi Konboi requested a review from shuheiktgw August 24, 2021 01:53
@@ -78,12 +78,11 @@ def start(self, build_number):
response_body = res.json()
logger.debug("Response body: {}".format(response_body))

self.test_session_id = response_body['id']
self.test_session_id = "builds/{}/test_sessions/{}".format(
Copy link
Contributor

@shuheiktgw shuheiktgw Aug 24, 2021

Choose a reason for hiding this comment

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

self.test_session_id is used to construct urls for uploading test case results and closing test sessions so I don't think changing self.test_session_id itself is a good idea. Instead, you might want to somehow pass build_name (or build_number) to the subset method.

def upload_events(self, events):
url = "{}/intake/organizations/{}/workspaces/{}/builds/{}/test_sessions/{}/events".format(
self.base_url,
self.org_name,
self.workspace_name,
self.build_number,
self.test_session_id

def finish(self):
url = "{}/intake/organizations/{}/workspaces/{}/builds/{}/test_sessions/{}/close".format(
self.base_url,
self.org_name,
self.workspace_name,
self.build_number,
self.test_session_id
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, How about change to use fixed test_session_id (buils//test_sessions/ format) in uploading test case results and closing test session?
Because I think we should gather a logic that building test session id in one place.

Copy link
Contributor

Choose a reason for hiding this comment

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

That could work, but then the name self.test_session_id looks strange to me since it is not. I don't want to step into how to implement it but If I were you, I would create a new small class like TestSessionContext and store build id and test session id to its instance. Then we can call getTestSessionId or getBuildPath to extract the necessary information.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I'm also wondering why those unite tests did not fail...

mock_requests.patch.assert_called_once_with(expected_url, headers=expected_headers)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think set test_session_id directly so this test didn't fail

client.build_number = "test_build_number"
client.test_session_id = "1"

@Konboi
Copy link
Collaborator Author

Konboi commented Aug 24, 2021

@shuheiktgw I changed that introduced TestSessionContext and use it. Could you review again?

self.base_url,
self.org_name,
self.workspace_name,
self.build_number,
self.test_session_id
self.test_session_context.get_build_path(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, I haven't noticed we could remove self.build_number but this makes sense!

@Konboi Konboi force-pushed the fix-align-test-session-id-format branch from 1f587c1 to 3ed2c55 Compare August 24, 2021 06:21
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@shuheiktgw shuheiktgw left a comment

Choose a reason for hiding this comment

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

LGTM👍 Thank you!

@Konboi Konboi merged commit 3a2c2a7 into main Aug 24, 2021
@Konboi Konboi deleted the fix-align-test-session-id-format branch August 24, 2021 07:44
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