@@ -30,6 +30,8 @@ public class ITElasticLogging extends BaseTest {
3030 private static String k8sExecCmdPrefix ;
3131 private static String elasticSearchURL ;
3232 private static Map <String , Object > testVarMap ;
33+ private static final String elasticStackYamlLoc =
34+ "kubernetes/samples/scripts/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml" ;
3335
3436 /**
3537 * This method gets called only once before any of the test methods are executed. It does the
@@ -46,12 +48,13 @@ public static void staticPrepare() throws Exception {
4648 initialize (APP_PROPS_FILE );
4749
4850 // Install Elastic Stack
49- String cmd =
50- "kubectl apply -f "
51- + getProjectRoot ()
52- + "/kubernetes/samples/scripts/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml" ;
53- logger .info ("Command to install Elastic search and Kibana: " + cmd );
54- TestUtils .exec (cmd );
51+ StringBuffer cmd =
52+ new StringBuffer ("kubectl apply -f " )
53+ .append (getProjectRoot ())
54+ .append ("/" )
55+ .append (elasticStackYamlLoc );
56+ logger .info ("Command to Install Elastic Stack: " + cmd .toString ());
57+ TestUtils .exec (cmd .toString ());
5558
5659 // Create operator-elk
5760 if (operator == null ) {
@@ -69,11 +72,12 @@ public static void staticPrepare() throws Exception {
6972 // Get Elasticsearch host and port from yaml file and build Elasticsearch URL
7073 testVarMap = TestUtils .loadYaml (OPERATOR1_ELK_YAML );
7174 String operatorPodName = operator .getOperatorPodName ();
72- elasticSearchURL =
73- "http://"
74- + testVarMap .get ("elasticSearchHost" )
75- + ":"
76- + testVarMap .get ("elasticSearchPort" );
75+ StringBuffer elasticSearchURLBuff =
76+ new StringBuffer ("http://" )
77+ .append (testVarMap .get ("elasticSearchHost" ))
78+ .append (":" )
79+ .append (testVarMap .get ("elasticSearchPort" ));
80+ elasticSearchURL = elasticSearchURLBuff .toString ();
7781 Assume .assumeFalse (
7882 "Got null when building Elasticsearch URL" , elasticSearchURL .contains ("null" ));
7983
@@ -108,12 +112,13 @@ public static void staticUnPrepare() throws Exception {
108112 tearDown (new Object () {}.getClass ().getEnclosingClass ().getSimpleName ());
109113
110114 // Uninstall Elastic Stack
111- String cmd =
112- "kubectl delete -f "
113- + getProjectRoot ()
114- + "/kubernetes/samples/scripts/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml" ;
115- logger .info ("Command to uninstall Elastic Stack: " + cmd );
116- TestUtils .exec (cmd );
115+ StringBuffer cmd =
116+ new StringBuffer ("kubectl delete -f " )
117+ .append (getProjectRoot ())
118+ .append ("/" )
119+ .append (elasticStackYamlLoc );
120+ logger .info ("Command to uninstall Elastic Stack: " + cmd .toString ());
121+ TestUtils .exec (cmd .toString ());
117122
118123 logger .info ("SUCCESS" );
119124 }
@@ -214,7 +219,7 @@ private void verifySearchResults(String queryCriteria, String regex, boolean che
214219 Assume .assumeTrue ("Total failed count should be 0!" , failedCount == 0 );
215220 logger .info ("Total failed count: " + failedCount );
216221 } else {
217- Assume .assumeFalse ("Total failed count should be 0 !" , hits .isEmpty ());
222+ Assume .assumeFalse ("Total hits of search is empty !" , hits .isEmpty ());
218223 }
219224 }
220225
@@ -281,6 +286,7 @@ private static String execElasticStackStatusCheck(String indexName, String varLo
281286 .toString ();
282287 logger .info ("Command to exec Elastic Stack status check: " + cmd );
283288 ExecResult result = TestUtils .exec (cmd );
289+ logger .info (result .stdout ());
284290
285291 return result .stdout ();
286292 }
0 commit comments