3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
+ import java .nio .file .Path ;
6
7
import java .time .OffsetDateTime ;
7
8
import java .util .ArrayList ;
8
9
import java .util .HashMap ;
39
40
import org .junit .jupiter .api .Test ;
40
41
import org .junit .jupiter .api .TestMethodOrder ;
41
42
43
+ import static java .nio .file .Files .createDirectories ;
44
+ import static java .nio .file .Files .write ;
45
+ import static java .nio .file .Paths .get ;
42
46
import static java .util .concurrent .TimeUnit .MINUTES ;
43
47
import static java .util .concurrent .TimeUnit .SECONDS ;
44
48
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
54
58
import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_CHART_DIR ;
55
59
import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_RELEASE_NAME ;
56
60
import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_SERVICE_NAME ;
61
+ import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
57
62
import static oracle .weblogic .kubernetes .TestConstants .WLS_DOMAIN_TYPE ;
58
63
import static oracle .weblogic .kubernetes .actions .TestActions .createServiceAccount ;
59
64
import static oracle .weblogic .kubernetes .actions .TestActions .deleteDomainCustomResource ;
60
65
import static oracle .weblogic .kubernetes .actions .TestActions .deleteSecret ;
61
66
import static oracle .weblogic .kubernetes .actions .TestActions .deleteServiceAccount ;
62
67
import static oracle .weblogic .kubernetes .actions .TestActions .getOperatorImageName ;
68
+ import static oracle .weblogic .kubernetes .actions .TestActions .getOperatorPodName ;
63
69
import static oracle .weblogic .kubernetes .actions .TestActions .getPodCreationTimestamp ;
64
70
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
65
71
import static oracle .weblogic .kubernetes .actions .TestActions .helmValuesToString ;
89
95
import static oracle .weblogic .kubernetes .utils .SecretUtils .createExternalRestIdentitySecret ;
90
96
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
91
97
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
98
+ import static org .apache .commons .io .FileUtils .deleteDirectory ;
92
99
import static org .assertj .core .api .Assertions .assertThat ;
93
100
import static org .awaitility .Awaitility .with ;
94
101
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
@@ -110,6 +117,7 @@ class ItUsabilityOperatorHelmChart {
110
117
111
118
private static String opNamespace = null ;
112
119
private static String op2Namespace = null ;
120
+ private static String op3Namespace = null ;
113
121
private static String domain1Namespace = null ;
114
122
private static String domain2Namespace = null ;
115
123
private static String domain3Namespace = null ;
@@ -147,7 +155,7 @@ class ItUsabilityOperatorHelmChart {
147
155
* JUnit engine parameter resolution mechanism
148
156
*/
149
157
@ BeforeAll
150
- public static void initAll (@ Namespaces (6 ) List <String > namespaces ) {
158
+ public static void initAll (@ Namespaces (7 ) List <String > namespaces ) {
151
159
logger = getLogger ();
152
160
// get a unique operator namespace
153
161
logger .info ("Getting a unique namespace for operator" );
@@ -178,6 +186,11 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
178
186
logger .info ("Getting a unique namespace for operator 2" );
179
187
assertNotNull (namespaces .get (5 ), "Namespace list is null" );
180
188
op2Namespace = namespaces .get (5 );
189
+
190
+ // get a unique operator 3 namespace
191
+ logger .info ("Getting a unique namespace for operator 3" );
192
+ assertNotNull (namespaces .get (6 ), "Namespace list is null" );
193
+ op3Namespace = namespaces .get (6 );
181
194
}
182
195
183
196
@ AfterAll
@@ -797,15 +810,15 @@ void testTwoDomainsInSameNameSpaceOnOperator() {
797
810
798
811
String opReleaseName = OPERATOR_RELEASE_NAME ;
799
812
HelmParams op1HelmParams = new HelmParams ().releaseName (opReleaseName )
800
- .namespace (op2Namespace )
813
+ .namespace (op3Namespace )
801
814
.chartDir (OPERATOR_CHART_DIR );
802
815
try {
803
816
// install operator
804
- String opServiceAccount = op2Namespace + "-sa" ;
805
- HelmParams opHelmParams = installAndVerifyOperator (op2Namespace , opServiceAccount , true ,
806
- 0 , op1HelmParams , domain4Namespace ).getHelmParams ();
817
+ String opServiceAccount = op3Namespace + "-sa" ;
818
+ HelmParams opHelmParams = installAndVerifyOperator (op3Namespace , opServiceAccount , true ,
819
+ 0 , "FINE" , op1HelmParams , domain4Namespace ).getHelmParams ();
807
820
assertNotNull (opHelmParams , "Can't install operator" );
808
- int externalRestHttpsPort = getServiceNodePort (op2Namespace , "external-weblogic-operator-svc" );
821
+ int externalRestHttpsPort = getServiceNodePort (op3Namespace , "external-weblogic-operator-svc" );
809
822
assertTrue (externalRestHttpsPort != -1 ,
810
823
"Could not get the Operator external service node port" );
811
824
logger .info ("externalRestHttpsPort {0}" , externalRestHttpsPort );
@@ -818,7 +831,7 @@ void testTwoDomainsInSameNameSpaceOnOperator() {
818
831
"can't start or verify domain5 in namespace " + domain4Namespace );
819
832
820
833
assertTrue (scaleClusterWithRestApi (domain4Uid , clusterName ,3 ,
821
- externalRestHttpsPort ,op2Namespace , opServiceAccount ),
834
+ externalRestHttpsPort ,op3Namespace , opServiceAccount ),
822
835
"Domain4 " + domain4Namespace + " scaling operation failed" );
823
836
String managedServerPodName1 = domain4Uid + managedServerPrefix + 3 ;
824
837
logger .info ("Checking that the managed server pod {0} exists in namespace {1}" ,
@@ -829,21 +842,21 @@ void testTwoDomainsInSameNameSpaceOnOperator() {
829
842
logger .info ("Domain4 scaled to 3 servers" );
830
843
831
844
assertTrue (scaleClusterWithRestApi (domain5Uid , clusterName ,3 ,
832
- externalRestHttpsPort ,op2Namespace , opServiceAccount ),
833
- "Domain2 " + domain4Namespace + " scaling operation failed" );
845
+ externalRestHttpsPort ,op3Namespace , opServiceAccount ),
846
+ "Domain5 " + domain4Namespace + " scaling operation failed" );
834
847
String managedServerPodName2 = domain5Uid + managedServerPrefix + 3 ;
835
848
logger .info ("Checking that the managed server pod {0} exists in namespace {1}" ,
836
849
managedServerPodName2 , domain4Namespace );
837
850
assertDoesNotThrow (() ->
838
851
checkPodExists (managedServerPodName2 , domain5Uid , domain4Namespace ),
839
- "operator failed to manage domain2 , scaling was not succeeded" );
852
+ "operator failed to manage domain5 , scaling was not succeeded" );
840
853
841
- logger .info ("Domain4 scaled to 3 servers" );
854
+ logger .info ("Domain5 scaled to 3 servers" );
842
855
843
856
assertDoesNotThrow (() ->
844
857
TestActions .scaleClusterWithScalingActionScript (clusterName , domain4Uid , domain4Namespace ,
845
858
"/u01/domains/" + domain4Uid , "scaleDown" , 1 ,
846
- op2Namespace , opServiceAccount ),
859
+ op3Namespace , opServiceAccount ),
847
860
"scaling was not succeeded" );
848
861
assertDoesNotThrow (() ->
849
862
checkPodDoesNotExist (managedServerPodName1 , domain4Uid , domain4Namespace ),
@@ -852,17 +865,36 @@ void testTwoDomainsInSameNameSpaceOnOperator() {
852
865
assertDoesNotThrow (() ->
853
866
TestActions .scaleClusterWithScalingActionScript (clusterName , domain5Uid , domain4Namespace ,
854
867
"/u01/domains/" + domain5Uid , "scaleDown" , 1 ,
855
- op2Namespace , opServiceAccount ),
868
+ op3Namespace , opServiceAccount ),
856
869
" scaling via scalingAction.sh script was not succeeded for domain5" );
857
870
858
871
assertDoesNotThrow (() ->
859
872
checkPodDoesNotExist (managedServerPodName2 , domain5Uid , domain4Namespace ),
860
873
" scaling via scalingAction.sh script was not succeeded for domain5" );
861
874
logger .info ("Domain5 scaled to 2 servers" );
862
875
} finally {
876
+ try {
877
+ String operatorPodName =
878
+ assertDoesNotThrow (() -> getOperatorPodName (OPERATOR_RELEASE_NAME , op3Namespace ),
879
+ "Can't get operator's pod name" );
880
+ Path logDirPath = get (RESULTS_ROOT , this .getClass ().getSimpleName ());
881
+ assertDoesNotThrow (() -> deleteDirectory (logDirPath .toFile ()),
882
+ "Delete directory failed" );
883
+ assertDoesNotThrow (() -> createDirectories (logDirPath ),
884
+ "Create directory failed" );
885
+ String podLog = assertDoesNotThrow (() -> TestActions .getPodLog (operatorPodName , op3Namespace ));
886
+ Path pathToLog =
887
+ get (RESULTS_ROOT , this .getClass ().getSimpleName (),
888
+ "/TwoDomainsInSameNameSpaceOnOperatorOpLog" + op3Namespace + ".log" );
889
+
890
+ assertDoesNotThrow (() -> write (pathToLog , podLog .getBytes ()),
891
+ "Can't write to file " + pathToLog );
892
+ } catch (Exception ex ) {
893
+ logger .info ("Failed to collect operator log" );
894
+ }
863
895
uninstallOperator (op1HelmParams );
864
- deleteSecret (OCIR_SECRET_NAME ,op2Namespace );
865
- cleanUpSA (op2Namespace );
896
+ deleteSecret (OCIR_SECRET_NAME , op3Namespace );
897
+ cleanUpSA (op3Namespace );
866
898
}
867
899
}
868
900
0 commit comments