Skip to content

Commit

Permalink
Merge pull request #1451 from jglick/DirectConnectionTest
Browse files Browse the repository at this point in the history
Added `DirectConnectionTest`, downgrading agent image
  • Loading branch information
jglick authored Oct 23, 2023
2 parents 814017a + db06913 commit fd5b84d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM jenkins/inbound-agent:3180.v3dd999d24861-1
FROM jenkins/inbound-agent:3174.v2c9e67f8f9df-1
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ private void validateJnlpContainer(Container jnlp, KubernetesSlave slave, boolea
assertThat(jnlp.getArgs(), empty());
if(directConnection) {
envVars.add(new EnvVar("JENKINS_PROTOCOLS", JENKINS_PROTOCOLS, null));
envVars.add(new EnvVar("JENKINS_DIRECT_CONNECTION", "localhost:" + Jenkins.get().getTcpSlaveAgentListener().getAdvertisedPort(), null));
envVars.add(new EnvVar("JENKINS_DIRECT_CONNECTION",
System.getProperty("hudson.TcpSlaveAgentListener.hostName", "localhost") + ":" +
Jenkins.get().getTcpSlaveAgentListener().getAdvertisedPort(), null));
envVars.add(new EnvVar("JENKINS_INSTANCE_IDENTITY", Jenkins.get().getTcpSlaveAgentListener().getIdentityPublicKey(), null));
} else {
envVars.add(new EnvVar("JENKINS_URL", JENKINS_URL, null));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2023 CloudBees, 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.
*/

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

import java.util.logging.Level;
import org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil;
import org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder;
import org.junit.Before;
import org.junit.Test;

public final class DirectConnectionTest extends AbstractKubernetesPipelineTest {

@Before
public void setUp() throws Exception {
KubernetesTestUtil.deletePods(cloud.connect(), KubernetesTestUtil.getLabels(cloud, this, name), false);
cloud.setDirectConnection(true);
logs.record(PodTemplateBuilder.class, Level.FINEST);
}

@Test
public void directConnectionAgent() throws Exception {
r.assertBuildStatusSuccess(r.waitForCompletion(createJobThenScheduleRun()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
podTemplate {
node(POD_LABEL) {
sh 'echo OK running'
}
}
2 changes: 2 additions & 0 deletions test-in-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ kubectl exec jenkins -- \
-Dport=$http_port \
-DslaveAgentPort=$tcp_port \
-Djenkins.host.address=jenkins.kubernetes-plugin-test.svc.cluster.local \
`# TODO perhaps PodTemplateBuilder should default host from KubernetesCloud.jenkinsUrl when this is unset? ` \
-Dhudson.TcpSlaveAgentListener.hostName=jenkins.kubernetes-plugin-test.svc.cluster.local \
-Dmaven.test.failure.ignore \
verify \
"$@"
Expand Down

0 comments on commit fd5b84d

Please sign in to comment.