15
15
import com .gargoylesoftware .htmlunit .html .HtmlPage ;
16
16
import com .gargoylesoftware .htmlunit .html .HtmlRadioButtonInput ;
17
17
import com .gargoylesoftware .htmlunit .html .HtmlSubmitInput ;
18
- import java .io .BufferedReader ;
19
- import java .io .InputStream ;
20
- import java .io .InputStreamReader ;
21
18
import java .net .Authenticator ;
22
19
import java .net .PasswordAuthentication ;
23
- import java .net .URL ;
24
20
import java .util .List ;
25
21
import java .util .Map ;
26
22
import javax .xml .bind .DatatypeConverter ;
@@ -45,26 +41,18 @@ public class ITMonitoringExporter extends BaseTest {
45
41
private static Operator operator = null ;
46
42
private static Domain domain = null ;
47
43
private static String myhost = "" ;
48
- private static String metricsUrl = "" ;
49
44
private static String exporterUrl = "" ;
50
- private static String serverName = "managed-server" ;
51
45
private static String configPath = "" ;
52
- private static String appName = TESTWSAPP ;
53
- private static String appNameUC = "TestWSApp" ;
54
- private static String testWSAppTotalServletInvokesSearchKey1 =
55
- "weblogic_servlet_invocation_total_count{app=\" testwsapp\" ,name=\" managed-server1_/TestWSApp\" ,servletName=\" TestWSAppServlethttp\" }" ;
56
- private static String testWSAppTotalServletInvokesSearchKey2 =
57
- "weblogic_servlet_invocation_total_count{app=\" testwsapp\" ,name=\" managed-server2_/TestWSApp\" ,servletName=\" TestWSAppServlethttp\" }" ;
58
- private static String loadBalancer = "TRAEFIK" ;
46
+ private static String metricsUrl = "" ;
47
+ // "heap_free_current{name="managed-server1"}[15s]" search for results for last 15secs
59
48
private static String prometheusSearchKey1 =
60
- "heap_free_current%7Bname%3D%22managed-server1%22%7D" ;
49
+ "heap_free_current%7Bname%3D%22managed-server1%22%7D%5B15s%5D " ;
61
50
private static String prometheusSearchKey2 =
62
- "heap_free_current%7Bname%3D%22managed-server2%22%7D" ;
51
+ "heap_free_current%7Bname%3D%22managed-server2%22%7D%5B15s%5D " ;
63
52
private static String testwsappPrometheusSearchKey =
64
- "weblogic_servlet_invocation_total_count%7Bapp%3D%22testwsapp%22%7D" ;
53
+ "weblogic_servlet_invocation_total_count%7Bapp%3D%22testwsapp%22%7D%5B15s%5D " ;
65
54
String oprelease = "op" + number ;
66
55
private int waitTime = 5 ;
67
- private int maxIterations = 30 ;
68
56
69
57
/**
70
58
* This method gets called only once before any of the test methods are executed. It does the
@@ -91,7 +79,7 @@ public static void staticPrepare() throws Exception {
91
79
myhost = domain .getHostNameForCurl ();
92
80
exporterUrl = "http://" + myhost + ":" + domain .getLoadBalancerWebPort () + "/wls-exporter/" ;
93
81
metricsUrl = exporterUrl + "metrics" ;
94
- configPath = BaseTest .getProjectRoot () + "/integration-tests/src/test/resources/exporter/ " ;
82
+ configPath = BaseTest .getProjectRoot () + "/integration-tests/src/test/resources/exporter" ;
95
83
upgradeTraefikHostName ();
96
84
deployRunMonitoringExporter (domain , operator );
97
85
buildDeployWebServiceApp (domain , TESTWSAPP , TESTWSSERVICE );
@@ -158,47 +146,9 @@ private static void startExporterPrometheusGrafana(Domain domain, Operator opera
158
146
throws Exception {
159
147
logger .info ("deploy exporter, prometheus, grafana " );
160
148
TestUtils .deployMonitoringExporterPrometethusGrafana (
161
- TestUtils .monitoringDir + "/apps/monitoringexporter/wls-exporter.war" , domain , operator );
162
- }
163
-
164
- private static Object getMetricsValue (BufferedReader contents , String metricKey )
165
- throws Exception {
166
- boolean found = false ;
167
- String line ;
168
- String result = null ;
169
- while ((line = contents .readLine ()) != null ) {
170
- if (line .contains (metricKey )) {
171
- found = true ;
172
- result = line .substring (line .lastIndexOf (" " ) + 1 );
173
- }
174
- }
175
- return result ;
176
- }
177
-
178
- private static boolean containsWordsIndexOf (String inputString , String [] words ) {
179
- boolean found = true ;
180
- for (String word : words ) {
181
- logger .info (" Checking inputString" + inputString + " word " + word );
182
- if (inputString .indexOf (word ) == -1 ) {
183
- found = false ;
184
- break ;
185
- }
186
- }
187
- return found ;
188
- }
189
-
190
- private static Object getMetricsValue (BufferedReader contents , String ... metricExp )
191
- throws Exception {
192
- boolean found = false ;
193
- String line ;
194
- String result = null ;
195
- while ((line = contents .readLine ()) != null ) {
196
- if (containsWordsIndexOf (line , metricExp )) {
197
- logger .info ("found metric value for " + line + " :" );
198
- result = line .substring (line .lastIndexOf (" " ) + 1 );
199
- }
200
- }
201
- return result ;
149
+ TestUtils .monitoringExporterDir + "/apps/monitoringexporter/wls-exporter.war" ,
150
+ domain ,
151
+ operator );
202
152
}
203
153
204
154
private static void setCredentials (WebClient webClient ) {
@@ -280,28 +230,23 @@ public void test01_CheckMetricsViaPrometheus() throws Exception {
280
230
*
281
231
* @throws Exception
282
232
*/
283
- // commenting out due bug OWLS-74163
284
- // @Test
233
+ @ Test
285
234
public void test02_ReplaceConfiguration () throws Exception {
286
235
Assume .assumeFalse (QUICKTEST );
287
236
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
288
237
logTestBegin (testMethodName );
289
238
boolean testCompletedSuccessfully = false ;
290
-
291
239
HtmlPage page = submitConfigureForm (exporterUrl , "replace" , configPath + "/rest_jvm.yml" );
292
240
293
- // check for updated metrics
294
- String searchKey1 = "heap_free_current{name=\" managed-server1\" }" ;
295
- String searchKey2 = "heap_free_current{name=\" managed-server2\" }" ;
296
241
boolean isFoundNewKey1 = false ;
297
242
boolean isFoundNewKey2 = false ;
298
243
boolean isFoundOldKey1 = true ;
299
244
boolean isFoundOldKey2 = true ;
300
245
301
- isFoundNewKey1 = checkMetrics ( searchKey1 );
302
- isFoundNewKey2 = checkMetrics ( searchKey2 );
303
- isFoundOldKey1 = checkMetrics ( testWSAppTotalServletInvokesSearchKey1 );
304
- isFoundOldKey2 = checkMetrics ( testWSAppTotalServletInvokesSearchKey2 );
246
+ isFoundNewKey1 = checkMetricsViaPrometheus ( prometheusSearchKey1 , "managed-server1" );
247
+ isFoundNewKey2 = checkMetricsViaPrometheus ( prometheusSearchKey2 , "managed-server2" );
248
+ isFoundOldKey1 = checkMetricsViaPrometheus ( testwsappPrometheusSearchKey , "managed-server1" );
249
+ isFoundOldKey2 = checkMetricsViaPrometheus ( testwsappPrometheusSearchKey , "managed-server2" );
305
250
String foundResults =
306
251
" server1: ( newMetrics:"
307
252
+ isFoundNewKey1
@@ -659,10 +604,10 @@ public void test14_AppendMetricsNameSnakeCaseTrueToSnakeCaseFalseConfiguration()
659
604
String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
660
605
logTestBegin (testMethodName );
661
606
boolean testCompletedSuccessfully = false ;
607
+
662
608
HtmlPage page =
663
609
submitConfigureForm (exporterUrl , "append" , configPath + "/rest_snakecasetrue.yml" );
664
610
assertNotNull (page );
665
- assertTrue (page .asText ().contains ("metricsNameSnakeCase" ));
666
611
String searchKey = "weblogic_servlet_executionTimeAverage%7Bapp%3D%22testwsapp%22%7D" ;
667
612
assertFalse (checkMetricsViaPrometheus (searchKey , "testwsapp" ));
668
613
testCompletedSuccessfully = true ;
@@ -798,15 +743,6 @@ private void changeConfigNegativeAuth(
798
743
}
799
744
}
800
745
801
- private Object getMetricsFromPage (String testUrl , String searchKey ) throws Exception {
802
- Authenticator .setDefault (new MyTestAuthenticator ());
803
- InputStream stream = new URL (testUrl ).openStream ();
804
- BufferedReader contents = new BufferedReader (new InputStreamReader (stream ));
805
- assertNotNull (contents );
806
-
807
- return getMetricsValue (contents , searchKey );
808
- }
809
-
810
746
private HtmlPage submitConfigureForm (
811
747
String exporterUrl , String effect , String configFile , String username , String password )
812
748
throws Exception {
@@ -858,7 +794,7 @@ private HtmlPage submitConfigureForm(
858
794
assertNotNull (page2 );
859
795
return page2 ;
860
796
}
861
-
797
+ /*
862
798
private boolean checkMetrics(String searchKey) throws Exception {
863
799
boolean result = false;
864
800
int i = 0;
@@ -878,6 +814,7 @@ private boolean checkMetrics(String searchKey) throws Exception {
878
814
}
879
815
return result;
880
816
}
817
+ */
881
818
}
882
819
883
820
class MyTestAuthenticator extends Authenticator {
0 commit comments