[teiid-commits] teiid SVN: r1632 - trunk/test-integration/db/src/main/java/org/teiid/test/client.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Dec 9 18:01:57 EST 2009


Author: vhalbert at redhat.com
Date: 2009-12-09 18:01:57 -0500 (Wed, 09 Dec 2009)
New Revision: 1632

Modified:
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
Log:
Teiid 781 - added a new summary report that gives the totals across all querysets for a given scenario

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java	2009-12-09 22:48:20 UTC (rev 1631)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java	2009-12-09 23:01:57 UTC (rev 1632)
@@ -64,8 +64,10 @@
 
     public static final SimpleDateFormat TSFORMAT = new SimpleDateFormat(
 	    "HH:mm:ss.SSS"); //$NON-NLS-1$
+    
+    
+    private Properties overrides = new Properties();
 
-
     public TestClient() {
 
 
@@ -100,6 +102,10 @@
 //	    FileUtils.removeDirectoryAndChildren(f);
 //	}
 	
+	this.overrides = getSubstitutedProperties(ConfigPropertyLoader.getInstance().getProperties());
+	
+	ConfigPropertyLoader.getInstance().setProperties(this.overrides);
+	
 	String scenaios_dir = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_DIR);
 	if (scenaios_dir == null) {
 	    throw new TransactionRuntimeException("scenariodir property was not defined");
@@ -115,6 +121,9 @@
 	
 	// List<String> queryFiles = new ArrayList<String>(files.length);
 	for (int i = 0; i < files.length; i++) {
+	    // overrides need to be reset because all overrides are cleared out after each query set
+	    ConfigPropertyLoader.getInstance().setProperties(overrides);
+	    
 	    runTest(files[i]);
 	}
 	
@@ -129,8 +138,12 @@
 	TestLogger.log("Starting scenario " + scenario_name);
 	
 	Properties sc_props = PropertiesUtils.load(scenariofile.getAbsolutePath());
-//	updateProps(sc_props);
 	
+	Properties sc_updates = getSubstitutedProperties(sc_props);
+	if (!sc_updates.isEmpty()) {
+	    sc_props.putAll(sc_props);
+	}
+	
 	// add the scenario props to the configuration
 	ConfigPropertyLoader.getInstance().setProperties(sc_props);
 	
@@ -250,23 +263,26 @@
 
     }
     
