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

GEODE-6183: Fix isAttachAPIFound and launcher tests #3650

Merged
merged 5 commits into from Jun 13, 2019

Conversation

kirklund
Copy link
Contributor

@kirklund kirklund commented May 30, 2019

Co-authored-by: Michael Oleske moleske@pivotal.io
Co-authored-by: Mark Hanson mhanson@pivotal.io

Fixed StressNewTest job for all launcher tests. These were failing in StressNewTest. I also moved all files to TemporaryFolder.

Additional reviewers: @demery-pivotal @mhansonp @moleske @aaronlindsey

Note: due to the empty commit to trigger precheckin, I will do a rebase and force push after reviews but before the final merge to develop.

@kirklund kirklund force-pushed the GEODE-6183-WindowsAttachProvider branch 2 times, most recently from 22aa84e to 675c816 Compare June 3, 2019 22:31
@kirklund kirklund marked this pull request as ready for review June 4, 2019 16:09
@kirklund kirklund force-pushed the GEODE-6183-WindowsAttachProvider branch from 675c816 to 3d3e547 Compare June 4, 2019 18:36
@kirklund kirklund changed the title DRAFT: GEODE-6183: Fix isAttachAPIFound and launcher tests GEODE-6183: Fix isAttachAPIFound and launcher tests Jun 4, 2019
Copy link
Contributor

@upthewaterspout upthewaterspout left a comment

Choose a reason for hiding this comment

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

I haven't reviewed all of the formatting cleanup, but the actual bug fix looks good. Many thanks for separating out the code cleanup from the actual fix!

This is beyond the scope of this PR, but we really shouldn't be using this Attach API at all. There are way better and more standard ways to interact with a process we've launched.

@kirklund
Copy link
Contributor Author

kirklund commented Jun 5, 2019

@upthewaterspout I think the only feature we're still using in Attach API that isn't available elsewhere is the check isProcessAlive(int pid) for any pid (not a java.lang.Process forked from the current JVM). I'm all for removing it. EDIT: actually NativeCalls (JNA) does have support for it.

Copy link
Member

@moleske moleske left a comment

Choose a reason for hiding this comment

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

Yay code cleanup (and the fix too)! Is there an existing Geode JIRA story for @upthewaterspout 's point about not using this?

@metatype
Copy link
Contributor

metatype commented Jun 5, 2019

Maybe: ProcessHandle.of(pid).ifExists(ProcessHandle::isAlive)

@kirklund
Copy link
Contributor Author

kirklund commented Jun 6, 2019

@moleske @upthewaterspout I filed GEODE-6841: Remove dependency on Attach API

@kirklund
Copy link
Contributor Author

kirklund commented Jun 6, 2019

Maybe: ProcessHandle.of(pid).ifExists(ProcessHandle::isAlive)

@metatype What API is ProcessHandle part of? My IntelliJ project cannot find that class. Also, please update https://issues.apache.org/jira/browse/GEODE-6841 with any info on alternative APIs. Please provide a review as well (we need 3) -- thanks! EDIT: Looks like ProcessHandle isn't added until JDK 9 source level.

@kohlmu-pivotal
Copy link
Contributor

I might be archaic in my thinking or understanding, but I thought there was some guidance that was once provided that inherited Test classes were a smell. If so, I do see quite a few of the test classes use inheritance, which makes this review harder, as I would now have to go back to source code to understand what a specific method would be providing.
In addition, I also see some classes are names "Integration". I thought there was an integration category that was used. Maybe the category was missed or maybe renaming of the Test class to further its classification would be more helpful.
Overall, these changes look good, with only cosmetic and hopefully minor changes

Copy link
Contributor

@bschuchardt bschuchardt left a comment

Choose a reason for hiding this comment

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

The locator integration test changes look fine. There's no diff for the distributed system integration test - can't tell what changed there. As for the original commit/fix it looks okay to me but I'm not familiar with the Attach API

@kirklund
Copy link
Contributor Author

kirklund commented Jun 6, 2019

@kohlmu-pivotal If I have a class called LocatorLauncher, then I create a unit test in src/test called LocatorLauncherTest and an integration test in src/integrationTest called LocatorLauncherIntegrationTest. I use those names simply because I want to. That's what I documented on the Geode wiki in the past and have been using for years.

@kirklund
Copy link
Contributor Author

kirklund commented Jun 6, 2019

@bschuchardt The diff for DistributedSystemIntegrationTest is 4th commit down in the commits tab. Here's a URL to it: e3d8cfb

@kirklund
Copy link
Contributor Author

kirklund commented Jun 6, 2019

@kohlmu-pivotal Re: inherited test classes: These are not new tests that I just recently decided to create with multiple-class inheritance. I simply cleaned them up. I'm not going to rewrite them from scratch, but you certainly can if you really want to.

@kohlmu-pivotal
Copy link
Contributor

@kirklund I thought that we had an @Category("IntegrationTest") that was there.. but I have not created a new test in a while
I also understand that you did just refactor the test. I was merely calling out that I believed that test inheritance was a smell that was agreed upon.
As I also stated, overall the changes look cosmetic and acceptable.

assertEquals(GemFireCacheImpl.getInstance().getMyId(),
alreadyManaging.get(0).getDistributedMember());
} finally {
System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + "enabledManagement");
Copy link
Member

Choose a reason for hiding this comment

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

Is it correct to leave this System variable set after the test completes?

Copy link
Contributor Author

@kirklund kirklund Jun 10, 2019

Choose a reason for hiding this comment

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

@rhoughton-pivot Adding RestoreSystemProperties JUnit Rule restores all System Properties after each test.

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;

Choose a reason for hiding this comment

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

What's the motivation behind using AssertJ instead of JUnit? How do we decide whether to use one vs the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AssertJ is a much richer assertion API that introduced to Geode a few years ago. I highly recommend using it over JUnit assertions!

Copy link
Contributor

@jujoramos jujoramos Jun 10, 2019

Choose a reason for hiding this comment

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

@aaronlindsey: I think the general preference and consensus is to use AssertJ instead of JUnit, it's been discussed some time ago in the Geode dev list: https://markmail.org/message/al3st2gko4hddwo2.

@kirklund
Copy link
Contributor Author

Review is closed. I'm going to do one final rebase on develop, force-push to remove the empty commit (for precheckin trigger). and then merge to develop.

kirklund and others added 5 commits June 13, 2019 10:21
VirtualMachine class can be loaded even if AttachProvider service
providers are not found. This change forces loading of providers
for isAttachAPIFound.

Co-authored-by: Michael Oleske <moleske@pivotal.io>
…tegrationTest

The tests that were using InetAddress.getLostHost for assertions may
fail depending on /etc/hosts configuration. This change should prevent
these failures.

Co-authored-by: Michael Oleske <moleske@pivotal.io>
Co-authored-by: Mark Hanson <mhanson@pivotal.io>
* Fixup IDE warnings
* Reformat test code
* Use SocketCreator.getLocalHost
* Fixup IDE warnings
* Reformat test code
* Fixup IDE warnings
* Reformat test code
* Update to use AssertJ
@kirklund kirklund force-pushed the GEODE-6183-WindowsAttachProvider branch from 40934ab to c566cd7 Compare June 13, 2019 17:21
@kirklund kirklund merged commit 87c83ee into apache:develop Jun 13, 2019
@kirklund kirklund deleted the GEODE-6183-WindowsAttachProvider branch June 13, 2019 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
10 participants