-
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
Make most ITs work with both linux and windows #143
Conversation
@@ -63,6 +65,7 @@ | |||
|
|||
@BeforeClass | |||
public static void init() throws Exception { | |||
Assume.assumeFalse(windows); |
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.
Currently, the premise of the ComputeEngineCloudWorkerFailedIT is that worker creation fails because there is no startup script which means Java is not installed on the agent. However, the way that Windows agents are created for integration tests right now means that java comes pre-installed on the image.
Unlike assertFalse, which leads to a failure, assumeFalse will skip tests. We can use this to skip tests it doesn't make sense to run with windows agents like this.
LGTM. |
Forgoing clicking the approve button, as I assume you'll want to merge a later PR in a finished state. |
Still having issues with the tests themselves. This will include changes to the documentation when those are working. |
…and number of concurrent tests.
641fbe1
to
31a07f2
Compare
jenkins/Jenkinsfile
Outdated
* limitations under the License. | ||
*/ | ||
|
||
// Windows Agent IT pipeline, run manually. |
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.
Having two files named "Jenkinsfile" could be confusing. Perhaps we can have Jenkinsfile.windows and Jenkinsfile.linux, both in the top level directory. The CI configuration allows you to specify the filename, so we're not limited to the "Jenkinsfile" naming convention.
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.
Done
import lombok.Getter; | ||
|
||
@Getter | ||
public enum Commands { |
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.
Missing javadoc header.
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.
Done
@@ -122,7 +119,6 @@ public void testMultipleLabelsProvisionedWithLabels() throws Exception { | |||
private void checkOneNode(PlannedNode plannedNode, String desc) | |||
throws InterruptedException, java.util.concurrent.ExecutionException { | |||
String name = plannedNode.displayName; | |||
plannedNode.future.get(); |
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.
What's the reasoning for removing this part?
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.
The thing that we care about most in this test is whether both configurations were used, which can be tested without waiting for the instances to fully launch by looking at the configuration of each planned node. This also speeds up this test, especially in the windows case.
import org.junit.rules.Timeout; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class ConfigAsCodeNonStandardJavaIT { |
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.
Missing javadoc header.
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.
Done
// Wait for the node creation to finish | ||
planned.iterator().next().future.get(); | ||
Instance instance = client.getInstance(PROJECT_ID, ZONE, name); | ||
assertNotNull(instance); |
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.
Do we think there's value in attempting to run a command to ensure Java is properly installed? Perhaps "java version", and making sure it doesn't error.
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.
This is tested for in the launch process, which will only complete if it's able to use java to start the agent process. This test shouldn't progress beyond line 80 until that finishes. Maybe it would make sense to have a build step here, which would confirm that the agent jar was used and java is properly installed.
static final String SSH_PRIVATE_KEY = SSH_KEY.getPrivateKey(); | ||
private static final String WINDOWS_STARTUP_SCRIPT = |
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.
Would it make sense to de-dup these startup scripts with their counterparts in the launchers? Same question with the SSH setup logic here.
… properly installed. Adjust timing for RestartPreemptedIT
…single connection instead of trying to connect twice.
public enum Commands { | ||
ECHO("echo %s", "echo %s"), | ||
EXIT("exit /b %s", "exit %s"), | ||
SLEEP("ping /n %s /l 1024 google.com ", "sleep %s"); |
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.
Yes, this is a little weird. I was not able to get the proper windows equivalent "timeout" to work. Looking around I found that there are some weird issues with running the command in non-interactive scripts, discussed in places such as this comment.
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.
Makes sense. Is using Powershell a viable alternative to batch? If so, we could consider using -NonInteractive: https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/About/about_PowerShell_exe?view=powershell-5.1#-noninteractive
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.
Thanks for the tip, while I had trouble using powershell within the existing batch scripts, this led me to finding the Powershell plugin which automatically applies the NonInteractive flag when running scripts, and I was able to remove this hack.
@@ -58,7 +58,18 @@ | |||
*/ | |||
@Override | |||
public Boolean call() throws IOException { | |||
HttpRequest request = createMetadataRequest(); | |||
HttpRequest initialRequest = createMetadataRequest(false); |
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.
This came up in #148 as well. Having the preemption event occur before the agent is running and listening for preemption events is rare, but given that it can and does happen it makes sense to check that it's not already preempted before beginning the long poll to wait for a change to the metadata (which won't happen in that case).
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.
Makes sense.
} | ||
} finally { | ||
} catch (Exception e) { |
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
@@ -87,8 +78,7 @@ private boolean authenticateSSH( | |||
return isAuthenticated; | |||
} | |||
|
|||
private boolean bootstrap(ComputeEngineComputer computer, TaskListener listener) | |||
throws IOException, Exception { // TODO(evanbrown): better exceptions | |||
private Optional<Connection> bootstrap(ComputeEngineComputer computer, TaskListener listener) { | |||
if (computer == null) { |
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.
Preconditions.checkNotNull()
} | ||
} finally { | ||
} catch (Exception e) { |
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.
Same comment as above re: swallowing exceptions.
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
…, use powershell to use sleep command. Update documentation for running windows ITs. Remove obsolete windows IT files.
6a3d605
to
7f0dc57
Compare
…rations test more reliable.
Wanted to verify these deletes were intentional:
|
Yes, those are no longer needed. |
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.
LGTM
This is a proof of concept, see CONTRIBUTING.md for information on the integration tests. I'll be updating the documentation there as well.
Once you have a disk image created for windows, and the corresponding environment variables, you will be able to run
mvn -Dit.windows=true verify
and run the tests using windows agents. This should increase test coverage and get rid of the need to have separate duplicated tests.When running simply
mvn verify
the test behavior is unchanged from before this change.There are still issues with this PR when it comes to running the windows tests, but I wanted to get this out for early feedback.