Running two client test
This commit is contained in:
parent
9a9c740e1c
commit
40b4d8aba3
@ -36,25 +36,22 @@ namespace ContinuousTests
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
var logPath = "logs";// Environment.GetEnvironmentVariable("LOGPATH");
|
var logPath = Environment.GetEnvironmentVariable("LOGPATH");
|
||||||
var codexDeploymentJson = "C:\\Users\\Ben\\Desktop\\codex-deployment.json"; //Environment.GetEnvironmentVariable("CODEXDEPLOYMENT");
|
var dataPath = Environment.GetEnvironmentVariable("DATAPATH");
|
||||||
var sleepPerSingle = "10";// Environment.GetEnvironmentVariable("SLEEPSECONDSPERSINGLETEST");
|
var codexDeploymentJson = Environment.GetEnvironmentVariable("CODEXDEPLOYMENT");
|
||||||
var sleepPerAll = "10";// Environment.GetEnvironmentVariable("SLEEPSECONDSPERALLTESTS");
|
var keep = Environment.GetEnvironmentVariable("KEEPPASSEDTESTLOGS");
|
||||||
var keep = ""; // Environment.GetEnvironmentVariable("KEEPPASSEDTESTLOGS");
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(logPath) &&
|
if (!string.IsNullOrEmpty(logPath) &&
|
||||||
!string.IsNullOrEmpty(codexDeploymentJson) &&
|
!string.IsNullOrEmpty(dataPath) &&
|
||||||
!string.IsNullOrEmpty(sleepPerSingle) &&
|
!string.IsNullOrEmpty(codexDeploymentJson))
|
||||||
!string.IsNullOrEmpty(sleepPerAll))
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new Configuration
|
return new Configuration
|
||||||
{
|
{
|
||||||
LogPath = logPath,
|
LogPath = logPath,
|
||||||
|
DataPath = dataPath,
|
||||||
CodexDeployment = ParseCodexDeploymentJson(codexDeploymentJson),
|
CodexDeployment = ParseCodexDeploymentJson(codexDeploymentJson),
|
||||||
//SleepSecondsPerSingleTest = Convert.ToInt32(sleepPerSingle),
|
|
||||||
//SleepSecondsPerAllTests = Convert.ToInt32(sleepPerAll),
|
|
||||||
KeepPassedTestLogs = keep == "1"
|
KeepPassedTestLogs = keep == "1"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -68,29 +65,21 @@ namespace ContinuousTests
|
|||||||
throw new Exception($"Unable to load configuration from '{filename}', and " +
|
throw new Exception($"Unable to load configuration from '{filename}', and " +
|
||||||
"unable to load configuration from environment variables. " + nl +
|
"unable to load configuration from environment variables. " + nl +
|
||||||
"'LOGPATH' = Path where log files will be saved." + nl +
|
"'LOGPATH' = Path where log files will be saved." + nl +
|
||||||
|
"'DATAPATH' = Path where temporary data files will be saved." + nl +
|
||||||
"'CODEXDEPLOYMENT' = Path to codex-deployment JSON file." + nl +
|
"'CODEXDEPLOYMENT' = Path to codex-deployment JSON file." + nl +
|
||||||
"'SLEEPSECONDSPERSINGLETEST' = Seconds to sleep after each individual test." + nl +
|
|
||||||
"'SLEEPSECONDSPERALLTESTS' = Seconds to sleep after all tests, before starting again." + nl +
|
|
||||||
"'KEEPPASSEDTESTLOGS' = (Optional, default: 0) Set to '1' to keep log files of tests that passed." + nl +
|
|
||||||
nl);
|
nl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Validate(Configuration configuration)
|
private void Validate(Configuration configuration)
|
||||||
{
|
{
|
||||||
//if (configuration.SleepSecondsPerSingleTest < 1)
|
|
||||||
//{
|
|
||||||
// Console.WriteLine("Warning: configuration.SleepSecondsPerSingleTest was less than 1 seconds. Using 1 seconds instead!");
|
|
||||||
// configuration.SleepSecondsPerSingleTest = 1;
|
|
||||||
//}
|
|
||||||
//if (configuration.SleepSecondsPerAllTests < 1)
|
|
||||||
//{
|
|
||||||
// Console.WriteLine("Warning: configuration.SleepSecondsPerAllTests was less than 10 seconds. Using 10 seconds instead!");
|
|
||||||
// configuration.SleepSecondsPerAllTests = 10;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(configuration.LogPath))
|
if (string.IsNullOrEmpty(configuration.LogPath))
|
||||||
{
|
{
|
||||||
throw new Exception($"Unvalid logpath set: '{configuration.LogPath}'");
|
throw new Exception($"Invalid LogPath set: '{configuration.LogPath}'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(configuration.DataPath))
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid DataPath set: '{configuration.DataPath}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configuration.CodexDeployment == null || !configuration.CodexDeployment.CodexContainers.Any())
|
if (configuration.CodexDeployment == null || !configuration.CodexDeployment.CodexContainers.Any())
|
||||||
|
@ -12,7 +12,9 @@ namespace ContinuousTests
|
|||||||
public abstract class ContinuousTest
|
public abstract class ContinuousTest
|
||||||
{
|
{
|
||||||
protected const int Zero = 0;
|
protected const int Zero = 0;
|
||||||
protected const int HourOne = 3600;
|
protected const int MinuteOne = 60;
|
||||||
|
protected const int MinuteFive = MinuteOne * 5;
|
||||||
|
protected const int HourOne = MinuteOne * 60;
|
||||||
protected const int DayOne = HourOne * 24;
|
protected const int DayOne = HourOne * 24;
|
||||||
protected const int DayThree = DayOne * 3;
|
protected const int DayThree = DayOne * 3;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
t.Begin();
|
t.Begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(TimeSpan.MaxValue);
|
while (true) Thread.Sleep((2 ^ 31) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ namespace ContinuousTests
|
|||||||
private readonly CodexNode[] nodes;
|
private readonly CodexNode[] nodes;
|
||||||
private readonly FileManager fileManager;
|
private readonly FileManager fileManager;
|
||||||
private readonly FixtureLog fixtureLog;
|
private readonly FixtureLog fixtureLog;
|
||||||
|
private readonly string dataFolder;
|
||||||
|
|
||||||
public SingleTestRun(Configuration config, TestHandle handle)
|
public SingleTestRun(Configuration config, TestHandle handle)
|
||||||
{
|
{
|
||||||
@ -25,6 +26,7 @@ namespace ContinuousTests
|
|||||||
fixtureLog = new FixtureLog(new LogConfig(config.LogPath, false), testName);
|
fixtureLog = new FixtureLog(new LogConfig(config.LogPath, false), testName);
|
||||||
|
|
||||||
nodes = CreateRandomNodes(handle.Test.RequiredNumberOfNodes);
|
nodes = CreateRandomNodes(handle.Test.RequiredNumberOfNodes);
|
||||||
|
dataFolder = config.DataPath + "-" + Guid.NewGuid();
|
||||||
fileManager = new FileManager(fixtureLog, CreateFileManagerConfiguration());
|
fileManager = new FileManager(fixtureLog, CreateFileManagerConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,16 +46,16 @@ namespace ContinuousTests
|
|||||||
fixtureLog.MarkAsFailed();
|
fixtureLog.MarkAsFailed();
|
||||||
}
|
}
|
||||||
fileManager.DeleteAllTestFiles();
|
fileManager.DeleteAllTestFiles();
|
||||||
|
Directory.Delete(dataFolder, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunTest()
|
private void RunTest()
|
||||||
{
|
{
|
||||||
var earliestMoment = handle.GetEarliestMoment();
|
var earliestMoment = handle.GetEarliestMoment();
|
||||||
var lastMoment = handle.GetLastMoment();
|
|
||||||
|
|
||||||
var t = earliestMoment;
|
var t = earliestMoment;
|
||||||
while (t <= lastMoment)
|
while (true)
|
||||||
{
|
{
|
||||||
RunMoment(t);
|
RunMoment(t);
|
||||||
|
|
||||||
@ -72,11 +74,15 @@ namespace ContinuousTests
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log(" > Completed last test moment. Test ended.");
|
if (exceptions.Any())
|
||||||
|
{
|
||||||
|
Log(" > Completed last test moment. Test failed.");
|
||||||
|
throw exceptions.First();
|
||||||
|
}
|
||||||
|
Log(" > Completed last test moment. Test passed.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exceptions.Any()) throw exceptions.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunMoment(int t)
|
private void RunMoment(int t)
|
||||||
@ -130,7 +136,7 @@ namespace ContinuousTests
|
|||||||
|
|
||||||
private DistTestCore.Configuration CreateFileManagerConfiguration()
|
private DistTestCore.Configuration CreateFileManagerConfiguration()
|
||||||
{
|
{
|
||||||
return new DistTestCore.Configuration(null, string.Empty, false, config.DataPath + Guid.NewGuid(),
|
return new DistTestCore.Configuration(null, string.Empty, false, dataFolder,
|
||||||
CodexLogLevel.Error, TestRunnerLocation.ExternalToCluster);
|
CodexLogLevel.Error, TestRunnerLocation.ExternalToCluster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace ContinuousTests
|
|||||||
|
|
||||||
public int? GetNextMoment(int currentMoment)
|
public int? GetNextMoment(int currentMoment)
|
||||||
{
|
{
|
||||||
var remainingMoments = moments.Where(m => m.Moment >= currentMoment).ToArray();
|
var remainingMoments = moments.Where(m => m.Moment > currentMoment).ToArray();
|
||||||
if (!remainingMoments.Any()) return null;
|
if (!remainingMoments.Any()) return null;
|
||||||
return remainingMoments.Min(m => m.Moment);
|
return remainingMoments.Min(m => m.Moment);
|
||||||
}
|
}
|
||||||
@ -71,6 +71,8 @@ namespace ContinuousTests
|
|||||||
{
|
{
|
||||||
Method = method;
|
Method = method;
|
||||||
Moment = moment;
|
Moment = moment;
|
||||||
|
|
||||||
|
if (moment < 0) throw new Exception("Moment must be zero or greater.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodInfo Method { get; }
|
public MethodInfo Method { get; }
|
||||||
|
@ -2,25 +2,24 @@
|
|||||||
|
|
||||||
namespace ContinuousTests.Tests
|
namespace ContinuousTests.Tests
|
||||||
{
|
{
|
||||||
public class MarketplaceTest : ContinuousTest
|
//public class MarketplaceTest : ContinuousTest
|
||||||
{
|
//{
|
||||||
public override int RequiredNumberOfNodes => 1;
|
// public override int RequiredNumberOfNodes => 1;
|
||||||
public override TimeSpan RunTestEvery => TimeSpan.FromDays(1);
|
// public override TimeSpan RunTestEvery => TimeSpan.FromDays(1);
|
||||||
public override TestFailMode TestFailMode => TestFailMode.AlwaysRunAllMoments;
|
// public override TestFailMode TestFailMode => TestFailMode.AlwaysRunAllMoments;
|
||||||
|
|
||||||
[TestMoment(t: Zero)]
|
// [TestMoment(t: Zero)]
|
||||||
public void NodePostsStorageRequest()
|
// public void NodePostsStorageRequest()
|
||||||
{
|
// {
|
||||||
//var c = new KubernetesWorkflow.WorkflowCreator(Log, new KubernetesWorkflow.Configuration());
|
// //var c = new KubernetesWorkflow.WorkflowCreator(Log, new KubernetesWorkflow.Configuration());
|
||||||
//var flow = c.CreateWorkflow();
|
// //var flow = c.CreateWorkflow();
|
||||||
//var rc = flow.Start(10, KubernetesWorkflow.Location.Unspecified, new CodexContainerRecipe(), new KubernetesWorkflow.StartupConfig());
|
// //var rc = flow.Start(10, KubernetesWorkflow.Location.Unspecified, new CodexContainerRecipe(), new KubernetesWorkflow.StartupConfig());
|
||||||
}
|
// }
|
||||||
|
|
||||||
[TestMoment(t: DayThree)]
|
// [TestMoment(t: DayThree)]
|
||||||
public void NodeDownloadsStorageRequestData()
|
// public void NodeDownloadsStorageRequestData()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,30 @@ using NUnit.Framework;
|
|||||||
|
|
||||||
namespace ContinuousTests.Tests
|
namespace ContinuousTests.Tests
|
||||||
{
|
{
|
||||||
//public class TwoClientTest : ContinuousTest
|
public class TwoClientTest : ContinuousTest
|
||||||
//{
|
{
|
||||||
// public override int RequiredNumberOfNodes => 2;
|
public override int RequiredNumberOfNodes => 2;
|
||||||
|
public override TimeSpan RunTestEvery => TimeSpan.FromHours(1);
|
||||||
|
public override TestFailMode TestFailMode => TestFailMode.StopAfterFirstFailure;
|
||||||
|
|
||||||
// public override void Run()
|
private ContentId? cid;
|
||||||
// {
|
private TestFile file = null!;
|
||||||
// var file = FileManager.GenerateTestFile(10.MB());
|
|
||||||
|
|
||||||
// var cid = UploadFile(Nodes[0], file);
|
[TestMoment(t: Zero)]
|
||||||
// Assert.That(cid, Is.Not.Null);
|
public void UploadTestFile()
|
||||||
|
{
|
||||||
|
file = FileManager.GenerateTestFile(10.MB());
|
||||||
|
|
||||||
// var dl = DownloadContent(Nodes[1], cid!);
|
cid = UploadFile(Nodes[0], file);
|
||||||
|
Assert.That(cid, Is.Not.Null);
|
||||||
|
}
|
||||||
|
|
||||||
// file.AssertIsEqual(dl);
|
[TestMoment(t: MinuteFive)]
|
||||||
// }
|
public void DownloadTestFile()
|
||||||
//}
|
{
|
||||||
|
var dl = DownloadContent(Nodes[1], cid!);
|
||||||
|
|
||||||
|
file.AssertIsEqual(dl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user