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

Sense for VirtualBox and $HOME when deciding to turn on vagrant testing. #24636

Merged
merged 10 commits into from
Jun 2, 2017

Conversation

jbaiera
Copy link
Member

@jbaiera jbaiera commented May 11, 2017

Some of the CI boxes for Elasticsearch have inconsistently configured environments when it comes to Vagrant. Vagrant requires $HOME to be set, as well as VirtualBox to be installed. This PR checks those two things are present before enabling tests with VagrantFixtures in the HDFS Repo (only place vagrant fixtures are used right now).

@jbaiera jbaiera added >bug :Delivery/Build Build or test infrastructure >test Issues or PRs that are addressing/adding tests labels May 11, 2017

// Finding that HOME needs to be set when performing vagrant updates
String homeLocation = System.getenv("HOME")
if (homeLocation == null) {
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this leniency? If vagrant fails because HOME is not set, that tails us there is a problem that needs fixing. With the logic here, we will simply not run the test and not know it is broken.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change this to throw an exception instead. If vagrant is installed but the environment can't support calling it, we should probably break earlier in the build with clear reasoning for why.

try {
ByteArrayOutputStream pipe = new ByteArrayOutputStream()
ExecResult runResult = exec {
commandLine 'vboxmanage', '--version'
Copy link
Member

Choose a reason for hiding this comment

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

We really need to share this stuff...VagrantTestPlugin also does this.

Can we do this exactly once (for vagrant and vboxmanage each) and set a property on the project like vagrantSupported? See for example in BuildPlugin how we check the java version etc in globalBuildInfo. This would also allow us to remove the tasks created by VagrantTestPlugin and just check the flag.

dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request May 12, 2017
This keeps failing the build so I am temporarily disabling it
until elastic#24636 gets merged.
dimitris-athanasiou added a commit that referenced this pull request May 12, 2017
This keeps failing the build so I am temporarily disabling it
until #24636 gets merged.
dimitris-athanasiou added a commit that referenced this pull request May 12, 2017
This keeps failing the build so I am temporarily disabling it
until #24636 gets merged.
dimitris-athanasiou added a commit that referenced this pull request May 12, 2017
This keeps failing the build so I am temporarily disabling it
until #24636 gets merged.
@dimitris-athanasiou
Copy link
Contributor

@jbaiera I have merged in #24643 in order to temporarily disable the task that causes build failures. Adding it here to remind you to re-enable once this is ready to go in.

@jbaiera
Copy link
Member Author

jbaiera commented May 12, 2017

I've moved the environment sensing out of the hdfs plugin build script as well as the vagrant test plugin into it's own VagrantSupportPlugin. Both vagrant and virtualbox are checked to see if they are installed. After the plugin is applied, if the root project hasn't been configured by it yet, then it does the environment checks and installs the results (as Installation objects) into the root project. It then transfers the Installation objects into the project applying the plugin. Installation is just a simple object that couples together the results of the checks: If the commands are installed, if the versions are correct, what the version number is if they meet the requirements, and any errors encountered while checking if they were installed. The plugin also creates the tasks to check the version for Vagrant and VirtualBox, so that hdfs repo and the packaging tests don't have to any more. These tasks no longer perform the actual lookup, but rather call the verify() method on the Installation objects, which throws if the Installation is not valid.

@jbaiera
Copy link
Member Author

jbaiera commented May 12, 2017

The VagrantTestPlugin definitely depends on this VagrantSupportPlugin. I'm not aware of any good ways to orchestrate that dependency in the build script. @rjernst any thoughts?

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

I left a few comments.

"and requires \$HOME to be set to function properly.")
}

project.ext.vagrantInstallation = project.rootProject.ext.vagrantInstallation
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to put these on all the projects? I think this plugin can just look for the flags on the root project?

}

private Installation getVagrantInstallation(Project project) {
// Only do secure fixture support if the regular fixture is supported,
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems to be specific to the old location of this check

}

