From 040c935818d7b721d1a097dd207967019755613f Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 20 May 2023 16:26:08 -0700 Subject: [PATCH] Adapting to jenkinsci/jenkins#6543 --- .../DockerComputerJNLPConnector.java | 4 -- .../DockerComputerJNLPConnectorTest.java | 53 ------------------- 2 files changed, 57 deletions(-) diff --git a/src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java b/src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java index 02cc7edf..b837ca0a 100644 --- a/src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java +++ b/src/main/java/io/jenkins/docker/connector/DockerComputerJNLPConnector.java @@ -195,10 +195,6 @@ public void beforeContainerCreated(DockerAPI api, String workdir, CreateContaine final String[] resolvedArgs = splitAndFilterEmpty(resolvedArgString, "\n"); cmd.withCmd(resolvedArgs); - String vmargs = jnlpLauncher.vmargs; - if (StringUtils.isNotBlank(vmargs)) { - DockerEnvUtils.addEnvToCmd("JAVA_OPT", vmargs.trim(), cmd); - } if (StringUtils.isNotBlank(user)) { cmd.withUser(user); } diff --git a/src/test/java/io/jenkins/docker/connector/DockerComputerJNLPConnectorTest.java b/src/test/java/io/jenkins/docker/connector/DockerComputerJNLPConnectorTest.java index 4347aa4e..afe531cb 100644 --- a/src/test/java/io/jenkins/docker/connector/DockerComputerJNLPConnectorTest.java +++ b/src/test/java/io/jenkins/docker/connector/DockerComputerJNLPConnectorTest.java @@ -1,11 +1,5 @@ package io.jenkins.docker.connector; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.github.dockerjava.api.command.CreateContainerCmd; import com.nirima.jenkins.plugins.docker.DockerTemplate; import com.nirima.jenkins.plugins.docker.DockerTemplateBase; @@ -14,10 +8,7 @@ import org.apache.commons.lang3.SystemUtils; import org.junit.Test; -import java.io.IOException; import java.net.URI; -import java.util.Map; -import java.util.TreeMap; public class DockerComputerJNLPConnectorTest extends DockerComputerConnectorTest { private static final String JNLP_AGENT_IMAGE_IMAGENAME = "jenkins/inbound-agent"; @@ -50,48 +41,4 @@ public void connectAgentViaJNLP() throws Exception { template.setName("connectAgentViaJNLP"); should_connect_agent(template); } - - @Test - public void testKeepingEvnInBeforeContainerCreated() throws IOException, InterruptedException { - // Given - final String env1 = "ENV1=val1"; - final String vmargs = "-Dhttp.proxyPort=8080"; - final DockerComputerJNLPConnector connector = new DockerComputerJNLPConnector(new JNLPLauncher(null, vmargs)); - - final CreateContainerCmd createCmd = mock(CreateContainerCmd.class); - final Map containerLabels = new TreeMap<>(); - when(createCmd.getLabels()).thenReturn(containerLabels); - DockerTemplate.setNodeNameInContainerConfig(createCmd, "nodeName"); - when(createCmd.getEnv()).thenReturn(new String[]{ env1 }); - - // When - connector.beforeContainerCreated(null, null, createCmd); - - // Then - verify(createCmd, times(1)).withEnv(new String[]{ - env1, - "JAVA_OPT=" + vmargs - }); - } - - @Test - public void testAddingVmargsInBeforeContainerCreated() throws IOException, InterruptedException { - // Given - final String vmargs = "-Dhttp.proxyPort=8080"; - final DockerComputerJNLPConnector connector = new DockerComputerJNLPConnector(new JNLPLauncher(null, vmargs)); - - final CreateContainerCmd createCmd = mock(CreateContainerCmd.class); - final Map containerLabels = new TreeMap<>(); - when(createCmd.getLabels()).thenReturn(containerLabels); - DockerTemplate.setNodeNameInContainerConfig(createCmd, "nodeName"); - - // When - connector.beforeContainerCreated(null, null, createCmd); - - // Then - verify(createCmd, times(1)).withEnv(new String[]{ - "JAVA_OPT=" + vmargs - }); - } - }