jenkinsci / jenkinsci/google-compute-engine-plugin

How to run the ITs locally?

Open
#189 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
58
Forks
97
PR merge metrics
No merged PRs in 30d

Description

I did follow the steps explained in the CONTRIBUTING.md but I'm afraid I cannot run them as expected

### If I run a specific ITs

```
$ GOOGLE_BOOT_DISK_IMAGE_NAME=debian-10-buster-v20200210 \
GOOGLE_REGION=us-central1 \
GOOGLE_ZONE=us-central1-f \
GOOGLE_BOOT_DISK_PROJECT_ID=debian-cloud \
GOOGLE_PROJECT_ID=my-project \
GOOGLE_CREDENTIALS_FILE=$(pwd)/jenkins-gce.json \
GOOGLE_SA_NAME=jenkins-gce \
mvn verify -DskipITs=false -Dtest=ConfigAsCodeTestIT
```

```
cat jenkins-gce.json
{
"type": "service_account",
"project_id": "my-project",
"private_key_id": "foobar",
"private_key": "-----BEGIN PRIVATE KEY-----\n...==\n-----END PRIVATE KEY-----\n",
"client_email": "jenkins-gce@my-project.iam.gserviceaccount.com",
"client_id": "foobar",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/jenkins-gce%40my-project.iam.gserviceaccount.com"
}

```

And the outcome is something like:

```
[INFO] Running com.google.jenkins.plugins.computeengine.integration.ConfigAsCodeTestIT
=== Starting com.google.jenkins.plugins.computeengine.integration.ConfigAsCodeTestIT
0.078 [id=14] INFO o.jvnet.hudson.test.WarExploder#explode: Picking up existing exploded jenkins.war at /Users/vmartinez/work/src/github.com/v1v/google-compute-engine-plugin/target/jenkins-for-test
0.334 [id=14] INFO o.jvnet.hudson.test.JenkinsRule#createWebServer: Running on http://localhost:60618/jenkins/
1.553 [id=23] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization
1.724 [id=44] WARNING hudson.ClassicPluginStrategy#createClassJarFromWebInfClasses: Created /Users/vmartinez/work/src/github.com/v1v/google-compute-engine-plugin/target/tmp/jenkins9213109901196734064/powershell/WEB-INF/lib/classes.jar; update plugin to a version created with a newer harness
1.867 [id=44] WARNING hudson.ClassicPluginStrategy#createClassJarFromWebInfClasses: Created /Users/vmartinez/work/src/github.com/v1v/google-compute-engine-plugin/target/tmp/jenkins9213109901196734064/oauth-credentials/WEB-INF/lib/classes.jar; update plugin to a version created with a newer harness
2.078 [id=44] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2.092 [id=23] INFO o.j.plugins.TrileadApiPlugin#start: Trilead being provided from file:/Users/vmartinez/.m2/repository/org/jenkins-ci/trilead-ssh2/build-217-jenkins-16/trilead-ssh2-build-217-jenkins-16.jar
3.573 [id=31] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
3.578 [id=31] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins
3.580 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
4.615 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
4.885 [id=24] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
4.961 [id=14] INFO c.g.j.p.c.i.ConfigAsCodeTestIT#init: init
5.105 [id=14] INFO c.g.j.p.c.integration.ITUtil#teardownResources: teardown
5.113 [id=14] INFO jenkins.model.Jenkins#cleanUp: Stopping Jenkins
5.330 [id=14] INFO jenkins.model.Jenkins#cleanUp: Jenkins stopped
[WARNING] ForkStarter IOException: java.lang.NullPointerException. See the dump file /Users/vmartinez/work/src/github.com/v1v/google-compute-engine-plugin/target/surefire-reports/2020-02-27T19-56-55_005-jvmRun1.dumpstream
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
```

### If I run with all the ITs

BTW, if I do run without -Dtest, then I get some other errors
```
$ GOOGLE_BOOT_DISK_IMAGE_NAME=debian-10-buster-v20200210 \
GOOGLE_REGION=us-central1 \
GOOGLE_ZONE=us-central1-f \
GOOGLE_BOOT_DISK_PROJECT_ID=debian-cloud \
GOOGLE_PROJECT_ID=my-project \
GOOGLE_CREDENTIALS_FILE=$(pwd)/jenkins-gce.json \
GOOGLE_SA_NAME=jenkins-gce \
mvn verify -DskipITs=false
```

```
[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) @ google-compute-engine ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.google.jenkins.plugins.computeengine.ComputeEngineCloudTest
[INFO] Running com.google.jenkins.plugins.computeengine.AcceleratorConfigurationTest
[INFO] Running InjectedTest
[INFO] Running com.google.jenkins.plugins.computeengine.InstanceConfigurationTest
[INFO] Running com.google.jenkins.plugins.computeengine.CleanLostNodesWorkTest
[INFO] Running com.google.jenkins.plugins.computeengine.GoogleKeyPairTest
[INFO] Running com.google.jenkins.plugins.computeengine.AutofilledNetworkConfigurationTest
[INFO] Running com.google.jenkins.plugins.computeengine.ConfigAsCodeTest
[INFO] Running com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest
[ERROR] Tests run: 20, Failures: 0, Errors: 20, Skipped: 0, Time elapsed: 0.797 s <<< FAILURE! - in com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest
[ERROR] com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest.construction Time elapsed: 0.015 s <<< ERROR!
java.lang.Error:
Unresolved compilation problems:
The method getNetwork() is undefined for the type SharedVpcNetworkConfiguration
The method getProjectId() is undefined for the type SharedVpcNetworkConfiguration
The method getSubnetwork() is undefined for the type SharedVpcNetworkConfiguration
The method getSubnetworkShortName() is undefined for the type SharedVpcNetworkConfiguration
The method getRegion() is undefined for the type SharedVpcNetworkConfiguration

at com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest.construction(SharedVpcNetworkConfigurationTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)

[ERROR] com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest.descriptorRegion Time elapsed: 0.617 s <<< ERROR!
java.lang.Error:
Unresolved compilation problem:

at com.google.jenkins.plugins.computeengine.ComputeEngineCloud.checkPermissions(ComputeEngineCloud.java:438)
at com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfiguration$DescriptorImpl.doCheckRegion(SharedVpcNetworkConfiguration.java:72)
at com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest.descriptorRegion(SharedVpcNetworkConfigurationTest.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)

[ERROR] com.google.jenkins.plugins.computeengine.SharedVpcNetworkConfigurationTest.descriptorSubnetwork Time elapsed: 0.002 s <<< ERROR!
java.lang.Error:
Unresolved compilation problem:
```

Am I missing anything?

Thanks

Contributor guide

Open the contributing guide

Research direction

Start with CONTRIBUTING.md and reproduce the two Maven commands using the reported environment variables. Inspect SharedVpcNetworkConfigurationTest.java, SharedVpcNetworkConfiguration.java, ComputeEngineCloud.java, and ConfigAsCodeTestIT to trace the compilation and fork errors. Done means the documented setup either runs the named integration test and the full suite or the documentation clearly records the required corrections.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, java
Domain
cloud, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.