This repository was archived by the owner on Apr 10, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +54
-17
lines changed
main/java/com/csviri/jenvtest/binary
test/java/com/csviri/jenvtest Expand file tree Collapse file tree 3 files changed +54
-17
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public BinaryManager(APIServerConfig config) {
27
27
}
28
28
29
29
public void initAndDownloadIfRequired () {
30
- Optional <File > maybeBinaryDir = findLatestBinariesAvailable ();
30
+ Optional <File > maybeBinaryDir = findTargetBinariesIfAvailable ();
31
31
File binaryDir = maybeBinaryDir .orElse (null );
32
32
33
33
if (maybeBinaryDir .isEmpty ()) {
@@ -63,11 +63,16 @@ public Binaries binaries() {
63
63
return binaries ;
64
64
}
65
65
66
- private Optional <File > findLatestBinariesAvailable () {
66
+ private Optional <File > findTargetBinariesIfAvailable () {
67
67
var platformSuffix = Utils .platformSuffix (osInfoProvider );
68
68
if (config .getApiServerVersion ().isPresent ()) {
69
- return Optional .of (new File (config .getJenvtestDir (), BINARY_LIST_DIR
70
- + File .separator + config .getApiServerVersion () + platformSuffix ));
69
+ var targetVersionDir = new File (config .getJenvtestDir (), BINARY_LIST_DIR
70
+ + File .separator + config .getApiServerVersion ().get () + platformSuffix );
71
+ if (targetVersionDir .exists ()){
72
+ return Optional .of (targetVersionDir );
73
+ } else {
74
+ return Optional .empty ();
75
+ }
71
76
}
72
77
File binariesListDir = new File (config .getJenvtestDir (), BINARY_LIST_DIR );
73
78
if (!binariesListDir .exists ()) {
Original file line number Diff line number Diff line change 10
10
class ApiServerTest {
11
11
12
12
@ Test
13
- void sanityTest () {
14
- var kubeApi = new APIServer ();
15
- try {
16
- kubeApi .start ();
17
-
18
- var client = new KubernetesClientBuilder ().build ();
19
- client .resource (testConfigMap ()).createOrReplace ();
20
- var cm = client .resource (testConfigMap ()).get ();
21
-
22
- assertThat (cm ).isNotNull ();
23
- } finally {
24
- kubeApi .stop ();
25
- }
13
+ void trivialCase () {
14
+ testWithAPIServer (new APIServer ());
26
15
}
27
16
17
+ @ Test
18
+ void apiServerWithSpecificVersion () {
19
+ testWithAPIServer (new APIServer (APIServerConfigBuilder .anAPIServerConfig ()
20
+ .withApiServerVersion ("1.26.0" )
21
+ .build ()));
22
+ }
23
+
24
+
25
+ void testWithAPIServer (APIServer kubeApi ) {
26
+ kubeApi .start ();
27
+
28
+ var client = new KubernetesClientBuilder ().build ();
29
+ client .resource (testConfigMap ()).create ();
30
+ var cm = client .resource (testConfigMap ()).get ();
31
+
32
+ assertThat (cm ).isNotNull ();
33
+
34
+ kubeApi .stop ();
35
+ }
36
+
37
+
28
38
}
Original file line number Diff line number Diff line change
1
+ package com .csviri .jenvtest .binary ;
2
+
3
+ import com .csviri .jenvtest .APIServerConfig ;
4
+ import com .csviri .jenvtest .APIServerConfigBuilder ;
5
+ import com .csviri .jenvtest .JenvtestException ;
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ import static org .junit .jupiter .api .Assertions .*;
9
+
10
+ class BinaryManagerTest {
11
+
12
+ @ Test
13
+ void throwsExceptionIfBinaryNotPresentAndInOfflineMode () {
14
+ BinaryManager binaryManager = new BinaryManager (APIServerConfigBuilder .anAPIServerConfig ()
15
+ .withDownloadBinaries (false )
16
+ .withApiServerVersion ("1.0.1" )
17
+ .build ());
18
+
19
+ assertThrows (JenvtestException .class , binaryManager ::initAndDownloadIfRequired );
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments