diff --git a/CodexNetDeployer/CodexNodeStarter.cs b/CodexNetDeployer/CodexNodeStarter.cs index 7c33892..898afb6 100644 --- a/CodexNetDeployer/CodexNodeStarter.cs +++ b/CodexNetDeployer/CodexNodeStarter.cs @@ -40,32 +40,41 @@ namespace CodexNetDeployer var tokenAddress = gethResult.MarketplaceNetwork.Marketplace.TokenAddress; var marketAccess = new MarketplaceAccess(lifecycle, gethResult.MarketplaceNetwork, account, codexAccess); - var debugInfo = codexAccess.Node.GetDebugInfo(); - if (!string.IsNullOrWhiteSpace(debugInfo.spr)) + try { - Console.Write("Online\t"); - - var interaction = gethResult.MarketplaceNetwork.Bootstrap.StartInteraction(lifecycle); - interaction.MintTestTokens(new[] { account.Account }, config.InitialTestTokens, tokenAddress); - Console.Write("Tokens minted\t"); - - var response = marketAccess.MakeStorageAvailable( - totalSpace: (config.StorageQuota!.Value - 1).MB(), - minPriceForTotalSpace: config.MinPrice.TestTokens(), - maxCollateral: config.MaxCollateral.TestTokens(), - maxDuration: TimeSpan.FromSeconds(config.MaxDuration)); - - if (!string.IsNullOrEmpty(response)) + var debugInfo = codexAccess.Node.GetDebugInfo(); + if (!string.IsNullOrWhiteSpace(debugInfo.spr)) { - Console.Write("Storage available\tOK" + Environment.NewLine); + Console.Write("Online\t"); - if (string.IsNullOrEmpty(bootstrapSpr)) bootstrapSpr = debugInfo.spr; - validatorsLeft--; - return container; + var interaction = gethResult.MarketplaceNetwork.Bootstrap.StartInteraction(lifecycle); + interaction.MintTestTokens(new[] { account.Account }, config.InitialTestTokens, tokenAddress); + Console.Write("Tokens minted\t"); + + var response = marketAccess.MakeStorageAvailable( + totalSpace: (config.StorageQuota!.Value - 1).MB(), + minPriceForTotalSpace: config.MinPrice.TestTokens(), + maxCollateral: config.MaxCollateral.TestTokens(), + maxDuration: TimeSpan.FromSeconds(config.MaxDuration)); + + if (!string.IsNullOrEmpty(response)) + { + Console.Write("Storage available\tOK" + Environment.NewLine); + + if (string.IsNullOrEmpty(bootstrapSpr)) bootstrapSpr = debugInfo.spr; + validatorsLeft--; + 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; } diff --git a/ContinuousTests/ContinuousTest.cs b/ContinuousTests/ContinuousTest.cs index 8d3deb8..8bfdf1e 100644 --- a/ContinuousTests/ContinuousTest.cs +++ b/ContinuousTests/ContinuousTest.cs @@ -44,7 +44,7 @@ namespace ContinuousTests public IFileManager FileManager { get; private set; } = null!; public Configuration Configuration { get; private set; } = null!; 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 abstract int RequiredNumberOfNodes { get; } diff --git a/ContinuousTests/ContinuousTestRunner.cs b/ContinuousTests/ContinuousTestRunner.cs index a6dcfda..a0f15ab 100644 --- a/ContinuousTests/ContinuousTestRunner.cs +++ b/ContinuousTests/ContinuousTestRunner.cs @@ -34,17 +34,18 @@ namespace ContinuousTests foreach (var testLoop in testLoops) { - cancelToken.ThrowIfCancellationRequested(); + if (cancelToken.IsCancellationRequested) break; overviewLog.Log("Launching test-loop for " + testLoop.Name); testLoop.Begin(); Thread.Sleep(TimeSpan.FromSeconds(15)); } - overviewLog.Log("All test-loops launched."); + overviewLog.Log("Finished launching test-loops."); cancelToken.WaitHandle.WaitOne(); overviewLog.Log("Cancelling all test-loops..."); taskFactory.WaitAll(); + overviewLog.Log("All tasks cancelled."); } private void ClearAllCustomNamespaces(ContinuousTest[] allTests, FixtureLog log) diff --git a/ContinuousTests/Tests/MarketplaceTest.cs b/ContinuousTests/Tests/MarketplaceTest.cs index 9582b66..02c3dcc 100644 --- a/ContinuousTests/Tests/MarketplaceTest.cs +++ b/ContinuousTests/Tests/MarketplaceTest.cs @@ -65,28 +65,32 @@ namespace ContinuousTests.Tests { var lastState = ""; var waitStart = DateTime.UtcNow; - var filesizeInMb = fileSize.SizeInBytes / 1024; + var filesizeInMb = fileSize.SizeInBytes / (1024 * 1024); 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") { + CancelToken.ThrowIfCancellationRequested(); + var purchaseStatus = codexAccess.Node.GetPurchaseStatus(purchaseId); + var statusJson = JsonConvert.SerializeObject(purchaseStatus); if (purchaseStatus != null && purchaseStatus.state != lastState) { lastState = purchaseStatus.state; + Log.Log("Purchase status: " + statusJson); } Thread.Sleep(2000); if (lastState == "errored") { - Assert.Fail("Contract start failed: " + JsonConvert.SerializeObject(purchaseStatus)); + Assert.Fail("Contract start failed: " + statusJson); } 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.");