24
24
import java .util .List ;
25
25
import java .util .Map ;
26
26
import javax .xml .bind .DatatypeConverter ;
27
- import oracle .kubernetes .operator .utils .Domain ;
28
- import oracle .kubernetes .operator .utils .Operator ;
29
- import oracle .kubernetes .operator .utils .TestUtils ;
27
+ import oracle .kubernetes .operator .utils .*;
30
28
import org .junit .AfterClass ;
31
29
import org .junit .Assert ;
32
30
import org .junit .Assume ;
@@ -56,6 +54,7 @@ public class ITMonitoringExporter extends BaseTest {
56
54
String oprelease = "op" + number ;
57
55
private int waitTime = 5 ;
58
56
private int maxIterations = 30 ;
57
+ private static String loadBalancer = "TRAEFIK" ;
59
58
60
59
/**
61
60
* This method gets called only once before any of the test methods are executed. It does the
@@ -80,13 +79,13 @@ public static void staticPrepare() throws Exception {
80
79
domain = createVerifyDomain (number , operator );
81
80
Assert .assertNotNull (domain );
82
81
}
82
+
83
83
myhost = domain .getHostNameForCurl ();
84
84
exporterUrl = "http://" + myhost + ":" + domain .getLoadBalancerWebPort () + "/wls-exporter/" ;
85
85
metricsUrl = exporterUrl + "metrics" ;
86
86
configPath = BaseTest .getProjectRoot () + "/integration-tests/src/test/resources/exporter/" ;
87
-
88
- deployRunMonitoringExporter (domain , operator );
89
87
upgradeTraefikHostName ();
88
+ deployRunMonitoringExporter (domain , operator );
90
89
buildDeployWebServiceApp (domain , TESTWSAPP , TESTWSSERVICE );
91
90
}
92
91
}
@@ -148,6 +147,43 @@ private static Domain createVerifyDomain(int number, Operator operator) throws E
148
147
return domain ;
149
148
}
150
149
150
+ /**
151
+ * call webapp and verify load balancing by checking server name in the response
152
+ *
153
+ * @param searchKey - metric query expression
154
+ * @throws Exception
155
+ */
156
+ public String checkMetricsViaPrometheus (String searchKey ) throws Exception {
157
+
158
+ // url
159
+ StringBuffer testAppUrl = new StringBuffer ("http://" );
160
+ testAppUrl
161
+ .append (domain .getHostNameForCurl ())
162
+ .append (":" )
163
+ .append ("32000" )
164
+ .append ("/api/v1/query?query=" );
165
+ if (loadBalancer .equals ("APACHE" )) {
166
+ testAppUrl .append ("weblogic/" );
167
+ }
168
+ testAppUrl .append (searchKey );
169
+ // curl cmd to call webapp
170
+ StringBuffer curlCmd = new StringBuffer ("curl --silent --noproxy '*'" );
171
+ curlCmd
172
+ .append (" -H 'host: " )
173
+ .append (domain .getDomainUid ())
174
+ .append (".org' " )
175
+ .append (testAppUrl .toString ());
176
+ // curl cmd to get response code
177
+ StringBuffer curlCmdResCode = new StringBuffer (curlCmd .toString ());
178
+ curlCmdResCode .append (" --write-out %{http_code} -o /dev/null" );
179
+
180
+ logger .info ("Curl cmd with response code " + curlCmdResCode );
181
+ logger .info ("Curl cmd " + curlCmd );
182
+ ExecResult result = ExecCommand .exec (curlCmd .toString ());
183
+ logger .info ("webapp invoked successfully for curlCmd:" + curlCmd );
184
+ return result .stdout ().trim ();
185
+ }
186
+
151
187
private static void startExporterPrometheusGrafana (Domain domain , Operator operator )
152
188
throws Exception {
153
189
@@ -238,6 +274,25 @@ public void test01_ReplaceConfiguration() throws Exception {
238
274
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
239
275
logTestBegin (testMethodName );
240
276
boolean testCompletedSuccessfully = false ;
277
+ String checkPrometheus = checkMetricsViaPrometheus ("webapp_config_open_sessions_current_count" );
278
+ assertTrue (checkPrometheus .contains ("testwsapp" ));
279
+
280
+ testCompletedSuccessfully = true ;
281
+ logger .info ("SUCCESS - " + testMethodName );
282
+ }
283
+
284
+ /**
285
+ * Replace monitoring exporter configuration and verify it was applied to both managed servers
286
+ *
287
+ * @throws Exception
288
+ */
289
+ @ Test
290
+ public void test02_ReplaceConfiguration () throws Exception {
291
+ Assume .assumeFalse (QUICKTEST );
292
+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
293
+ logTestBegin (testMethodName );
294
+ boolean testCompletedSuccessfully = false ;
295
+ logger .info (checkMetricsViaPrometheus ("heap_size_current" ));
241
296
/*
242
297
exporterUrl = "http://slc13kef.us.oracle.com:" + "30305" + "/wls-exporter/";
243
298
metricsUrl = exporterUrl + "metrics";
0 commit comments