Skip to content

Commit e19924c

Browse files
authored
Merge pull request #2848 from jglick/ltsc2022
Update Windows tests from LTSC 2019 to LTSC 2022
2 parents 7338d28 + 52dadd8 commit e19924c

14 files changed

Lines changed: 45 additions & 39 deletions

File tree

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ public void onClose(int i, String s) {
623623
if (!launcher.isUnix() && toggleOutputForCaller != null) {
624624
// Windows welcome message should not be sent to the caller as it is a side-effect of calling
625625
// the wrapping cmd.exe
626-
// Microsoft Windows [Version 10.0.17763.2686]
627-
// (c) 2018 Microsoft Corporation. All rights reserved.
626+
// Microsoft Windows [Version 10.0.20348.4893]
627+
// (c) Microsoft Corporation. All rights reserved.
628628
//
629629
// C:\>
630630
stream.flush();

src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-directConnection.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<p>
1414
<b>Note:</b> In <i>Direct Connection</i> mode agents will not be able to reconnect to a restarted controller if a <i>Random</i> 'TCP port for inbound agents' is configured!<br/>
15-
<b>Note:</b> <i>Direct Connection</i> does not work with the currently available <code>jenkins/inbound-agent:windowsservercore-1809</code> image.
15+
<b>Note:</b> <i>Direct Connection</i> does not work with the currently available <code>jenkins/inbound-agent:windowsservercore-ltsc2022</code> image.
1616
</p>
1717

1818
</div>

src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/samples/windows.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ kind: Pod
88
spec:
99
containers:
1010
- name: jnlp
11-
image: jenkins/inbound-agent:windowsservercore-1809
11+
image: jenkins/inbound-agent:windowsservercore-ltsc2022
1212
- name: shell
13-
image: mcr.microsoft.com/powershell:preview-windowsservercore-1809
13+
image: mcr.microsoft.com/powershell:preview-windowsservercore-ltsc2022
1414
command:
1515
- powershell
1616
args:
1717
- Start-Sleep
1818
- 999999
1919
nodeSelector:
2020
kubernetes.io/os: windows
21+
node.kubernetes.io/windows-build: 10.0.20348
2122
''') {
2223
retry(count: 2, conditions: [kubernetesAgent(), nonresumable()]) {
2324
node(POD_LABEL) {

src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesTestUtil.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import static org.junit.jupiter.api.Assertions.assertTrue;
3131
import static org.junit.jupiter.api.Assumptions.assumeTrue;
3232

33-
import edu.umd.cs.findbugs.annotations.CheckForNull;
3433
import hudson.Util;
3534
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
3635
import io.fabric8.kubernetes.api.model.Node;
@@ -77,7 +76,7 @@ public class KubernetesTestUtil {
7776
public static final String CONTAINER_ENV_VAR_FROM_SECRET_VALUE = "container-pa55w0rd";
7877
public static final String POD_ENV_VAR_FROM_SECRET_VALUE = "pod-pa55w0rd";
7978

80-
public static final String WINDOWS_1809_BUILD = "10.0.17763";
79+
public static final String WINDOWS_LTSC_2022_BUILD = "10.0.20348";
8180

8281
public static KubernetesCloud setupCloud(Object test, String name) throws Exception {
8382
KubernetesCloud cloud = new KubernetesCloud("kubernetes");
@@ -155,18 +154,16 @@ public static void assumeWindows(String buildNumber) {
155154
assumeTrue(isWindows(buildNumber), "Cluster seems to contain no Windows nodes with build " + buildNumber);
156155
}
157156

158-
public static boolean isWindows(@CheckForNull String buildNumber) {
157+
public static boolean isWindows(String buildNumber) {
159158
try (KubernetesClient client = new KubernetesClientBuilder().build()) {
160159
for (Node n : client.nodes().list().getItems()) {
161160
Map<String, String> labels = n.getMetadata().getLabels();
162161
String os = labels.get("kubernetes.io/os");
163162
String windowsBuild = labels.get("node.kubernetes.io/windows-build");
164163
LOGGER.info(() -> "Found node " + n.getMetadata().getName() + " running OS " + os
165164
+ " with Windows build " + windowsBuild);
166-
if ("windows".equals(os)) {
167-
if (buildNumber == null || buildNumber.equals(windowsBuild)) {
168-
return true;
169-
}
165+
if ("windows".equals(os) && buildNumber.equals(windowsBuild)) {
166+
return true;
170167
}
171168
}
172169
}

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorWindowsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
package org.csanchez.jenkins.plugins.kubernetes.pipeline;
2626

27-
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.WINDOWS_1809_BUILD;
27+
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.WINDOWS_LTSC_2022_BUILD;
2828
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.assumeKubernetes;
2929
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.assumeWindows;
3030
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.deletePods;
@@ -95,7 +95,7 @@ class ContainerExecDecoratorWindowsTest {
9595
@BeforeAll
9696
static void beforeAll() {
9797
assumeKubernetes();
98-
assumeWindows(WINDOWS_1809_BUILD);
98+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
9999
}
100100

101101
@BeforeEach
@@ -106,7 +106,7 @@ void beforeEach(JenkinsRule rule, TestInfo info) throws Exception {
106106
client = cloud.connect();
107107
deletePods(client, getLabels(this, name), false);
108108

109-
String image = "mcr.microsoft.com/windows:" + WINDOWS_1809_BUILD + ".2686";
109+
String image = "mcr.microsoft.com/powershell:preview-windowsservercore-ltsc2022";
110110
String containerName = "container";
111111
String podName = "test-command-execution-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789");
112112
pod = client.pods()
@@ -123,7 +123,7 @@ void beforeEach(JenkinsRule rule, TestInfo info) throws Exception {
123123
.withArgs("Start-Sleep", "2147483")
124124
.build())
125125
.addToNodeSelector("kubernetes.io/os", "windows")
126-
.addToNodeSelector("node.kubernetes.io/windows-build", WINDOWS_1809_BUILD)
126+
.addToNodeSelector("node.kubernetes.io/windows-build", WINDOWS_LTSC_2022_BUILD)
127127
.withTerminationGracePeriodSeconds(0L)
128128
.endSpec()
129129
.build());

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import static org.awaitility.Awaitility.await;
2929
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.CONTAINER_ENV_VAR_FROM_SECRET_VALUE;
3030
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.POD_ENV_VAR_FROM_SECRET_VALUE;
31-
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.WINDOWS_1809_BUILD;
31+
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.WINDOWS_LTSC_2022_BUILD;
3232
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.assumeWindows;
3333
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.deletePods;
3434
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.getLabels;
@@ -99,6 +99,7 @@
9999
import org.jvnet.hudson.test.LogRecorder;
100100
import org.jvnet.hudson.test.MockAuthorizationStrategy;
101101
import org.jvnet.hudson.test.TestExtension;
102+
import org.jvnet.hudson.test.recipes.WithTimeout;
102103

103104
class KubernetesPipelineTest extends AbstractKubernetesPipelineTest {
104105

@@ -715,8 +716,9 @@ void runInDynamicallyCreatedContainer() throws Exception {
715716

716717
@Issue("JENKINS-57256")
717718
@Test
719+
@WithTimeout(value = 900) // in case we need to pull windows docker image
718720
void basicWindows() throws Exception {
719-
assumeWindows(WINDOWS_1809_BUILD);
721+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
720722
cloud.setDirectConnection(false); // not yet supported by
721723
// https://github.com/jenkinsci/docker-inbound-agent/blob/517ccd68fd1ce420e7526ca6a40320c9a47a2c18/jenkins-agent.ps1
722724
r.assertBuildStatusSuccess(r.waitForCompletion(b));
@@ -726,8 +728,9 @@ void basicWindows() throws Exception {
726728

727729
@Issue("JENKINS-53500")
728730
@Test
731+
@WithTimeout(value = 900) // in case we need to pull windows docker image
729732
void windowsContainer() throws Exception {
730-
assumeWindows(WINDOWS_1809_BUILD);
733+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
731734
cloud.setDirectConnection(false);
732735
r.assertBuildStatusSuccess(r.waitForCompletion(b));
733736
r.assertLogContains("Directory of C:\\home\\jenkins\\agent\\workspace\\windows Container\\subdir", b);
@@ -739,7 +742,7 @@ void windowsContainer() throws Exception {
739742
"Does not appear fixable: https://github.com/jenkinsci/kubernetes-plugin/pull/1724#discussion_r2287512410")
740743
@Test
741744
void interruptedPodWindows() throws Exception {
742-
assumeWindows(WINDOWS_1809_BUILD);
745+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
743746
cloud.setDirectConnection(false);
744747
r.waitForMessage("starting to sleep", b);
745748
b.getExecutor().interrupt();
@@ -749,20 +752,22 @@ void interruptedPodWindows() throws Exception {
749752

750753
@Test
751754
@Issue("JENKINS-75563")
755+
@WithTimeout(value = 900) // in case we need to pull windows docker image
752756
// Before PR#1724 this would fail as windows processes were not killed
753757
// and hence files blocked. The test is a bit unrealistic as I want it
754758
// to be fast and deterministic, but imagine that instead of the ping we execute
755759
// a big checkout that locks some files and prevents next steps to execute
756760
void killsProcessesWindows() throws Exception {
757-
assumeWindows(WINDOWS_1809_BUILD);
761+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
758762
cloud.setDirectConnection(false);
759763
r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
760764
r.assertLogContains("\"It worked!\"", b);
761765
}
762766

763767
@Test
768+
@WithTimeout(value = 900) // in case we need to pull windows docker image
764769
void secretMaskingWindows() throws Exception {
765-
assumeWindows(WINDOWS_1809_BUILD);
770+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
766771
cloud.setDirectConnection(false);
767772
r.assertBuildStatusSuccess(r.waitForCompletion(b));
768773
r.assertLogContains(

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesSamplesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void smokes() throws Exception {
4040
// TODO tried without success to use Parameterized here (need to construct parameters _after_ JenkinsRule
4141
// starts)
4242
for (GroovySample gs : ExtensionList.lookup(GroovySample.class)) {
43-
if (gs.name().equals("kubernetes-windows") && !isWindows(null)) {
43+
if (gs.name().equals("kubernetes-windows") && !isWindows(WINDOWS_LTSC_2022_BUILD)) {
4444
System.err.println("==== Skipping " + gs.title() + " ====");
4545
continue;
4646
}

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/RestartPipelineTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.jvnet.hudson.test.LogRecorder;
6565
import org.jvnet.hudson.test.junit.jupiter.BuildWatcherExtension;
6666
import org.jvnet.hudson.test.junit.jupiter.JenkinsSessionExtension;
67+
import org.jvnet.hudson.test.recipes.WithTimeout;
6768

6869
class RestartPipelineTest {
6970

@@ -216,8 +217,9 @@ void runInPodWithRestartWithLongSleep() throws Throwable {
216217
}
217218

218219
@Test
220+
@WithTimeout(value = 900) // in case we need to pull windows docker image
219221
void windowsRestart() throws Throwable {
220-
assumeWindows(WINDOWS_1809_BUILD);
222+
assumeWindows(WINDOWS_LTSC_2022_BUILD);
221223
AtomicReference<String> projectName = new AtomicReference<>();
222224
story.then(r -> {
223225
configureAgentListener();

src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/basicWindows.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ kind: Pod
44
spec:
55
containers:
66
- name: jnlp
7-
image: jenkins/inbound-agent:windowsservercore-1809
7+
image: jenkins/inbound-agent:windowsservercore-ltsc2022
88
nodeSelector:
99
kubernetes.io/os: windows
10-
node.kubernetes.io/windows-build: 10.0.17763
10+
node.kubernetes.io/windows-build: 10.0.20348
1111
'''
1212
) {
1313
node(POD_LABEL) {

src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/interruptedPodWindows.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ kind: Pod
44
spec:
55
containers:
66
- name: jnlp
7-
image: jenkins/inbound-agent:windowsservercore-1809
7+
image: jenkins/inbound-agent:windowsservercore-ltsc2022
88
- name: shell
9-
image: mcr.microsoft.com/powershell:preview-windowsservercore-1809
9+
image: mcr.microsoft.com/powershell:preview-windowsservercore-ltsc2022
1010
command:
1111
- powershell
1212
args:
1313
- Start-Sleep
1414
- 999999
1515
nodeSelector:
1616
kubernetes.io/os: windows
17-
node.kubernetes.io/windows-build: 10.0.17763
17+
node.kubernetes.io/windows-build: 10.0.20348
1818
''') {
1919
node(POD_LABEL) {
2020
container('shell') {

0 commit comments

Comments
 (0)