Correct cancelling behavior
This commit is contained in:
parent
b42570be14
commit
dc38797ee7
|
@ -40,6 +40,8 @@ namespace CodexNetDeployer
|
||||||
var tokenAddress = gethResult.MarketplaceNetwork.Marketplace.TokenAddress;
|
var tokenAddress = gethResult.MarketplaceNetwork.Marketplace.TokenAddress;
|
||||||
var marketAccess = new MarketplaceAccess(lifecycle, gethResult.MarketplaceNetwork, account, codexAccess);
|
var marketAccess = new MarketplaceAccess(lifecycle, gethResult.MarketplaceNetwork, account, codexAccess);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var debugInfo = codexAccess.Node.GetDebugInfo();
|
var debugInfo = codexAccess.Node.GetDebugInfo();
|
||||||
if (!string.IsNullOrWhiteSpace(debugInfo.spr))
|
if (!string.IsNullOrWhiteSpace(debugInfo.spr))
|
||||||
{
|
{
|
||||||
|
@ -64,8 +66,15 @@ namespace CodexNetDeployer
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exception:" + ex.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.Write("Unknown failure. Downloading container log." + Environment.NewLine);
|
||||||
|
lifecycle.DownloadLog(container);
|
||||||
|
|
||||||
Console.Write("Unknown failure." + Environment.NewLine);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace ContinuousTests
|
||||||
public IFileManager FileManager { get; private set; } = null!;
|
public IFileManager FileManager { get; private set; } = null!;
|
||||||
public Configuration Configuration { get; private set; } = null!;
|
public Configuration Configuration { get; private set; } = null!;
|
||||||
public virtual ITimeSet TimeSet { get { return new DefaultTimeSet(); } }
|
public virtual ITimeSet TimeSet { get { return new DefaultTimeSet(); } }
|
||||||
public CancellationToken CancelToken { get; private set; } = null;
|
public CancellationToken CancelToken { get; private set; } = new CancellationToken();
|
||||||
public NodeRunner NodeRunner { get; private set; } = null!;
|
public NodeRunner NodeRunner { get; private set; } = null!;
|
||||||
|
|
||||||
public abstract int RequiredNumberOfNodes { get; }
|
public abstract int RequiredNumberOfNodes { get; }
|
||||||
|
|
|
@ -34,17 +34,18 @@ namespace ContinuousTests
|
||||||
|
|
||||||
foreach (var testLoop in testLoops)
|
foreach (var testLoop in testLoops)
|
||||||
{
|
{
|
||||||
cancelToken.ThrowIfCancellationRequested();
|
if (cancelToken.IsCancellationRequested) break;
|
||||||
|
|
||||||
overviewLog.Log("Launching test-loop for " + testLoop.Name);
|
overviewLog.Log("Launching test-loop for " + testLoop.Name);
|
||||||
testLoop.Begin();
|
testLoop.Begin();
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(15));
|
Thread.Sleep(TimeSpan.FromSeconds(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
overviewLog.Log("All test-loops launched.");
|
overviewLog.Log("Finished launching test-loops.");
|
||||||
cancelToken.WaitHandle.WaitOne();
|
cancelToken.WaitHandle.WaitOne();
|
||||||
overviewLog.Log("Cancelling all test-loops...");
|
overviewLog.Log("Cancelling all test-loops...");
|
||||||
taskFactory.WaitAll();
|
taskFactory.WaitAll();
|
||||||
|
overviewLog.Log("All tasks cancelled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearAllCustomNamespaces(ContinuousTest[] allTests, FixtureLog log)
|
private void ClearAllCustomNamespaces(ContinuousTest[] allTests, FixtureLog log)
|
||||||
|
|
|
@ -65,28 +65,32 @@ namespace ContinuousTests.Tests
|
||||||
{
|
{
|
||||||
var lastState = "";
|
var lastState = "";
|
||||||
var waitStart = DateTime.UtcNow;
|
var waitStart = DateTime.UtcNow;
|
||||||
var filesizeInMb = fileSize.SizeInBytes / 1024;
|
var filesizeInMb = fileSize.SizeInBytes / (1024 * 1024);
|
||||||
var maxWaitTime = TimeSpan.FromSeconds(filesizeInMb * 10.0);
|
var maxWaitTime = TimeSpan.FromSeconds(filesizeInMb * 10.0);
|
||||||
|
|
||||||
Log.Log(nameof(WaitForContractToStart) + " for " + Time.FormatDuration(maxWaitTime));
|
Log.Log($"{nameof(WaitForContractToStart)} for {Time.FormatDuration(maxWaitTime)}");
|
||||||
while (lastState != "started")
|
while (lastState != "started")
|
||||||
{
|
{
|
||||||
|
CancelToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var purchaseStatus = codexAccess.Node.GetPurchaseStatus(purchaseId);
|
var purchaseStatus = codexAccess.Node.GetPurchaseStatus(purchaseId);
|
||||||
|
var statusJson = JsonConvert.SerializeObject(purchaseStatus);
|
||||||
if (purchaseStatus != null && purchaseStatus.state != lastState)
|
if (purchaseStatus != null && purchaseStatus.state != lastState)
|
||||||
{
|
{
|
||||||
lastState = purchaseStatus.state;
|
lastState = purchaseStatus.state;
|
||||||
|
Log.Log("Purchase status: " + statusJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
|
|
||||||
if (lastState == "errored")
|
if (lastState == "errored")
|
||||||
{
|
{
|
||||||
Assert.Fail("Contract start failed: " + JsonConvert.SerializeObject(purchaseStatus));
|
Assert.Fail("Contract start failed: " + statusJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DateTime.UtcNow - waitStart > maxWaitTime)
|
if (DateTime.UtcNow - waitStart > maxWaitTime)
|
||||||
{
|
{
|
||||||
Assert.Fail($"Contract was not picked up within {maxWaitTime.TotalSeconds} seconds timeout: " + JsonConvert.SerializeObject(purchaseStatus));
|
Assert.Fail($"Contract was not picked up within {maxWaitTime.TotalSeconds} seconds timeout: {statusJson}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.Log("Contract started.");
|
Log.Log("Contract started.");
|
||||||
|
|
Loading…
Reference in New Issue