Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added automated test for ODBC FailOver functionality #1371

Merged
merged 8 commits into from
Jul 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions core/src/test/scala/io/snappydata/util/ODBCDriverTestSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

package io.snappydata
import java.io._

import scala.language.{implicitConversions, postfixOps}
import scala.sys.process._


class ODBCDriverTestSuite extends SnappyTestRunner {
val snappyProductDir = System.getenv("SNAPPY_HOME")
val snappyNativeTestDir = s"$snappyProductDir/../../../store/native/tests"

test("ODBC_FailOverTest_NEWSERVER"){
try {
var scriptPath = s"$snappyNativeTestDir/failoverTest_NewServer.sh"
var consoleOutput = s"$scriptPath $snappyProductDir $snappyNativeTestDir".!!
assert(consoleOutput.contains("Test executed successfully"),
s"FailOver failed $consoleOutput")
} finally {

}
}

test("ODBC_FailOverTest_NONE"){
try {
var scriptPath = s"$snappyNativeTestDir/failoverTest_None.sh"
var consoleOutput = s"$scriptPath $snappyProductDir $snappyNativeTestDir".!!
assert(consoleOutput.contains("Test executed successfully, no failover tried"),
s"There failover tried but failed $consoleOutput")
} finally {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ public class SnappyPrms extends BasePrms {
*/
public static Long isUserConfTest;

/**
* (boolean) - whether to run the CPP script in hydra.
*/
public static Long isCppTest;

/**
* (boolean) - whether TPCH schema is used in test for running the queries concurrently.
*/
Expand Down
17 changes: 12 additions & 5 deletions dtests/src/test/java/io/snappydata/hydra/cluster/SnappyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class SnappyTest implements Serializable {
private static String simulateStreamScriptDestinationFolder = TestConfig.tab().stringAt(SnappyPrms.simulateStreamScriptDestinationFolder, dtests);
public static boolean isLongRunningTest = TestConfig.tab().booleanAt(SnappyPrms.isLongRunningTest, false); //default to false
public static boolean isUserConfTest = TestConfig.tab().booleanAt(SnappyPrms.isUserConfTest, false); //default to false
public static boolean isCppTest = TestConfig.tab().booleanAt(SnappyPrms.isCppTest, false); //default to false
bisenpiyush marked this conversation as resolved.
Show resolved Hide resolved
public static boolean useRowStore = TestConfig.tab().booleanAt(SnappyPrms.useRowStore, false); //default to false
public static boolean isRestarted = false;
public static boolean useSmartConnectorMode = TestConfig.tab().booleanAt(SnappyPrms.useSmartConnectorMode, false); //default to false
Expand Down Expand Up @@ -1760,7 +1761,14 @@ public static synchronized void HydraTask_executeScripts() {
RemoteTestModule.getCurrentThread().getThreadId() + ".log";
logFile = new File(dest);
String comma_separated_args_list = StringUtils.join(SnappyPrms.getScriptArgs(), " ");
String command = filePath + " " + comma_separated_args_list;
String command = null;
if (isCppTest) {

String primaryLocatorHost = getPrimaryLocatorHost();
String primaryLocatorPort = getPrimaryLocatorPort();
Log.getLogWriter().info("inside cpp test: " + primaryLocatorHost + primaryLocatorPort);
command = filePath + " " + comma_separated_args_list + " " + primaryLocatorHost + " " + primaryLocatorPort;
} else command = filePath + " " + comma_separated_args_list;
ProcessBuilder pb = new ProcessBuilder("/bin/bash", "-c", command);
snappyTest.executeProcess(pb, logFile);
}
Expand Down Expand Up @@ -2172,7 +2180,7 @@ protected String getPrimaryLeadHost() {
retrievePrimaryLeadHost();
leadHost = (String) SnappyBB.getBB().getSharedMap().get("primaryLeadHost");
Log.getLogWriter().info("primaryLead Host is: " + leadHost);
} else leadHost = (String) SnappyBB.getBB().getSharedMap().get("primaryLeadHost");
} else leadHost = (String) SnappyBB.getBB().getSharedMap().get("primaryLeadHost");
return leadHost;
}

Expand Down Expand Up @@ -2489,7 +2497,7 @@ public boolean getSnappyJobsStatus(String snappyJobScript, File logFile, String
jobIds.add(jobID);
}
}
if(jobIds==null) {
if (jobIds == null) {
Log.getLogWriter().info("Failed to start the snappy job.");
return true;
}
Expand Down Expand Up @@ -2985,8 +2993,7 @@ public static synchronized void HydraTask_cycleLeadVM() {
}
}

protected void
cycleVM(int numToKill, int stopStartVMs, String cycledVM, Long lastCycledTimeFromBB, long
protected void cycleVM(int numToKill, int stopStartVMs, String cycledVM, Long lastCycledTimeFromBB, long
lastCycledTime, String vmName, boolean isDmlOp, boolean restart, boolean rebalance) {
if (!cycleVms) {
Log.getLogWriter().warning("cycleVms sets to false, no node will be brought down in the test run");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
io.snappydata.hydra.cluster.SnappyPrms-serverLauncherProps = " -heap-size=4g -memory-size=8g ";
//io.snappydata.hydra.cluster.SnappyPrms-serverLauncherProps += " -J-Dgemfire.VersionVector.VERBOSE=true -J-Dgemfirexd.debug.true=TraceTran,TraceQuery ";

io.snappydata.hydra.cluster.SnappyPrms-executorMemory = 4g;
io.snappydata.hydra.cluster.SnappyPrms-leadMemory = 4g;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
io/snappydata/hydra/rowTableCPP/rowTableCPPTest.conf
A=snappyStore snappyStoreHosts=1 snappyStoreVMsPerHost=1 snappyStoreThreadsPerVM=4
B=lead leadHosts=1 leadVMsPerHost=1 leadThreadsPerVM=4
C=locator locatorHosts=1 locatorVMsPerHost=1 locatorThreadsPerVM=1
persistenceMode="sync" redundantCopies=1
dataFilesLocation="$GEMFIRE/../../../tests/common/src/main/resources/northwind/"
scriptLocation="$GEMFIRE/../../../store/native/tests/failoverTest_Retry.sh"
tableType="PartitionedRow"
timeduration=60
scriptPWD="$GEMFIRE/../../../store/native/tests/"
numVMsToStop=1

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// INCLUDE $JTESTS/io/snappydata/hydra/connectionPool/connPool.inc;

INCLUDE $JTESTS/io/snappydata/hydra/northwind/startEmbeddedModeCluster.conf;
INCLUDE $JTESTS/io/snappydata/hydra/northwind/stopEmbeddedModeCluster.conf;
INCLUDE $JTESTS/io/snappydata/hydra/rowTableCPP/serverHA.inc;
INCLUDE $JTESTS/io/snappydata/hydra/northwind/backUpServerConfig.inc;

INITTASK taskClass = io.snappydata.hydra.cluster.SnappyTest taskMethod = HydraTask_executeSQLScripts
io.snappydata.hydra.cluster.SnappyPrms-sqlScriptNames = create_and_load_partitionedRowTables_persistent.sql
io.snappydata.hydra.cluster.SnappyPrms-dataLocation = ${dataFilesLocation}
threadGroups = snappyThreads
;

TASK taskClass = io.snappydata.hydra.cluster.SnappyTest taskMethod = HydraTask_executeScripts
io.snappydata.hydra.cluster.SnappyPrms-scriptNames = ${scriptLocation}
io.snappydata.hydra.cluster.SnappyPrms-scriptArgs = ${timeduration},${scriptPWD}
threadGroups = snappyStoreThreads
maxThreads = 1
;

hydra.Prms-totalTaskTimeSec = 900;
hydra.Prms-maxResultWaitSec = 1200;
io.snappydata.hydra.cluster.SnappyPrms-isCppTest = true;
/*

bisenpiyush marked this conversation as resolved.
Show resolved Hide resolved
connectionPool.SnappyConnectionPoolPrms-connectionProperties = "route-query=false";*/
19 changes: 19 additions & 0 deletions dtests/src/test/java/io/snappydata/hydra/rowTableCPP/serverHA.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
io.snappydata.hydra.cluster.SnappyPrms-waitTimeBeforeNextCycleVM = 120; //how long to wait before

io.snappydata.hydra.cluster.SnappyPrms-cycleVms = true;

util.StopStartPrms-stopModes = NICE_KILL;
util.StopStartPrms-numVMsToStop = RANGE 1 ${numVMsToStop} EGNAR;

INITTASK taskClass = util.StopStartVMs taskMethod = StopStart_initTask
threadGroups = snappyThreads, locatorThreads, snappyStoreThreads, leadThreads;

TASK taskClass = io.snappydata.hydra.cluster.SnappyTest taskMethod = HydraTask_cycleStoreVms
maxThreads = 1
startInterval = 60
threadGroups = snappyThreads
maxTimesToRun = 5
;

CLOSETASK taskClass = io.snappydata.hydra.cluster.SnappyTest taskMethod = restoreServerConfigData
threadGroups = snappyThreads;