Commit a0edb802 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Improved testing support for multi-clients.

Also added a few multi-client tests.

Change-Id: Ie78e100ce6f880a5055454fb77994de074e37440
parent 2b1eab1a
......@@ -246,6 +246,15 @@ ENDIF()
# Make these tests use reverse connection.
SET (CutMulti_REVERSE_CONNECT TRUE)
# Enable collaboration tests.
set (AnimatePipelineTime_ENABLE_COLLAB TRUE)
set (3DWidgetInCustomFilter_ENABLE_COLLAB TRUE)
set (CalcParens_ENABLE_COLLAB TRUE)
set (Calculator_ENABLE_COLLAB TRUE)
set (ColorEditor1_ENABLE_COLLAB TRUE)
set (Fractal2D_ENABLE_COLLAB TRUE)
add_client_tests("pv"
TEST_SCRIPTS ${TESTS_WITHOUT_BASELINES}
PARALLEL
......@@ -272,4 +281,8 @@ IF (PARAVIEW_DATA_ROOT)
# TODO: remote rendering tests and reverse connect tests.
add_multi_client_tests("pvcs-collab"
BASELINE_DIR ${PARAVIEW_DATA_ROOT}/Baseline
TEST_SCRIPTS ${TESTS_WITH_BASELINES})
ENDIF (PARAVIEW_DATA_ROOT)
......@@ -100,12 +100,41 @@ ENDFUNCTION (add_client_server_tests)
FUNCTION (add_client_render_server_tests prefix)
add_pv_test(${prefix} "_DISABLE_CRS"
COMMAND
--data-server ${PARAVIEW_DATA_SERVER_EXECUTABLE}
--render-server ${PARAVIEW_RENDER_SERVER_EXECUTABLE}
--client ${CLIENT_EXECUTABLE}
-dr
--disable-light-kit
--server=testserver-dsrs
--test-directory=${PARAVIEW_TEST_DIR}
${ARGN})
ENDFUNCTION (add_client_render_server_tests)
FUNCTION(add_multi_client_tests prefix)
PV_PARSE_ARGUMENTS(ACT "TEST_SCRIPTS;BASELINE_DIR" "PARALLEL" ${ARGN})
foreach (test_script ${ACT_TEST_SCRIPTS})
get_filename_component(test_name ${test_script} NAME_WE)
if (${test_name}_ENABLE_COLLAB)
set (extra_args)
process_args(extra_args)
add_test("${prefix}.${test_name}"
${PARAVIEW_SMTESTDRIVER_EXECUTABLE}
--test-multi-clients
--server ${PARAVIEW_SERVER_EXECUTABLE}
--client ${CLIENT_EXECUTABLE}
-dr
--disable-light-kit
--server=testserver
--test-directory=${PARAVIEW_TEST_DIR}
--test-script=${test_script}
--test-master
--exit
--client ${CLIENT_EXECUTABLE}
-dr
--disable-light-kit
--server=testserver
--test-directory=${PARAVIEW_TEST_DIR}
--test-slave
${extra_args}
--exit
)
endif()
endforeach(test_script)
ENDFUNCTION(add_multi_client_tests)
......@@ -216,7 +216,7 @@ int vtkSMTestDriver::ProcessCommandLine(int argc, char* argv[])
this->TestTiledDisplay = 1;
fprintf(stderr, "Test Tiled Display.\n");
}
if(strcmp(argv[i], "--test-multi-client") == 0)
if(strcmp(argv[i], "--test-multi-clients") == 0)
{
this->TestMultiClient = 1;
fprintf(stderr, "Test Tiled Display.\n");
......
......@@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqCommandLineOptionsBehavior.h"
#include "pqActiveObjects.h"
#include "pqCollaborationEventPlayer.h"
#include "pqComponentsTestUtility.h"
#include "pqCoreUtilities.h"
#include "pqDeleteReaction.h"
......@@ -172,6 +173,18 @@ void pqCommandLineOptionsBehavior::playTests()
{
this->resetApplication();
}
else if (cc==0)
{
if (options->GetTestMaster())
{
pqCollaborationEventPlayer::waitForConnections(2);
}
else if (options->GetTestSlave())
{
pqCollaborationEventPlayer::waitForMaster();
}
}
// Play the test script if specified.
pqTestUtility* testUtility = pqApplicationCore::instance()->testUtility();
......@@ -189,6 +202,11 @@ void pqCommandLineOptionsBehavior::playTests()
if (options->GetExitAppWhenTestsDone())
{
if (options->GetTestMaster())
{
pqCollaborationEventPlayer::wait(1000);
}
QApplication::instance()->exit(success? 0 : 1);
}
}
......
......@@ -49,38 +49,55 @@ pqCollaborationEventPlayer::~pqCollaborationEventPlayer()
{
}
//-----------------------------------------------------------------------------
void pqCollaborationEventPlayer::waitForMaster()
{
pqCollaborationManager* mgr = qobject_cast<pqCollaborationManager*>(
pqApplicationCore::instance()->manager("COLLABORATION_MANAGER"));
// this process should just wait patiently until it becomes the master.
while (mgr && !mgr->collaborationManager()->IsMaster())
{
pqEventDispatcher::processEventsAndWait(500);
}
}
//-----------------------------------------------------------------------------
void pqCollaborationEventPlayer::waitForConnections(int num_connections)
{
pqCollaborationManager* mgr = qobject_cast<pqCollaborationManager*>(
pqApplicationCore::instance()->manager("COLLABORATION_MANAGER"));
// this process should just wait patiently until it becomes the master.
while (mgr && mgr->collaborationManager()->GetNumberOfConnectedClients() <
num_connections)
{
pqEventDispatcher::processEventsAndWait(500);
}
pqEventDispatcher::processEventsAndWait(1000);
}
//-----------------------------------------------------------------------------
void pqCollaborationEventPlayer::wait(int ms)
{
pqEventDispatcher::processEventsAndWait(ms);
}
//-----------------------------------------------------------------------------
bool pqCollaborationEventPlayer::playEvent(QObject* ,
const QString& command, const QString& arguments, bool& error)
{
pqCollaborationManager* mgr =
qobject_cast<pqCollaborationManager*>(
pqApplicationCore::instance()->manager("COLLABORATION_MANAGER"));
if (mgr && command == "waitForMaster")
if (command == "waitForMaster")
{
cout << "waitForMaster" << endl;
// this process should just wait patiently until it becomes the master.
while (!mgr->collaborationManager()->IsMaster())
{
pqEventDispatcher::processEventsAndWait(500);
}
cout << "Done" << endl;
pqCollaborationEventPlayer::waitForMaster();
return true;
}
else if (mgr && command == "waitForConnections")
else if (command == "waitForConnections")
{
cout << "waitForConnections" << endl;
// this process should just wait patiently until it becomes the master.
while (mgr->collaborationManager()->GetNumberOfConnectedClients() < 2)
{
pqEventDispatcher::processEventsAndWait(500);
}
cout << "Done" << endl;
pqCollaborationEventPlayer::waitForConnections(2);
return true;
}
else if (command == "wait")
{
pqEventDispatcher::processEventsAndWait(1000);
pqCollaborationEventPlayer::wait(1000);
return true;
}
return false;
......
......@@ -51,6 +51,13 @@ public:
const QString& command,
const QString& arguments, bool& error);
/// used to wait till the process becomes a master.
static void waitForMaster();
/// used to wait until there are num_connection connections.
static void waitForConnections(int num_connections);
static void wait(int milli_seconds);
private:
Q_DISABLE_COPY(pqCollaborationEventPlayer)
};
......
......@@ -79,6 +79,8 @@ pqOptions::pqOptions()
this->DisableLightKit = 0;
this->CurrentImageThreshold = 12;
this->PythonScript = 0;
this->TestMaster = 0;
this->TestSlave = 0;
}
//-----------------------------------------------------------------------------
......@@ -133,6 +135,14 @@ void pqOptions::Initialize()
this->AddArgument("--script", NULL,
&this->PythonScript,
"Set a python script to be evaluated on startup.");
this->AddBooleanArgument("--test-master", 0,
&this->TestMaster,
"(For testing) When present, tests master configuration.");
this->AddBooleanArgument("--test-slave", 0,
&this->TestSlave,
"(For testing) When present, tests slave configuration.");
}
//-----------------------------------------------------------------------------
......
......@@ -87,6 +87,11 @@ public:
vtkGetMacro(DisableLightKit, int);
vtkSetMacro(DisableLightKit, int);
// Description:
// These flags are used for testing multi-clients configurations.
vtkGetMacro(TestMaster, int);
vtkGetMacro(TestSlave, int);
// Description:
// Using --script option, user can specify a python script to be run on
// startup. This have any effect only when ParaView is built with Python
......@@ -112,6 +117,8 @@ protected:
int DisableRegistry;
int DisableLightKit;
int CurrentImageThreshold;
int TestMaster;
int TestSlave;
char* PythonScript;
vtkSetStringMacro(PythonScript);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment