40
40
import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
41
41
import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
42
42
import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
43
+ import oracle .weblogic .kubernetes .assertions .TestAssertions ;
43
44
import oracle .weblogic .kubernetes .assertions .impl .ClusterRole ;
44
45
import oracle .weblogic .kubernetes .assertions .impl .ClusterRoleBinding ;
45
46
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
46
47
import org .apache .commons .io .FileUtils ;
47
48
48
49
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
49
50
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
51
+ import static oracle .weblogic .kubernetes .TestConstants .BUSYBOX_IMAGE ;
52
+ import static oracle .weblogic .kubernetes .TestConstants .BUSYBOX_TAG ;
50
53
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
54
+ import static oracle .weblogic .kubernetes .TestConstants .GRAFANA_IMAGE_NAME ;
55
+ import static oracle .weblogic .kubernetes .TestConstants .GRAFANA_IMAGE_TAG ;
51
56
import static oracle .weblogic .kubernetes .TestConstants .GRAFANA_REPO_NAME ;
52
57
import static oracle .weblogic .kubernetes .TestConstants .GRAFANA_REPO_URL ;
53
58
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
54
59
import static oracle .weblogic .kubernetes .TestConstants .MANAGED_SERVER_NAME_BASE ;
55
60
import static oracle .weblogic .kubernetes .TestConstants .MONITORING_EXPORTER_BRANCH ;
56
61
import static oracle .weblogic .kubernetes .TestConstants .MONITORING_EXPORTER_WEBAPP_VERSION ;
57
62
import static oracle .weblogic .kubernetes .TestConstants .OKD ;
63
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
64
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_ALERT_MANAGER_IMAGE_NAME ;
65
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_ALERT_MANAGER_IMAGE_TAG ;
66
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_CONFIG_MAP_RELOAD_IMAGE_NAME ;
67
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_CONFIG_MAP_RELOAD_IMAGE_TAG ;
68
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_IMAGE_NAME ;
69
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_IMAGE_TAG ;
70
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_NODE_EXPORTER_IMAGE_NAME ;
71
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_NODE_EXPORTER_IMAGE_TAG ;
72
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_PUSHGATEWAY_IMAGE_NAME ;
73
+ import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_PUSHGATEWAY_IMAGE_TAG ;
58
74
import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_REPO_NAME ;
59
75
import static oracle .weblogic .kubernetes .TestConstants .PROMETHEUS_REPO_URL ;
60
76
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
73
89
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
74
90
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
75
91
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
92
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
76
93
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
77
94
import static oracle .weblogic .kubernetes .utils .FileUtils .checkFile ;
78
95
import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
@@ -315,15 +332,48 @@ public static PrometheusParams installAndVerifyPrometheus(String promReleaseSuff
315
332
assertDoesNotThrow (() -> Files .copy (srcPromFile , targetPromFile ,
316
333
StandardCopyOption .REPLACE_EXISTING )," Failed to copy files" );
317
334
String oldValue = "regex: default;domain1" ;
318
- assertDoesNotThrow (() -> replaceStringInFile (targetPromFile .toString (),
319
- oldValue ,
320
- prometheusRegexValue ), "Failed to replace String " );
321
- assertDoesNotThrow (() -> replaceStringInFile (targetPromFile .toString (),
322
- "pvc-alertmanager" ,
323
- "pvc-alertmanager" + promReleaseSuffix ), "Failed to replace String " );;
324
- assertDoesNotThrow (() -> replaceStringInFile (targetPromFile .toString (),
325
- "pvc-prometheus" ,
326
- "pvc-" + prometheusReleaseName ),"Failed to replace String " );
335
+ logger .info ("copy the promvalues.yaml to staging location" );
336
+ assertDoesNotThrow (() -> {
337
+ replaceStringInFile (targetPromFile .toString (),
338
+ oldValue ,
339
+ prometheusRegexValue );
340
+ replaceStringInFile (targetPromFile .toString (),
341
+ "pvc-alertmanager" ,
342
+ "pvc-alertmanager" + promReleaseSuffix );
343
+ replaceStringInFile (targetPromFile .toString (),
344
+ "pvc-prometheus" ,
345
+ "pvc-" + prometheusReleaseName );
346
+ replaceStringInFile (targetPromFile .toString (),
347
+ "pushgateway_image" ,
348
+ PROMETHEUS_PUSHGATEWAY_IMAGE_NAME );
349
+ replaceStringInFile (targetPromFile .toString (),
350
+ "pushgateway_tag" ,
351
+ PROMETHEUS_PUSHGATEWAY_IMAGE_TAG );
352
+ replaceStringInFile (targetPromFile .toString (),
353
+ "prometheus_image" ,
354
+ PROMETHEUS_IMAGE_NAME );
355
+ replaceStringInFile (targetPromFile .toString (),
356
+ "prometheus_tag" ,
357
+ PROMETHEUS_IMAGE_TAG );
358
+ replaceStringInFile (targetPromFile .toString (),
359
+ "prometheus_alertmanager_image" ,
360
+ PROMETHEUS_ALERT_MANAGER_IMAGE_NAME );
361
+ replaceStringInFile (targetPromFile .toString (),
362
+ "prometheus_alertmanager_tag" ,
363
+ PROMETHEUS_ALERT_MANAGER_IMAGE_TAG );
364
+ replaceStringInFile (targetPromFile .toString (),
365
+ "prometheus_configmap_reload_image" ,
366
+ PROMETHEUS_CONFIG_MAP_RELOAD_IMAGE_NAME );
367
+ replaceStringInFile (targetPromFile .toString (),
368
+ "prometheus_configmap_reload_tag" ,
369
+ PROMETHEUS_CONFIG_MAP_RELOAD_IMAGE_TAG );
370
+ replaceStringInFile (targetPromFile .toString (),
371
+ "prometheus_node_exporter_image" ,
372
+ PROMETHEUS_NODE_EXPORTER_IMAGE_NAME );
373
+ replaceStringInFile (targetPromFile .toString (),
374
+ "prometheus_node_exporter_tag" ,
375
+ PROMETHEUS_NODE_EXPORTER_IMAGE_TAG );
376
+ }, "Failed to create " + targetPromFile );
327
377
if (OKD ) {
328
378
assertDoesNotThrow (() -> replaceStringInFile (targetPromFile .toString (),
329
379
"65534" ,
@@ -389,23 +439,53 @@ public static PrometheusParams installAndVerifyPrometheus(String promReleaseSuff
389
439
*
390
440
* @param grafanaReleaseName the grafana release name
391
441
* @param grafanaNamespace the grafana namespace in which the operator will be installed
392
- * @param grafanaValueFile the grafana value .yaml file path
442
+ * @param grafanaHelmValuesFileDir the grafana helm values .yaml file directory
393
443
* @param grafanaVersion the version of the grafana helm chart
394
444
* @return the grafana Helm installation parameters
395
445
*/
396
446
public static GrafanaParams installAndVerifyGrafana (String grafanaReleaseName ,
397
447
String grafanaNamespace ,
398
- String grafanaValueFile ,
448
+ String grafanaHelmValuesFileDir ,
399
449
String grafanaVersion ) {
400
450
LoggingFacade logger = getLogger ();
451
+ logger .info ("create a staging location for grafana scripts" );
452
+ Path fileTemp = Paths .get (grafanaHelmValuesFileDir );
453
+ assertDoesNotThrow (() -> FileUtils .deleteDirectory (fileTemp .toFile ()),"Failed to delete temp dir for grafana" );
454
+
455
+ assertDoesNotThrow (() -> Files .createDirectories (fileTemp ), "Failed to create temp dir for grafana" );
456
+
457
+ logger .info ("copy the grafanavalues.yaml to staging location" );
458
+ Path srcGrafanaFile = Paths .get (RESOURCE_DIR , "exporter" , "grafanavalues.yaml" );
459
+ Path targetGrafanaFile = Paths .get (fileTemp .toString (), "grafanavalues.yaml" );
460
+ assertDoesNotThrow (() -> Files .copy (srcGrafanaFile , targetGrafanaFile ,
461
+ StandardCopyOption .REPLACE_EXISTING )," Failed to copy files" );
462
+ assertDoesNotThrow (() -> replaceStringInFile (targetGrafanaFile .toString (),
463
+ "pvc-grafana" , "pvc-" + grafanaReleaseName ));
464
+ assertDoesNotThrow (() -> replaceStringInFile (targetGrafanaFile .toString (),
465
+ "grafana_image" ,
466
+ GRAFANA_IMAGE_NAME ),"Failed to replace String " );
467
+ assertDoesNotThrow (() -> replaceStringInFile (targetGrafanaFile .toString (),
468
+ "grafana_tag" ,
469
+ GRAFANA_IMAGE_TAG ),"Failed to replace String " );
470
+ assertDoesNotThrow (() -> replaceStringInFile (targetGrafanaFile .toString (),
471
+ "busybox_image" ,
472
+ BUSYBOX_IMAGE ), "Failed to replace String " );
473
+ assertDoesNotThrow (() -> replaceStringInFile (targetGrafanaFile .toString (),
474
+ "busybox_tag" ,
475
+ BUSYBOX_TAG ), "Failed to replace String " );
476
+
477
+ if (!OKE_CLUSTER ) {
478
+ assertDoesNotThrow (() -> replaceStringInFile (targetGrafanaFile .toString (),
479
+ "enabled: false" , "enabled: true" ));
480
+ }
401
481
// Helm install parameters
402
482
HelmParams grafanaHelmParams = new HelmParams ()
403
483
.releaseName (grafanaReleaseName )
404
484
.namespace (grafanaNamespace )
405
485
.repoUrl (GRAFANA_REPO_URL )
406
486
.repoName (GRAFANA_REPO_NAME )
407
487
.chartName ("grafana" )
408
- .chartValuesFile (grafanaValueFile );
488
+ .chartValuesFile (targetGrafanaFile . toString () );
409
489
410
490
if (grafanaVersion != null ) {
411
491
grafanaHelmParams .chartVersion (grafanaVersion );
@@ -429,6 +509,7 @@ public static GrafanaParams installAndVerifyGrafana(String grafanaReleaseName,
429
509
logger .info ("Installing grafana in namespace {0}" , grafanaNamespace );
430
510
int grafanaNodePort = getNextFreePort ();
431
511
logger .info ("Installing grafana with node port {0}" , grafanaNodePort );
512
+ assertDoesNotThrow (() -> logger .info (Files .readString (targetGrafanaFile )));
432
513
// grafana chart values to override
433
514
GrafanaParams grafanaParams = new GrafanaParams ()
434
515
.helmParams (grafanaHelmParams )
@@ -454,7 +535,7 @@ public static GrafanaParams installAndVerifyGrafana(String grafanaReleaseName,
454
535
logger .info ("Wait for the grafana pod is ready in namespace {0}" , grafanaNamespace );
455
536
testUntil (
456
537
assertDoesNotThrow (() -> isGrafanaReady (grafanaNamespace ),
457
- "grafanaIsReady failed with ApiException" ),
538
+ "grafanaIsReady failed with ApiException" ),
458
539
logger ,
459
540
"grafana to be running in namespace {0}" ,
460
541
grafanaNamespace );
@@ -789,12 +870,11 @@ public static void verifyMonExpAppAccessThroughNginx(String nginxHost, int repli
789
870
ADMIN_PASSWORD_DEFAULT ,
790
871
K8S_NODEPORT_HOST ,
791
872
nodeport );
792
- assertThat (callWebAppAndCheckForServerNameInResponse (curlCmd , managedServerNames , 50 ))
793
- .as ("Verify NGINX can access the monitoring exporter metrics "
794
- + "from all managed servers in the domain via http" )
795
- .withFailMessage ("NGINX can not access the monitoring exporter metrics "
796
- + "from one or more of the managed servers via http" )
797
- .isTrue ();
873
+ testUntil (withLongRetryPolicy ,
874
+ TestAssertions .callTestWebAppAndCheckForServerNameInResponse (curlCmd , managedServerNames , 200 ),
875
+ logger ,
876
+ "Verify NGINX can access the monitoring exporter metrics \n "
877
+ + "from all managed servers in the domain via http" );
798
878
}
799
879
800
880
/**
0 commit comments