private Installation getVirtualBoxInstallation(Project project) {
// Also check to see if virtualbox is installed. We need both vagrant
Copy link
Member

Choose a reason for hiding this comment

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

This comment also refers to stuff outside this plugin

* is installed, if it is the correct version, which version was found, and any
* errors that were encountered when checking for the installation.
*/
class Installation {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we really need this abstraction...can we just keep it simple and store a boolean property on the root project indicating whether vagrant is installed at the given version, and the same for virtualbox? You can even store this in a map, along with whatever error description you want about getting the version. eg.

rootProject.ext.vagrant = ['supported': false, 'info': 'Unsupported version of vagrant [${version}]. Need [Vagrant 1.8.6+]']
....
if (rootProject.vagrant.supported == false) {
    logger.warn(rootProject.vagrant.info)
} else {
    // use vagrant
}

} else {
logger.warn("Could not read installed vagrant version:\n" + output)
if (project.virtualBoxInstallation.supported == false) {
logger.warn(project.virtualBoxInstallation.error.message)
Copy link
Member

Choose a reason for hiding this comment

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

These messages are becoming noisy, and aren't actually helpful, because they are emitted even when not trying to run this task. I wonder if instead you could check emit this at runtime if the task would have run? You could do this as a doFirst, and throw a StopExecutionException if the task should be skipped.

@jbaiera jbaiera force-pushed the fix-virtualbox-sense branch from de71a9b to 16e668f Compare May 18, 2017 15:33
@jbaiera
Copy link
Member Author

jbaiera commented May 31, 2017

@rjernst How are we on the recent changes for this? I'd like to get this merged soon.

@rjernst
Copy link
Member

rjernst commented May 31, 2017

@jbaiera I had not looked at it since I left my last comments. Please ping me in the future when it is ready for another review. I will look now.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM, left a couple minor comments that can be addressed in followups if desired.


// Finding that HOME needs to be set when performing vagrant updates
String homeLocation = System.getenv("HOME")
if (project.rootProject.ext.vagrantSupported && homeLocation == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Why does this check need to be done for every project using this instead of once inside the installation checks above?


if (secureFixtureSupported) {
integTestSecure.mustRunAfter(project.integTest)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this mustRunAfter will actually do anything. The integTest task is just a dummy task that depends on setting up the integTestCluster and running integTestRunner. When you run gradle check do you see tasks form the secure and regular integTest intermixed?

@jbaiera jbaiera force-pushed the fix-virtualbox-sense branch from 17601aa to 5d1dfc0 Compare June 2, 2017 17:31
@jbaiera jbaiera merged commit 4ed0abe into elastic:master Jun 2, 2017
@jbaiera jbaiera deleted the fix-virtualbox-sense branch June 2, 2017 20:26
dakrone added a commit to dakrone/elasticsearch that referenced this pull request Jun 2, 2017
jbaiera added a commit that referenced this pull request Jun 12, 2017
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 12, 2017
* master:
  Do not swallow node lock failed exception
  Revert "Revert "Sense for VirtualBox and $HOME when deciding to turn on vagrant testing. (elastic#24636)""
  Aggregations bug: Significant_text fails on arrays of text. (elastic#25030)
  Speed up sorted scroll when the index sort matches the search sort (elastic#25138)
  TranslogTests.testWithRandomException ignored a possible simulated OOM when trimming files
  Adapt TranslogTests.testWithRandomException to checkpoint syncing on trim
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 13, 2017
* master:
  Explicitly reject duplicate data paths
  Do not swallow node lock failed exception
  Revert "Revert "Sense for VirtualBox and $HOME when deciding to turn on vagrant testing. (elastic#24636)""
  Aggregations bug: Significant_text fails on arrays of text. (elastic#25030)
  Speed up sorted scroll when the index sort matches the search sort (elastic#25138)
  TranslogTests.testWithRandomException ignored a possible simulated OOM when trimming files
  Adapt TranslogTests.testWithRandomException to checkpoint syncing on trim
  Change BWC versions on get mapping 404s
  Fix get mappings HEAD requests
  TranslogTests#commit didn't allow for a concurrent closing of a view
  Fix handling of exceptions thrown on HEAD requests
  Fix comment formatting in EvilLoggerTests
  Remove unneeded weak reference from prefix logger
  Test: remove faling test that relies on merge order
jbaiera added a commit that referenced this pull request Sep 19, 2017
jbaiera added a commit that referenced this pull request Sep 19, 2017
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team >test Issues or PRs that are addressing/adding tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants