You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+69-36Lines changed: 69 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,45 +54,78 @@ An essential part of getting your change through is to make sure all existing te
54
54
* Make sure you are at the directory where pom.xml is located.
55
55
56
56
##### Unit Tests
57
-
* Run the following:
58
-
59
-
```
60
-
mvn test
61
-
```
57
+
* Run the following:
58
+
```
59
+
mvn test
60
+
```
62
61
63
62
##### Integration Tests
64
-
* By default, the integration tests are not executed. In case you are interested in executing
65
-
them, disable the `skipITs` property.
66
-
* The following environment variables are required to run the integration tests. 5, 6, and 7 are
67
-
only required when running a windows integration test.
68
-
69
-
1. GOOGLE_PROJECT_ID
70
-
1. GOOGLE_CREDENTIALS
71
-
1. GOOGLE_REGION
72
-
1. GOOGLE_ZONE
73
-
1. GOOGLE_BOOT_DISK_PROJECT_ID
74
-
1. GOOGLE_BOOT_DISK_IMAGE_NAME
75
-
1. GOOGLE_JENKINS_PASSWORD
76
-
1. GOOGLE_SA_NAME
77
-
78
-
* Run the following:
79
-
```
80
-
mvn verify -DskipITs=false
81
-
```
63
+
64
+
Integration tests provision actual instances in a GCP project, run pipeline, take snapshot etc.
65
+
Therefore, they are disabled in the CI and expected to be executed by contributors in their laptop itself.
66
+
67
+
Reasons for disabling integration test in CI,
68
+
* getting provisioning GCP infra is not possible
69
+
* even if we did get a GCP infra setup in the CI, it is risky to expose that, as someone can abuse the CI.
70
+
71
+
By default, integration tests are skipped from the maven goals, need to enable using the `skipITs` property.
72
+
73
+
Steps to execute integration test
74
+
* Prepare VM images
75
+
(ideally we should automate this see idea [here](https://github.com/jenkinsci/google-compute-engine-plugin/pull/492#discussion_r1892705637))
76
+
The jenkins agent images need to have java installed. We have a packer script to create the image and upload to your configured GCP project.
77
+
The scripts are located in [testimages/linux](./testimages/linux)
78
+
Navigate to the directory and execute,
79
+
```bash
80
+
bash setup-gce-image.sh
81
+
```
82
+
* The above agent image contains the `java` command available on the PATH; which the plugin uses by default for launching the agent.
83
+
This plugin also supports configuring custom path for java executable, and we have an integration test for that `ComputeEngineCloudNonStandardJavaIT`.
84
+
If you would like to execute this test, please create an image with `java` command not being on the PATH, but at a custom path `/usr/bin/non-standard-java`.
85
+
To create a non-standard java image, execute,
86
+
```bash
87
+
bash setup-gce-image.sh non-standard-java
88
+
```
89
+
If you want to delete the images or recreate them, use the arguments `--recreate` or `--delete`.
90
+
91
+
* Create a service account with relevant access - See [Refer to IAM Credentials](Home.md#iam-credentials)
92
+
93
+
* Export these mandatory environment variable
94
+
```bash
95
+
export GOOGLE_PROJECT_ID=your-project-id
96
+
export GOOGLE_CREDENTIALS=/path/to/sa-key.json
97
+
export GOOGLE_REGION=us-central1
98
+
export GOOGLE_ZONE=us-central1-a
99
+
export GOOGLE_SA_NAME=jenkins-agent-sa
100
+
```
101
+
* Run the integration tests as,
102
+
* Run all the tests
103
+
```bash
104
+
mvn verify -DskipITs=false
105
+
```
106
+
* Run a specific test class
107
+
```bash
108
+
mvn clean test -Dtest=ComputeEngineCloudRestartPreemptedIT
109
+
```
110
+
* Run a specific test method
111
+
```bash
112
+
mvn clean test -Dtest=ComputeEngineCloudRestartPreemptedIT#testIfNodeWasPreempted
113
+
```
114
+
You can also debug the tests with surefire by passing `-Dmaven.surefire.debug=true` and in your IDE connect to remote debug port `8000`.
82
115
83
116
###### Windows Integration Test
84
117
* By default, the integration tests only use linux based agents for testing. If you make a
85
118
windows-related change, or otherwise want to test that a change still works for windows agents,
86
-
run the tests with the flag `-Dit.windows=true` like this:
87
-
```bash
88
-
mvn verify -Dit.windows=true
89
-
```
90
-
91
-
Make sure you have these extra environment variables configured:
92
-
* GOOGLE_BOOT_DISK_PROJECT_ID will be the same as your project id.
93
-
*GOOGLE_BOOT_DISK_IMAGE_NAME will be the name of the image you created using packer in Google
94
-
cloud console.
95
-
* GOOGLE_JENKINS_PASSWORD will be the password you set when creating the image with packer, used
96
-
for password based ssh authentication.
97
-
* More information on building your baseline windows image can be found [here](WINDOWS.md)
98
-
and an example powershell script for setup can be found [here](windows-it-install.ps1).
119
+
run the tests with the flag `-Dit.windows=true` like this:
120
+
```bash
121
+
mvn verify -Dit.windows=true
122
+
```
123
+
* You need to prepare the windows image before running the tests.
124
+
* More information on building your baseline windows image can be found [here](WINDOWS.md)
125
+
and an example powershell script for setup can be found [here](windows-it-install.ps1).
126
+
*In addition to the environment variables mentioned inthe previous section, also export these variables too,
127
+
```bash
128
+
export GOOGLE_BOOT_DISK_PROJECT_ID=your-project-id # will be the same as your project id
129
+
export GOOGLE_BOOT_DISK_IMAGE_NAME=windows-image-name # will be the name of the image you created using packer in Google cloud console
130
+
export GOOGLE_JENKINS_PASSWORD=password # will be the password you set when creating the image with packer, used for password based ssh authentication.
Copy file name to clipboardExpand all lines: src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloud1WorkerCreatedFor2ExecutorsIT.java
0 commit comments