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

Fix Flaky DLP tests #2447

Merged
merged 4 commits into from
Mar 20, 2020

Conversation

shubha-rajan
Copy link
Contributor

Fixes: #2302, #2303, #2317

The tests keep timing out, so I followed the pattern implemented in the corresponding python samples to create a job and immediately cancel it.

@shubha-rajan shubha-rajan requested a review from a team March 19, 2020 21:02
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 19, 2020
Copy link
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

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

PTAL - I suspect you'll need a tiny delay before canceling the job, but I could very much be wrong.
LGTM - if I am wrong.

Comment on lines +112 to +114
try (DlpServiceClient client = DlpServiceClient.create()) {
client.cancelDlpJob(request);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine if it works, but I'd bet these things can't happen right after the other. (some hysteresis).
(and it would be a flaky test again)

Comment on lines +127 to +130
CancelDlpJobRequest request = CancelDlpJobRequest.newBuilder().setName(jobId).build();
try (DlpServiceClient client = DlpServiceClient.create()) {
client.cancelDlpJob(request);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine if it works, but I'd bet these things can't happen right after the other. (some hysteresis).
(and it would be a flaky test again)

Comment on lines +142 to +146
String jobId = output.split("Job created: ")[1].split("\n")[0];
CancelDlpJobRequest request = CancelDlpJobRequest.newBuilder().setName(jobId).build();
try (DlpServiceClient client = DlpServiceClient.create()) {
client.cancelDlpJob(request);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine if it works, but I'd bet these things can't happen right after the other. (some hysteresis).
(and it would be a flaky test again)

@shubha-rajan
Copy link
Contributor Author

@lesv I think you're right about the delay. It might create a race condition, so that it fails at the assertion before the job is created. I added a 3s delay before the assertion and cancelling, but I'm not sure if that's enough. What do you think? I feel like timing always introduces a bit of flakiness to tests.

@lesv
Copy link
Contributor

lesv commented Mar 20, 2020

You aren't testing canceling, so delay / cancel @ 1s, 4s, & 10s- if it still fails, ignore it. Comment that we don't really care about canceling, and we are only doing it to conserve quota.

@shubha-rajan shubha-rajan merged commit 5275013 into GoogleCloudPlatform:master Mar 20, 2020
olavloite pushed a commit to olavloite/java-docs-samples that referenced this pull request Mar 22, 2020
* modified tests to cancel job

* added delay to tests

* added comment
Sita04 pushed a commit that referenced this pull request Feb 7, 2023
* modified tests to cancel job

* added delay to tests

* added comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
4 participants