-
Notifications
You must be signed in to change notification settings - Fork 90
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
Make most ITs work with both linux and windows #143
Merged
stephenashank
merged 16 commits into
jenkinsci:master
from
stephenashank:feature/issue49windows
Oct 17, 2019
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e0860ed
Make most ITs work with both linux and windows
43ae720
Rename misspelled file.
a608c41
Use generic commands which can vary based on the platform.
60b2464
Split ConfigAsCodeTest into two different tests.
7aaa488
Adjusting timing through Awaitility and nodefuture.get().
df8e355
Create independent profile for windows ITs, with different run order …
5423f9d
Consolidate SSH keys and users.
31a07f2
Add pipeline script for running windows ITs.
98069b1
Loosen tolerance for SnapshotCreated test. Fix ConfigAsCodeIT zone/re…
7149c5c
Use service account email for windows config as code it.
5fbf016
PR feedback: Add class header javadoc, add build step to confirm java…
70e6a1f
PR Feedback: Change Jenkinsfile names. Adjust profile and timeouts.
6bb42b9
Fixes for bugs uncovered by test unreliability. In particular, use a …
fee03f9
Cleanup
7f0dc57
PR Feedback: Don't swallow exceptions, use Preconditions.checkNotNull…
5bcb4fc
Fix exit command for powershell scripts. Make MultipleMatchingConfigu…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Windows Agent IT pipeline, run manually. | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
cloud 'kubernetes' | ||
label 'maven-pod' | ||
yamlFile 'jenkins/maven-pod.yaml' | ||
} | ||
} | ||
|
||
environment { | ||
GOOGLE_PROJECT_ID = "${GCE_IT_PROJECT_ID}" | ||
GOOGLE_REGION = "${GCE_IT_REGION}" | ||
GOOGLE_ZONE = "${GCE_IT_ZONE}" | ||
GOOGLE_SA_NAME = "${GCE_IT_SA}" | ||
GOOGLE_BOOT_DISK_PROJECT_ID = "${GCE_WINDOWS_IT_IMAGE_PROJECT}" | ||
GOOGLE_BOOT_DISK_IMAGE_NAME = "${GCE_WINDOWS_IT_IMAGE_NAME}" | ||
BUILD_ARTIFACTS_BUCKET = "${GCE_IT_BUCKET}" | ||
CLEAN_BRANCH_NAME = "${BRANCH_NAME}".replaceAll("[/&;<>|\\]]", "_") | ||
BUILD_ARTIFACTS = "windows-${CLEAN_BRANCH_NAME}-${BUILD_ID}.tar.gz" | ||
} | ||
|
||
stages { | ||
stage("Build and test") { | ||
steps { | ||
container('maven') { | ||
withCredentials([[$class: 'StringBinding', credentialsId: env.GCE_IT_CRED_ID, variable: 'GOOGLE_CREDENTIALS'], | ||
[$class: 'StringBinding', credentialsId: env.GCE_WINDOWS_IT_JENKINS_PASSWORD, variable: 'GOOGLE_JENKINS_PASSWORD']]) { | ||
catchError { | ||
// build | ||
sh "mvn clean package -ntp" | ||
|
||
// run tests | ||
sh "mvn verify -ntp -Dit.windows=true" | ||
} | ||
|
||
sh "jenkins/saveAndCompress.sh" | ||
step([$class: 'ClassicUploadStep', credentialsId: env.GCE_BUCKET_CRED_ID, bucket: "gs://${BUILD_ARTIFACTS_BUCKET}", pattern: env.BUILD_ARTIFACTS]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator; | ||
import com.google.api.services.compute.model.Operation; | ||
import com.google.common.base.Preconditions; | ||
import com.trilead.ssh2.Connection; | ||
import hudson.model.TaskListener; | ||
import java.io.IOException; | ||
|
@@ -51,21 +52,12 @@ protected Optional<Connection> setupConnection( | |
logWarning(computer, listener, "Non-windows node provided"); | ||
return Optional.empty(); | ||
} | ||
boolean isBootstrapped = bootstrap(computer, listener); | ||
if (!isBootstrapped) { | ||
Optional<Connection> bootstrapConn = bootstrap(computer, listener); | ||
if (!bootstrapConn.isPresent()) { | ||
logWarning(computer, listener, "bootstrapresult failed"); | ||
return Optional.empty(); | ||
} | ||
|
||
// connect fresh as ROOT | ||
logInfo(computer, listener, "connect fresh as root"); | ||
Connection cleanupConn = connectToSsh(computer, listener); | ||
if (!authenticateSSH(node.getSshUser(), node.getWindowsConfig(), cleanupConn, listener)) { | ||
logWarning(computer, listener, "Authentication failed"); | ||
return Optional.empty(); // failed to connect | ||
} | ||
|
||
return Optional.of(cleanupConn); | ||
return bootstrapConn; | ||
} | ||
|
||
private boolean authenticateSSH( | ||
|
@@ -87,11 +79,8 @@ private boolean authenticateSSH( | |
return isAuthenticated; | ||
} | ||
|
||
private boolean bootstrap(ComputeEngineComputer computer, TaskListener listener) | ||
throws IOException, Exception { // TODO(evanbrown): better exceptions | ||
if (computer == null) { | ||
throw new IllegalArgumentException("A null ComputeEngineComputer was provided"); | ||
} | ||
private Optional<Connection> bootstrap(ComputeEngineComputer computer, TaskListener listener) { | ||
Preconditions.checkNotNull(computer, "A null ComputeEngineComputer was provided"); | ||
logInfo(computer, listener, "bootstrap"); | ||
|
||
ComputeEngineInstance node = computer.getNode(); | ||
|
@@ -125,14 +114,16 @@ private boolean bootstrap(ComputeEngineComputer computer, TaskListener listener) | |
} | ||
if (!isAuthenticated) { | ||
logWarning(computer, listener, "Authentication failed"); | ||
return false; | ||
return Optional.empty(); | ||
} | ||
} finally { | ||
} catch (Exception e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above re: swallowing exceptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added logging |
||
logException(computer, listener, "Failed to authenticate with exception: ", e); | ||
if (bootstrapConn != null) { | ||
bootstrapConn.close(); | ||
} | ||
return Optional.empty(); | ||
} | ||
return true; | ||
return Optional.ofNullable(bootstrapConn); | ||
} | ||
|
||
@Override | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I'm weary of swallowing exceptions like this. I think at the very least we should consider logging it as a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added logging