11
11
import static org .hamcrest .Matchers .sameInstance ;
12
12
import static org .hamcrest .junit .MatcherAssert .assertThat ;
13
13
14
+ import com .google .code .tempusfugit .concurrency .IntermittentTestRunner ;
15
+ import com .google .code .tempusfugit .concurrency .annotations .Intermittent ;
14
16
import com .meterware .simplestub .Memento ;
15
17
import com .meterware .simplestub .StaticStubSupport ;
16
18
import io .kubernetes .client .models .V1ObjectMeta ;
23
25
import oracle .kubernetes .weblogic .domain .v2 .DomainSpec ;
24
26
import org .junit .After ;
25
27
import org .junit .Before ;
26
- import org .junit .Ignore ;
27
28
import org .junit .Rule ;
28
29
import org .junit .Test ;
29
30
import org .junit .rules .TestWatcher ;
30
31
import org .junit .runner .Description ;
32
+ import org .junit .runner .RunWith ;
31
33
34
+ @ RunWith (IntermittentTestRunner .class )
32
35
public class ServerKubernetesObjectsLookupTest {
33
36
34
37
private List <Memento > mementos = new ArrayList <>();
35
38
39
+ private String retryLegalName ;
40
+ private ServerKubernetesObjects retryInstance ;
41
+
36
42
@ Rule
37
43
public TestWatcher watcher =
38
44
new TestWatcher () {
39
45
@ Override
40
46
protected void failed (Throwable e , Description description ) {
41
47
super .failed (e , description );
42
48
System .out .println ("Tell Russell\n " + DomainPresenceMonitor .getExplanation ());
43
- try {
44
- Memento serverMap =
45
- StaticStubSupport .preserve (ServerKubernetesObjectsManager .class , "serverMap" );
46
- Map <String , ServerKubernetesObjects > map = serverMap .getOriginalValue ();
47
- System .out .println (" internal: " + map );
48
- System .out .println (
49
- " returned: " + ServerKubernetesObjectsManager .getServerKubernetesObjects ());
50
- } catch (NoSuchFieldException ignored ) {
51
- }
49
+ Map <String , ServerKubernetesObjects > returnedMap =
50
+ ServerKubernetesObjectsManager .getServerKubernetesObjects ();
51
+
52
+ System .out .printf (
53
+ "\n Object in map with key %s is %s, which compares %b" ,
54
+ retryLegalName ,
55
+ returnedMap .get (retryLegalName ),
56
+ retryInstance == returnedMap .get (retryLegalName ));
52
57
}
53
58
};
54
59
@@ -82,7 +87,7 @@ public void whenNoPreexistingDomains_createEmptyServerKubernetesObjectsMap() {
82
87
}
83
88
84
89
@ Test
85
- @ Ignore
90
+ @ Intermittent ( repetition = 10 )
86
91
public void whenK8sHasDomainWithOneServer_canLookupFromServerKubernetesObjectsFactory () {
87
92
Domain domain = createDomain ("UID1" , "ns1" );
88
93
DomainPresenceInfo info = DomainPresenceInfoManager .getOrCreate (domain );
@@ -91,6 +96,8 @@ public void whenK8sHasDomainWithOneServer_canLookupFromServerKubernetesObjectsFa
91
96
92
97
assertThat (info .getServers (), hasEntry (equalTo ("admin" ), sameInstance (sko )));
93
98
99
+ retryLegalName = LegalNames .toServerName ("UID1" , "admin" );
100
+ retryInstance = sko ;
94
101
assertThat (
95
102
ServerKubernetesObjectsManager .getServerKubernetesObjects (),
96
103
hasEntry (equalTo (LegalNames .toServerName ("UID1" , "admin" )), sameInstance (sko )));
0 commit comments