Skip to content

Commit

Permalink
ICE-6767 Better handling of server start failure by test controller
Browse files Browse the repository at this point in the history
  • Loading branch information
dgboone committed Oct 1, 2015
1 parent 493f604 commit 36a9c67
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cpp/test/TestSuite/10.0/Package.appxmanifest
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Identity Name="f4c6cdff-3ef9-43fb-8094-d50c547e70f6" Publisher="CN=jose" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="f4c6cdff-3ef9-43fb-8094-d50c547e70f6" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>TestSuite</DisplayName>
<DisplayName>Ice Test Suite</DisplayName>
<PublisherDisplayName>jose</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
Expand All @@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="TestSuite.App">
<uap:VisualElements DisplayName="TestSuite" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="TestSuite" BackgroundColor="transparent">
<uap:VisualElements DisplayName="Ice Test Suite" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="TestSuite" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
Expand Down
10 changes: 7 additions & 3 deletions cpp/test/TestSuite/Controller.ice
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ module Test
module Common
{

exception ServerFailedException
{
string reason;
};

interface Server
{
void waitTestSuccess();
void waitForServer();
void waitForServer() throws ServerFailedException;
void terminate();
};

sequence<string> StringSeq;

interface Controller
{
Server* runServer(string lang, string name, string protocol, string host, bool winrt,
StringSeq options);
Server* runServer(string lang, string name, string protocol, string host, bool winrt, StringSeq options);
};

};
Expand Down
4 changes: 4 additions & 0 deletions cpp/test/TestSuite/MainPage.xaml.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ TestRunner::run()
{
_page->failed(ex->Message);
}
catch (Test::Common::ServerFailedException& ex)
{
_page->failed(ref new String(IceUtil::stringToWstring("Server failed to start:\n\n" + ex.reason).c_str()));
}
catch(const std::exception& ex)
{
_page->failed(ref new String(IceUtil::stringToWstring(ex.what()).c_str()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ServerI extends _ServerDisp
public ServerI(Process process, String name)
{
_process = process;
_processOutput = new StringBuffer();
_name = name;
_started = 0;
_terminated = false;
Expand All @@ -46,6 +47,11 @@ public void run()
String line = null;
while((line = reader.readLine()) != null)
{
if(_started == 0)
{
_processOutput.append(line + "\n");
}

if(line.matches(Pattern.quote("starting server...") + ".*ok") ||
line.matches(Pattern.quote("starting serveramd...") + ".*ok") ||
line.matches(Pattern.quote("starting servertie...") + ".*ok") ||
Expand Down Expand Up @@ -137,6 +143,7 @@ public void waitTestSuccess(Ice.Current current)
}

public synchronized void waitForServer(Ice.Current current)
throws ServerFailedException
{
while(!_terminated)
{
Expand All @@ -156,12 +163,12 @@ public synchronized void waitForServer(Ice.Current current)
}
if(_terminated && _started == 0)
{
// TODO: Add user exception instead of throwing a local exception.
throw new RuntimeException("process failed to start");
throw new ServerFailedException(_processOutput.toString());
}
}

private Process _process;
private StringBuffer _processOutput;
private String _name;
private int _started;
private boolean _terminated;
Expand Down
10 changes: 7 additions & 3 deletions java/test/controller/src/main/slice/Controller.ice
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ module Test
module Common
{

exception ServerFailedException
{
string reason;
};

interface Server
{
void waitTestSuccess();
void waitForServer();
void waitForServer() throws ServerFailedException;
void terminate();
};

sequence<string> StringSeq;

interface Controller
{
Server* runServer(string lang, string name, string protocol, string host, bool winrt,
StringSeq options);
Server* runServer(string lang, string name, string protocol, string host, bool winrt, StringSeq options);
};

};
Expand Down
10 changes: 7 additions & 3 deletions js/test/Common/Controller.ice
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ module Test
module Common
{

exception ServerFailedException
{
string reason;
};

interface Server
{
void waitTestSuccess();
void waitForServer();
void waitForServer() throws ServerFailedException;
void terminate();
};

sequence<string> StringSeq;

interface Controller
{
Server* runServer(string lang, string name, string protocol, string host, bool winrt,
StringSeq options);
Server* runServer(string lang, string name, string protocol, string host, bool winrt, StringSeq options);
};

};
Expand Down
19 changes: 14 additions & 5 deletions js/test/Common/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function isSafari()

function isWorker()
{
return typeof(WorkerGlobalScope) !== 'undefined' && this instanceof WorkerGlobalScope;
return typeof(WorkerGlobalScope) !== 'undefined' && this instanceof WorkerGlobalScope;
}

function runTest(name, language, defaultHost, protocol, configurations, out)
Expand Down Expand Up @@ -86,7 +86,8 @@ function runTest(name, language, defaultHost, protocol, configurations, out)
var initData = id.clone();
if(configuration.args !== undefined)
{
initData.properties = Ice.createProperties(configuration.args, id.properties);
initData.properties =
Ice.createProperties(configuration.args, id.properties);
}
return __test__(out, initData);
});
Expand Down Expand Up @@ -154,10 +155,18 @@ function runTest(name, language, defaultHost, protocol, configurations, out)
{
out.writeLine("exception occurred in call to " + r.operation);
}
out.writeLine(ex.toString());
if(ex.stack)
if(ex instanceof Test.Common.ServerFailedException)
{
out.writeLine(ex.stack);
out.writeLine("Server failed to start:\n");
out.writeLine(ex.reason);
}
else
{
out.writeLine(ex.toString());
if(ex.stack)
{
out.writeLine(ex.stack);
}
}
return false;
});
Expand Down

0 comments on commit 36a9c67

Please sign in to comment.