-    private void updateProps(Properties props) {
-	Properties configProps = ConfigPropertyLoader.getInstance().getProperties();
+    private Properties getSubstitutedProperties(Properties props) {
+	Properties or = new Properties();
 	
+	Properties configprops = ConfigPropertyLoader.getInstance().getProperties();
+
+	
 	Iterator it = props.keySet().iterator();
 	while (it.hasNext()) {
 	    String key = (String) it.next();
 	    String value = props.getProperty( key );
 	    String newValue = null;
 	    int loc = value.indexOf("${");
-	    while (loc >= -1) {
+	    while (loc > -1) {
 
-		String prop_name = value.substring(loc, value.indexOf("}", loc) );
+		String prop_name = value.substring(loc + 2, value.indexOf("}", loc) );
 		
-		String prop_value = configProps.getProperty(prop_name);
+		String prop_value = configprops.getProperty(prop_name);
 		if (prop_value != null) {
 		
-		    String newvalue = StringUtil.replace(value, "${" + prop_name + "}", prop_value);
+		    newValue = StringUtil.replace(value, "${" + prop_name + "}", prop_value);
 		    
 		    
 		}
@@ -275,11 +291,13 @@
 		
 	    }
 	    if (newValue != null) {
-		ConfigPropertyLoader.getInstance().setProperty(key, newValue);
+		or.setProperty(key, newValue);
 	    }
 	    		
 	}
 	
+	return or;
+
     }
 
     

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java	2009-12-09 22:48:20 UTC (rev 1631)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java	2009-12-09 23:01:57 UTC (rev 1632)
@@ -32,10 +32,12 @@
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 public class TestResultsSummary  {
     private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
@@ -47,7 +49,9 @@
     private int total_queries = 0;
     private int total_pass = 0;
     private int total_fail = 0;
-    private int total_scenarios = 0;
+    private int total_querysets = 0;
+    private Set<String> failed_queries = new HashSet<String>(10);
+    private Set<String> query_sets = new HashSet<String>(10);
  
     private static PrintStream getSummaryStream(String outputDir,
 	    String summaryName) throws IOException {
@@ -165,24 +169,42 @@
 	return passFailGenMap;
     }
     
-    private void addTotalPassFailGen(Collection results) {
+    private void addTotalPassFailGen(String scenario_name, Collection results) {
+	int queries = 0;
+	int pass = 0;
+	int fail = 0;
+	
+	String queryset = null;
 
-	total_scenarios++;
+	total_querysets++;
 	for (Iterator resultsItr = results.iterator(); resultsItr.hasNext();) {
 	    TestResult stat = (TestResult) resultsItr.next();
-	    ++total_queries;
+	    
+	    if (queryset == null){
+		queryset = stat.getQuerySetID();
+	    }
+	    
+	    ++queries;
 	    switch (stat.getStatus()) {
 	    case TestResult.RESULT_STATE.TEST_EXCEPTION:
-		++total_fail;
+		++fail;
+		
+		this.failed_queries.add(stat.getQueryID());
 		break;
 	    case TestResult.RESULT_STATE.TEST_SUCCESS:
-		++total_pass;
+		++pass;
 		break;
 	    case TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION:
-		++total_pass;
+		++pass;
 		break;
 	    }
 	}
+	
+	this.query_sets.add("\t" + queryset + "\t\t" + pass + "\t" + fail + "\t" + queries);
+	
+	total_fail = total_fail + fail;
+	total_pass = total_pass + pass;
+	total_queries = total_queries + queries;
 
     }
 
@@ -214,7 +236,7 @@
 		//              logError("Unable to get output stream for file: " + outputFileName); //$NON-NLS-1$
 		throw e;
 	    }
-	    addTotalPassFailGen(testResults);
+	    addTotalPassFailGen(testname, testResults);
 	    // Text File output
 	    printQueryTestResults(outputStream, testStartTS, endTS,
 		    numberOfClients, TestClient.TSFORMAT, testResults);
@@ -295,13 +317,47 @@
 		outputStream.println("=================="); //$NON-NLS-1$
 		
 		outputStream
-		.println("Number of Scenarios: " + total_scenarios); //$NON-NLS-1$ //$NON-NLS-2$
+		.println("Number of Query Sets: " + total_querysets); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		outputStream.println("=================="); //$NON-NLS-1$
+		outputStream.println("Query Sets"); //$NON-NLS-1$
+		outputStream.println("\t" + "Name" + "\t\t" + "Pass" + "\t" + "Fail" + "\t" + "Total"); //$NON-NLS-1$
+
+		if (!this.query_sets.isEmpty()) {
+			
+			for (Iterator<String> it=this.query_sets.iterator(); it.hasNext();) {
+				outputStream
+				.println(it.next()); //$NON-NLS-1$ //$NON-NLS-2$
+		    
+			}
+
+		}	
+		outputStream.println("=================="); //$NON-NLS-1$
+		
+		
 		outputStream
-			.println("Number of Queries: " + total_queries); //$NON-NLS-1$ //$NON-NLS-2$
-		outputStream
-			.println("Number Passed    : " + total_pass); //$NON-NLS-1$ //$NON-NLS-2$
-		outputStream
-			.println("Number Failed    : " + total_fail); //$NON-NLS-1$ //$NON-NLS-2$
+		.println("\t" + "Totals" + "\t\t" + total_pass + "\t" + total_fail + "\t" + total_queries);
+		
+//		outputStream
+//			.println("Number of Queries: " + total_queries); //$NON-NLS-1$ //$NON-NLS-2$
+//		outputStream
+//			.println("Number Passed    : " + total_pass); //$NON-NLS-1$ //$NON-NLS-2$
+//		outputStream
+//			.println("Number Failed    : " + total_fail); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		if (!this.failed_queries.isEmpty()) {
+			outputStream.println("\n\n=================="); //$NON-NLS-1$
+			outputStream.println("Failed Queries"); //$NON-NLS-1$		    
+			
+			for (Iterator<String> it=this.failed_queries.iterator(); it.hasNext();) {
+				outputStream
+				.println("\t - " + it.next()); //$NON-NLS-1$ //$NON-NLS-2$
+		    
+			}
+				    
+			outputStream.println("=================="); //$NON-NLS-1$
+		    
+		}
 
 		    outputStream.close();
 



More information about the teiid-commits mailing list