Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

Commit 6dd40ba

Browse files
authored
Allow to configure timeout for kubectl as long or int (#315)
## Description Add api for config timeout in ms as long data type ## Type of Change Please delete options that are not relevant. * New feature (non-breaking change which adds functionality) --------- Signed-off-by: David Kornel <kornys@outlook.com>
1 parent b68e914 commit 6dd40ba

6 files changed

Lines changed: 41 additions & 6 deletions

File tree

test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/KubeCmdClient.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ public interface KubeCmdClient<K extends KubeCmdClient<K>> {
4646

4747

4848
/**
49-
* Sets the timeout for subsequent operations.
49+
* Sets the timeout for later operations.
5050
*
51-
* @param timeout timeout for execution of command.
51+
* @param timeout timeout in ms for execution of command.
5252
* @return This kube client.
5353
*/
5454
KubeCmdClient<K> withTimeout(int timeout);
5555

56+
/**
57+
* Sets the timeout for later operations.
58+
*
59+
* @param timeout timeout in ms for execution of command.
60+
* @return This kube client.
61+
*/
62+
KubeCmdClient<K> withTimeout(long timeout);
63+
5664
/**
5765
* Retrieves the currently set namespace for the Kubernetes client.
5866
*

test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/Kubectl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ public Kubectl withTimeout(int timeout) {
5959
return new Kubectl(namespace, config, timeout);
6060
}
6161

62+
/**
63+
* Sets the timeout for subsequent operations.
64+
*
65+
* @param timeout timeout for execution of command.
66+
* @return This kube client.
67+
*/
68+
@Override
69+
public Kubectl withTimeout(long timeout) {
70+
return new Kubectl(namespace, config, (int) timeout);
71+
}
72+
6273
/**
6374
* Gets the current namespace of the Kubectl instance.
6475
*

test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/Oc.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,27 @@ public Oc inNamespace(String namespace) {
6262
}
6363

6464
/**
65-
* Sets the timeout for subsequent operations.
65+
* Sets the timeout for later operations.
6666
*
67-
* @param timeout timeout for execution of command.
67+
* @param timeout timeout in ms for execution of command.
6868
* @return This kube client.
6969
*/
7070
@Override
7171
public Oc withTimeout(int timeout) {
7272
return new Oc(namespace, config, timeout);
7373
}
7474

75+
/**
76+
* Sets the timeout for later operations.
77+
*
78+
* @param timeout timeout in ms for execution of command.
79+
* @return This kube client.
80+
*/
81+
@Override
82+
public Oc withTimeout(long timeout) {
83+
return new Oc(namespace, config, (int) timeout);
84+
}
85+
7586
/**
7687
* Gets the current namespace of the Oc instance.
7788
*

test-frame-common/src/test/java/io/skodjob/testframe/clients/cmdClient/KubectlTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void testGetUsernameConstructsCommandAndReturnsOutput() {
110110
ExecResult mockResult = mockSuccessfulExecResult(expectedUsername);
111111
mockedExec.when(() -> Exec.exec(anyList(), eq(10))).thenReturn(mockResult);
112112

113-
Kubectl client = new Kubectl(CUSTOM_CONFIG).inNamespace(DEFAULT_NAMESPACE).withTimeout(10);
113+
Kubectl client = new Kubectl(CUSTOM_CONFIG).inNamespace(DEFAULT_NAMESPACE).withTimeout(10L);
114114
String actualUsername = client.getUsername();
115115

116116
assertEquals(expectedUsername, actualUsername);

test-frame-common/src/test/java/io/skodjob/testframe/clients/cmdClient/OcTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void testNewAppConstructsCorrectCommand() {
132132
ExecResult mockResult = mockSuccessfulExecResult("Application created");
133133
mockedExec.when(() -> Exec.exec(anyList(), eq(5))).thenReturn(mockResult);
134134

135-
Oc client = new Oc(CUSTOM_CONFIG).inNamespace(DEFAULT_NAMESPACE).withTimeout(5);
135+
Oc client = new Oc(CUSTOM_CONFIG).inNamespace(DEFAULT_NAMESPACE).withTimeout(5L);
136136
client.newApp(templateName, params);
137137

138138
ArgumentCaptor<List<String>> listCaptor = ArgumentCaptor.forClass(List.class);

test-frame-common/src/test/java/io/skodjob/testframe/clients/cmdClient/TestableCmdKubeClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public KubeCmdClient<TestableCmdKubeClient> withTimeout(int timeout) {
3232
return null;
3333
}
3434

35+
@Override
36+
public KubeCmdClient<TestableCmdKubeClient> withTimeout(long timeout) {
37+
return null;
38+
}
39+
3540
@Override
3641
public String getCurrentNamespace() {
3742
return "";

0 commit comments

Comments
 (0)