Skip to content
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

System property to override default Slave Connect Timeout in seconds #432

Merged

Conversation

v1v
Copy link
Member

@v1v v1v commented Feb 18, 2019

Enable -Dorg.csanchez.jenkins.plugins.kubernetes.PodTemplate.connectionTimeout=XYZ property to override the agent connect timeout which it's 100 seconds by default.

Highlights

  • Override default Slave Connect Timeout using a system property
  • As agreed no ITs are in place for this particular change


assertNotNull(timeoutTemplate);
assertEquals(10, timeoutTemplate.getSlaveConnectTimeout());
r.assertLogNotContains("Hello from container!", b);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be a race condition, couldn't it?


@Test
public void runInPodValidateOverrideSlaveConnectTimeout() throws Exception {
System.setProperty(org.csanchez.jenkins.plugins.kubernetes.PodTemplate.class.getName()+".connectionTimeout", "10");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to clear the property after the test or it will affect other tests

you could just do this test as part of another test to avoid increasing the test time during build

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I'm iterating a few times as I was not aware of the ITs setup :(

@@ -76,6 +76,9 @@ public static void isKubernetesConfigured() throws Exception {
assumeKubernetes();
}

@BeforeClass
protected void overrideSystemProperties() { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is not needed

@Override
@BeforeClass
protected void overrideSystemProperties() {
System.setProperty(PodTemplate.class.getName()+".connectionTimeout", "10");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need a separate class, you can just add to your test the System.setProperty and add to the class

@After
public void cleanup() {
    System.clearProperty(PodTemplate.class.getName()+".connectionTimeout");
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha! That's even better. So I'll proceed with your approach

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to iterate a few more times as it seems some issues with the context of the system.properties outside of the @Before and @BeforeClass annotations

@carlossg carlossg merged commit ac2b4d4 into jenkinsci:master Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants