Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

tests: update tests to use LRO #587

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

georgiyekkert
Copy link
Contributor

@georgiyekkert georgiyekkert commented Dec 6, 2021

Update tests to use LRO.
Also manually checked LRO cancel()

@georgiyekkert georgiyekkert requested a review from a team as a code owner December 6, 2021 20:26
@product-auto-label product-auto-label bot added the api: compute Issues related to the googleapis/java-compute API. label Dec 6, 2021
Copy link
Contributor

@vam-google vam-google left a comment

Choose a reason for hiding this comment

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

LGTM with few minor comments.
As for failing tests, I think is ok - this PR merges into a branch, not into a master. And the branch it tires to merge is broken already (this is kind of the point of this PR - to fix as much as possible that broken branch)

@@ -58,7 +56,7 @@ public void setUpMethod() {
@AfterClass
public static void tearDown() {
for (Address address : addresses) {
addressesClient.delete(DEFAULT_PROJECT, DEFAULT_REGION, address.getName());
addressesClient.deleteAsync(DEFAULT_PROJECT, DEFAULT_REGION, address.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is better wait for completion. Even though technically, we may quit and let the operation do its job on the server side, but waiting and potentially reporting deletion error seems cleaner and more robust.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

e.printStackTrace();
} catch (TimeoutException e) {; // expected
}
future.cancel(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this by any chance testing operation cancellation functionality as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it doesn't, I tested it manually. e2e test for this seems a little bit more complicated, had no time to work on that.

@@ -65,7 +73,16 @@ public static void tearDown() {

@Test
public void testHeaders() {
addressesClient.insert("test", "test", Address.newBuilder().setName("test").build());
OperationFuture<Operation, Operation> future =
addressesClient.insertAsync("test", "test", Address.newBuilder().setName("test").build());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please give params more descriptive values than "test" and "test", this is a good practice even if the values do not really matter for the test itself (increases the test code readability and is easy to do).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

fail("Did not catch the exception");
} catch (InvalidArgumentException ex) {
String message = "Bad Request";
} catch (ExecutionException ex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ExecutionException is caught here, but is also declared in throws block above. Do you really need both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't, removed from declaration

@vam-google vam-google merged commit f3ef144 into googleapis:owlbot-migration Dec 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: compute Issues related to the googleapis/java-compute API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants