From 71409b06aeff21d598847946df5f0524f0c3ebcf Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 26 Jan 2024 11:37:18 -0500 Subject: [PATCH 01/11] Increases timeout for codex contracts deployment --- ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs index acfc0ac..f7864de 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsStarter.cs @@ -85,7 +85,7 @@ namespace CodexContractsPlugin private void WaitUntil(Func predicate) { - Time.WaitUntil(predicate, TimeSpan.FromMinutes(3), TimeSpan.FromSeconds(2)); + Time.WaitUntil(predicate, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(2)); } private StartupConfig CreateStartupConfig(IGethNode gethNode) From dc33f0655c7bf1255a1467fb178b07cd3ac84f41 Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:05:51 +0200 Subject: [PATCH 02/11] ci: upldate actions to the latest versions (#95) --- .github/workflows/docker-reusable.yml | 27 +++++++++++---------- .github/workflows/run-continuous-tests.yaml | 4 +-- .github/workflows/run-dist-tests.yaml | 4 +-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-reusable.yml b/.github/workflows/docker-reusable.yml index 66fb8a2..cc01f1e 100644 --- a/.github/workflows/docker-reusable.yml +++ b/.github/workflows/docker-reusable.yml @@ -1,4 +1,4 @@ -name: Docker - Reusable +name: Reusable - Docker on: @@ -66,26 +66,26 @@ jobs: PLATFORM: ${{ format('{0}/{1}', 'linux', matrix.target.arch) }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker - Meta id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.DOCKER_REPO }} - name: Docker - Set up Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Docker - Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Docker - Build and Push by digest id: build - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: ${{ env.DOCKER_FILE }} @@ -101,9 +101,9 @@ jobs: touch "/tmp/digests/${digest#sha256:}" - name: Docker - Upload digest - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: digests + name: digests-${{ matrix.target.arch }} path: /tmp/digests/* if-no-files-found: error retention-days: 1 @@ -139,17 +139,18 @@ jobs: fi - name: Docker - Download digests - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: digests + pattern: digests-* + merge-multiple: true path: /tmp/digests - name: Docker - Set up Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Docker - Meta id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.DOCKER_REPO }} flavor: | @@ -161,7 +162,7 @@ jobs: type=sha,enable=${{ env.TAG_SHA }} - name: Docker - Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/run-continuous-tests.yaml b/.github/workflows/run-continuous-tests.yaml index 74334e8..c364fa3 100644 --- a/.github/workflows/run-continuous-tests.yaml +++ b/.github/workflows/run-continuous-tests.yaml @@ -91,7 +91,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ${{ inputs.workflow_source }} @@ -112,7 +112,7 @@ jobs: [[ -n "${{ inputs.tests_cleanup }}" ]] && echo "TESTS_CLEANUP=${{ inputs.tests_cleanup }}" >>"$GITHUB_ENV" || echo "TESTS_CLEANUP=${{ env.TESTS_CLEANUP }}" >>"$GITHUB_ENV" - name: Kubectl - Install ${{ env.KUBE_VERSION }} - uses: azure/setup-kubectl@v3 + uses: azure/setup-kubectl@v4 with: version: ${{ env.KUBE_VERSION }} diff --git a/.github/workflows/run-dist-tests.yaml b/.github/workflows/run-dist-tests.yaml index d629b9d..7eb45c6 100644 --- a/.github/workflows/run-dist-tests.yaml +++ b/.github/workflows/run-dist-tests.yaml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Variables run: | @@ -57,7 +57,7 @@ jobs: [[ -n "${{ inputs.command }}" ]] && COMMAND="${{ inputs.command }}" || COMMAND="${{ env.COMMAND }}" - name: Kubectl - Install ${{ env.KUBE_VERSION }} - uses: azure/setup-kubectl@v3 + uses: azure/setup-kubectl@v4 with: version: ${{ env.KUBE_VERSION }} From 930c44f0379d3ef8bf3b654d7d9d545c5293bd8a Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:50:42 +0200 Subject: [PATCH 03/11] ci: use temporary branch for setup-kubectl action (#96) --- .github/workflows/run-continuous-tests.yaml | 2 +- .github/workflows/run-dist-tests.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-continuous-tests.yaml b/.github/workflows/run-continuous-tests.yaml index c364fa3..d29e91c 100644 --- a/.github/workflows/run-continuous-tests.yaml +++ b/.github/workflows/run-continuous-tests.yaml @@ -112,7 +112,7 @@ jobs: [[ -n "${{ inputs.tests_cleanup }}" ]] && echo "TESTS_CLEANUP=${{ inputs.tests_cleanup }}" >>"$GITHUB_ENV" || echo "TESTS_CLEANUP=${{ env.TESTS_CLEANUP }}" >>"$GITHUB_ENV" - name: Kubectl - Install ${{ env.KUBE_VERSION }} - uses: azure/setup-kubectl@v4 + uses: azure/setup-kubectl@releases/v4.0.0 with: version: ${{ env.KUBE_VERSION }} diff --git a/.github/workflows/run-dist-tests.yaml b/.github/workflows/run-dist-tests.yaml index 7eb45c6..a91b818 100644 --- a/.github/workflows/run-dist-tests.yaml +++ b/.github/workflows/run-dist-tests.yaml @@ -57,7 +57,7 @@ jobs: [[ -n "${{ inputs.command }}" ]] && COMMAND="${{ inputs.command }}" || COMMAND="${{ env.COMMAND }}" - name: Kubectl - Install ${{ env.KUBE_VERSION }} - uses: azure/setup-kubectl@v4 + uses: azure/setup-kubectl@releases/v4.0.0 with: version: ${{ env.KUBE_VERSION }} From ec0f7a679030e1d26ad0d836ad3a312c1bd9be7a Mon Sep 17 00:00:00 2001 From: Giuliano Mega Date: Thu, 22 Feb 2024 10:41:07 -0300 Subject: [PATCH 04/11] Remove run ID and introduce deploy ID (#93) This PR removes the notion of a run id and replaces it with a deploy id in continuous tests. Deploy ids can be set at deploy time only (duh), and will be picked up by the test runner from the deploy file on subsequent runs of the continuous test runner. As a consequence, the deploy id becomes a deployer parameter, and can no longer be overridden at the runner. For non-continuous tests, the deploy ID is created on-the-fly. --- ProjectPlugins/CodexPlugin/CodexDeployment.cs | 14 +++++++--- .../ContinuousTestRunner.cs | 5 ++-- Tests/CodexContinuousTests/SingleTestRun.cs | 27 ++++++++++++++----- Tests/CodexContinuousTests/StartupChecker.cs | 27 +++++++++++++------ Tests/CodexContinuousTests/TestLoop.cs | 3 ++- Tests/CodexTests/AutoBootstrapDistTest.cs | 1 + Tests/DistTestCore/DistTest.cs | 9 ++++--- Tests/DistTestCore/Logs/BaseTestLog.cs | 9 +++++-- Tests/DistTestCore/Logs/FixtureLog.cs | 8 +++--- Tests/DistTestCore/Logs/StatusLog.cs | 8 +++--- Tests/DistTestCore/Logs/TestLog.cs | 5 ++-- Tests/DistTestCore/NameUtils.cs | 12 ++------- Tests/DistTestCore/TestLifecycle.cs | 10 ++++--- Tools/CodexNetDeployer/Configuration.cs | 4 +++ Tools/CodexNetDeployer/Deployer.cs | 17 +++++++----- Tools/CodexNetDeployer/K8sHook.cs | 6 +++-- 16 files changed, 108 insertions(+), 57 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/CodexDeployment.cs b/ProjectPlugins/CodexPlugin/CodexDeployment.cs index e1548ed..ccf5ef2 100644 --- a/ProjectPlugins/CodexPlugin/CodexDeployment.cs +++ b/ProjectPlugins/CodexPlugin/CodexDeployment.cs @@ -6,8 +6,12 @@ namespace CodexPlugin { public class CodexDeployment { - public CodexDeployment(CodexInstance[] codexInstances, GethDeployment gethDeployment, CodexContractsDeployment codexContractsDeployment, RunningContainers? prometheusContainer, RunningContainers? discordBotContainer, DeploymentMetadata metadata) + public CodexDeployment(CodexInstance[] codexInstances, GethDeployment gethDeployment, + CodexContractsDeployment codexContractsDeployment, RunningContainers? prometheusContainer, + RunningContainers? discordBotContainer, DeploymentMetadata metadata, + String id) { + Id = id; CodexInstances = codexInstances; GethDeployment = gethDeployment; CodexContractsDeployment = codexContractsDeployment; @@ -16,6 +20,7 @@ namespace CodexPlugin Metadata = metadata; } + public String Id { get; } public CodexInstance[] CodexInstances { get; } public GethDeployment GethDeployment { get; } public CodexContractsDeployment CodexContractsDeployment { get; } @@ -38,7 +43,10 @@ namespace CodexPlugin public class DeploymentMetadata { - public DeploymentMetadata(string name, DateTime startUtc, DateTime finishedUtc, string kubeNamespace, int numberOfCodexNodes, int numberOfValidators, int storageQuotaMB, CodexLogLevel codexLogLevel, int initialTestTokens, int minPrice, int maxCollateral, int maxDuration, int blockTTL, int blockMI, int blockMN) + public DeploymentMetadata(string name, DateTime startUtc, DateTime finishedUtc, string kubeNamespace, + int numberOfCodexNodes, int numberOfValidators, int storageQuotaMB, CodexLogLevel codexLogLevel, + int initialTestTokens, int minPrice, int maxCollateral, int maxDuration, int blockTTL, int blockMI, + int blockMN) { Name = name; StartUtc = startUtc; @@ -73,4 +81,4 @@ namespace CodexPlugin public int BlockMI { get; } public int BlockMN { get; } } -} +} \ No newline at end of file diff --git a/Tests/CodexContinuousTests/ContinuousTestRunner.cs b/Tests/CodexContinuousTests/ContinuousTestRunner.cs index c79fc71..b860c86 100644 --- a/Tests/CodexContinuousTests/ContinuousTestRunner.cs +++ b/Tests/CodexContinuousTests/ContinuousTestRunner.cs @@ -27,10 +27,11 @@ namespace ContinuousTests var startTime = DateTime.UtcNow; var overviewLog = new LogSplitter( - new FixtureLog(logConfig, startTime, "Overview"), + new FixtureLog(logConfig, startTime, config.CodexDeployment.Id, "Overview"), new ConsoleLog() ); - var statusLog = new StatusLog(logConfig, startTime, "continuous-tests", "ContinuousTestRun"); + var statusLog = new StatusLog(logConfig, startTime, "continuous-tests", config.CodexDeployment.Id, + "ContinuousTestRun"); overviewLog.Log("Initializing..."); diff --git a/Tests/CodexContinuousTests/SingleTestRun.cs b/Tests/CodexContinuousTests/SingleTestRun.cs index d7ccd80..4552b46 100644 --- a/Tests/CodexContinuousTests/SingleTestRun.cs +++ b/Tests/CodexContinuousTests/SingleTestRun.cs @@ -25,7 +25,9 @@ namespace ContinuousTests private readonly string testName; private static int failureCount = 0; - public SingleTestRun(EntryPointFactory entryPointFactory, TaskFactory taskFactory, Configuration config, ILog overviewLog, StatusLog statusLog, TestHandle handle, StartupChecker startupChecker, CancellationToken cancelToken) + public SingleTestRun(EntryPointFactory entryPointFactory, + TaskFactory taskFactory, Configuration config, ILog overviewLog, StatusLog statusLog, TestHandle handle, + StartupChecker startupChecker, CancellationToken cancelToken, string deployId) { this.taskFactory = taskFactory; this.config = config; @@ -34,8 +36,9 @@ namespace ContinuousTests this.handle = handle; this.cancelToken = cancelToken; testName = handle.Test.GetType().Name; - fixtureLog = new FixtureLog(new LogConfig(config.LogPath), DateTime.UtcNow, testName); - entryPoint = entryPointFactory.CreateEntryPoint(config.KubeConfigFile, config.DataPath, config.CodexDeployment.Metadata.KubeNamespace, fixtureLog); + fixtureLog = new FixtureLog(new LogConfig(config.LogPath), DateTime.UtcNow, deployId, testName); + entryPoint = entryPointFactory.CreateEntryPoint(config.KubeConfigFile, config.DataPath, + config.CodexDeployment.Metadata.KubeNamespace, fixtureLog); ApplyLogReplacements(fixtureLog, startupChecker); nodes = CreateRandomNodes(); @@ -80,6 +83,7 @@ namespace ContinuousTests { fixtureLog.Delete(); } + resultHandler(true); } catch (Exception ex) @@ -114,6 +118,7 @@ namespace ContinuousTests { effectiveStart = config.CodexDeployment.Metadata.StartUtc.Subtract(TimeSpan.FromSeconds(30)); } + var effectiveEnd = DateTime.UtcNow; var elasticSearchLogDownloader = new ElasticSearchLogDownloader(entryPoint.Tools, fixtureLog); @@ -122,14 +127,17 @@ namespace ContinuousTests var container = node.Container; var deploymentName = container.RunningContainers.StartResult.Deployment.Name; var namespaceName = container.RunningContainers.StartResult.Cluster.Configuration.KubernetesNamespace; - var openingLine = $"{namespaceName} - {deploymentName} = {node.Container.Name} = {node.GetDebugInfo().id}"; - elasticSearchLogDownloader.Download(fixtureLog.CreateSubfile(), node.Container, effectiveStart, effectiveEnd, openingLine); + var openingLine = + $"{namespaceName} - {deploymentName} = {node.Container.Name} = {node.GetDebugInfo().id}"; + elasticSearchLogDownloader.Download(fixtureLog.CreateSubfile(), node.Container, effectiveStart, + effectiveEnd, openingLine); } } private void ApplyLogReplacements(FixtureLog fixtureLog, StartupChecker startupChecker) { - foreach (var replacement in startupChecker.LogReplacements) fixtureLog.AddStringReplace(replacement.From, replacement.To); + foreach (var replacement in startupChecker.LogReplacements) + fixtureLog.AddStringReplace(replacement.From, replacement.To); } private void RunTestMoments() @@ -161,9 +169,11 @@ namespace ContinuousTests { ThrowFailTest(); } + return; } } + fixtureLog.Log("Test run has been cancelled."); } @@ -193,6 +203,7 @@ namespace ContinuousTests result.Add("testname", testName); result.Add("message", message); result.Add("involvedpods", string.Join(",", nodes.Select(n => n.GetName()))); + result.Add("involvedpodnames", string.Join(",", nodes.Select(n => n.GetPodInfo().Name))); var error = message.Split(Environment.NewLine).First(); if (error.Contains(":")) error = error.Substring(1 + error.LastIndexOf(":")); @@ -222,6 +233,7 @@ namespace ContinuousTests { return UnpackException(a.InnerExceptions.First()); } + if (exception is TargetInvocationException t) { return UnpackException(t.InnerException!); @@ -294,7 +306,8 @@ namespace ContinuousTests { result[i] = containers.PickOneRandom(); } + return result; } } -} +} \ No newline at end of file diff --git a/Tests/CodexContinuousTests/StartupChecker.cs b/Tests/CodexContinuousTests/StartupChecker.cs index b232265..1527589 100644 --- a/Tests/CodexContinuousTests/StartupChecker.cs +++ b/Tests/CodexContinuousTests/StartupChecker.cs @@ -23,7 +23,8 @@ namespace ContinuousTests public void Check() { - var log = new FixtureLog(new LogConfig(config.LogPath), DateTime.UtcNow, "StartupChecks"); + var log = new FixtureLog(new LogConfig(config.LogPath), DateTime.UtcNow, config.CodexDeployment.Id, + "StartupChecks"); log.Log("Starting continuous test run..."); IncludeDeploymentConfiguration(log); log.Log("Checking configuration..."); @@ -46,13 +47,15 @@ namespace ContinuousTests { var podInfo = workflow.GetPodInfo(container); log.Log($"Codex environment variables for '{container.Name}':"); - log.Log($"Namespace: {container.RunningContainers.StartResult.Cluster.Configuration.KubernetesNamespace} - " + + log.Log( + $"Namespace: {container.RunningContainers.StartResult.Cluster.Configuration.KubernetesNamespace} - " + $"Pod name: {podInfo.Name} - Deployment name: {instance.Containers.StartResult.Deployment.Name}"); var codexVars = container.Recipe.EnvVars; foreach (var vars in codexVars) log.Log(vars.ToString()); log.Log(""); } } + log.Log($"Deployment metadata: {JsonConvert.SerializeObject(deployment.Metadata)}"); log.Log(""); } @@ -64,6 +67,7 @@ namespace ContinuousTests { throw new Exception("Unable to find any tests."); } + foreach (var test in tests) { cancelToken.ThrowIfCancellationRequested(); @@ -87,7 +91,8 @@ namespace ContinuousTests private void CheckCodexNodes(BaseLog log, Configuration config) { - var nodes = entryPoint.CreateInterface().WrapCodexContainers(config.CodexDeployment.CodexInstances.Select(i => i.Containers).ToArray()); + var nodes = entryPoint.CreateInterface() + .WrapCodexContainers(config.CodexDeployment.CodexInstances.Select(i => i.Containers).ToArray()); var pass = true; foreach (var n in nodes) { @@ -106,6 +111,7 @@ namespace ContinuousTests pass = false; } } + if (!pass) { throw new Exception("Not all codex nodes responded."); @@ -126,6 +132,7 @@ namespace ContinuousTests { return false; } + return true; } @@ -145,7 +152,8 @@ namespace ContinuousTests propertyName: nameof(ContinuousTest.CustomK8sNamespace)); } - private void DuplicatesCheck(ContinuousTest[] tests, List errors, Func considerCondition, Func getValue, string propertyName) + private void DuplicatesCheck(ContinuousTest[] tests, List errors, + Func considerCondition, Func getValue, string propertyName) { foreach (var test in tests) { @@ -155,7 +163,8 @@ namespace ContinuousTests if (duplicates.Any()) { duplicates.Add(test); - errors.Add($"Tests '{string.Join(",", duplicates.Select(d => d.Name))}' have the same '{propertyName}'. These must be unique."); + errors.Add( + $"Tests '{string.Join(",", duplicates.Select(d => d.Name))}' have the same '{propertyName}'. These must be unique."); return; } } @@ -170,14 +179,16 @@ namespace ContinuousTests { if (test.RequiredNumberOfNodes < 1) { - errors.Add($"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Test must require > 0 nodes, or -1 to select all nodes."); + errors.Add( + $"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Test must require > 0 nodes, or -1 to select all nodes."); } else if (test.RequiredNumberOfNodes > config.CodexDeployment.CodexInstances.Length) { - errors.Add($"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Deployment only has {config.CodexDeployment.CodexInstances.Length}"); + errors.Add( + $"Test '{test.Name}' requires {test.RequiredNumberOfNodes} nodes. Deployment only has {config.CodexDeployment.CodexInstances.Length}"); } } } } } -} +} \ No newline at end of file diff --git a/Tests/CodexContinuousTests/TestLoop.cs b/Tests/CodexContinuousTests/TestLoop.cs index 46b4e29..aa0d636 100644 --- a/Tests/CodexContinuousTests/TestLoop.cs +++ b/Tests/CodexContinuousTests/TestLoop.cs @@ -77,7 +77,8 @@ namespace ContinuousTests { var test = (ContinuousTest)Activator.CreateInstance(testType)!; var handle = new TestHandle(test); - var run = new SingleTestRun(entryPointFactory, taskFactory, config, overviewLog, statusLog, handle, startupChecker, cancelToken); + var run = new SingleTestRun(entryPointFactory, taskFactory, config, overviewLog, statusLog, handle, + startupChecker, cancelToken, config.CodexDeployment.Id); runFinishedHandle.Reset(); run.Run(runFinishedHandle, result => diff --git a/Tests/CodexTests/AutoBootstrapDistTest.cs b/Tests/CodexTests/AutoBootstrapDistTest.cs index 694b255..5c70496 100644 --- a/Tests/CodexTests/AutoBootstrapDistTest.cs +++ b/Tests/CodexTests/AutoBootstrapDistTest.cs @@ -23,5 +23,6 @@ namespace CodexTests } protected ICodexNode? BootstrapNode { get; private set; } + } } diff --git a/Tests/DistTestCore/DistTest.cs b/Tests/DistTestCore/DistTest.cs index 5237bbc..cc71e5d 100644 --- a/Tests/DistTestCore/DistTest.cs +++ b/Tests/DistTestCore/DistTest.cs @@ -20,16 +20,19 @@ namespace DistTestCore private readonly object lifecycleLock = new object(); private readonly EntryPoint globalEntryPoint; private readonly Dictionary lifecycles = new Dictionary(); + private readonly string deployId; public DistTest() { var assemblies = AppDomain.CurrentDomain.GetAssemblies(); testAssemblies = assemblies.Where(a => a.FullName!.ToLowerInvariant().Contains("test")).ToArray(); + + deployId = NameUtils.MakeDeployId(); var logConfig = configuration.GetLogConfig(); var startTime = DateTime.UtcNow; - fixtureLog = new FixtureLog(logConfig, startTime); - statusLog = new StatusLog(logConfig, startTime, "dist-tests"); + fixtureLog = new FixtureLog(logConfig, startTime, deployId); + statusLog = new StatusLog(logConfig, startTime, "dist-tests", deployId); globalEntryPoint = new EntryPoint(fixtureLog, configuration.GetK8sConfiguration(new DefaultTimeSet(), TestNamespacePrefix), configuration.GetFileManagerFolder()); @@ -181,7 +184,7 @@ namespace DistTestCore lock (lifecycleLock) { var testNamespace = TestNamespacePrefix + Guid.NewGuid().ToString(); - var lifecycle = new TestLifecycle(fixtureLog.CreateTestLog(), configuration, GetTimeSet(), testNamespace); + var lifecycle = new TestLifecycle(fixtureLog.CreateTestLog(), configuration, GetTimeSet(), testNamespace, deployId); lifecycles.Add(testName, lifecycle); LifecycleStart(lifecycle); } diff --git a/Tests/DistTestCore/Logs/BaseTestLog.cs b/Tests/DistTestCore/Logs/BaseTestLog.cs index e1f6d3d..4cd4aa6 100644 --- a/Tests/DistTestCore/Logs/BaseTestLog.cs +++ b/Tests/DistTestCore/Logs/BaseTestLog.cs @@ -5,13 +5,18 @@ namespace DistTestCore.Logs public abstract class BaseTestLog : BaseLog { private bool hasFailed; + private readonly string deployId; + + protected BaseTestLog(string deployId) + { + this.deployId = deployId; + } public void WriteLogTag() { - var runId = NameUtils.GetRunId(); var category = NameUtils.GetCategoryName(); var name = NameUtils.GetTestMethodName(); - LogFile.WriteRaw($"{runId} {category} {name}"); + LogFile.WriteRaw($"{deployId} {category} {name}"); } public void MarkAsFailed() diff --git a/Tests/DistTestCore/Logs/FixtureLog.cs b/Tests/DistTestCore/Logs/FixtureLog.cs index 8da2a48..6559f81 100644 --- a/Tests/DistTestCore/Logs/FixtureLog.cs +++ b/Tests/DistTestCore/Logs/FixtureLog.cs @@ -5,15 +5,17 @@ namespace DistTestCore.Logs public class FixtureLog : BaseTestLog { private readonly string fullName; + private readonly string deployId; - public FixtureLog(LogConfig config, DateTime start, string name = "") + public FixtureLog(LogConfig config, DateTime start, string deployId, string name = "") : base(deployId) { + this.deployId = deployId; fullName = NameUtils.GetFixtureFullName(config, start, name); } public TestLog CreateTestLog(string name = "") { - return new TestLog(fullName, name); + return new TestLog(fullName, deployId, name); } public void DeleteFolder() @@ -26,4 +28,4 @@ namespace DistTestCore.Logs return fullName; } } -} +} \ No newline at end of file diff --git a/Tests/DistTestCore/Logs/StatusLog.cs b/Tests/DistTestCore/Logs/StatusLog.cs index a03e919..0706eb8 100644 --- a/Tests/DistTestCore/Logs/StatusLog.cs +++ b/Tests/DistTestCore/Logs/StatusLog.cs @@ -6,16 +6,18 @@ namespace DistTestCore.Logs { public class StatusLog { - private readonly object fileLock = new object(); + private readonly object fileLock = new(); + private readonly string deployId; private readonly string fullName; private readonly string fixtureName; private readonly string testType; - public StatusLog(LogConfig config, DateTime start, string testType, string name = "") + public StatusLog(LogConfig config, DateTime start, string testType, string deployId, string name = "") { fullName = NameUtils.GetFixtureFullName(config, start, name) + "_STATUS.log"; fixtureName = NameUtils.GetRawFixtureName(); this.testType = testType; + this.deployId = deployId; } public void ConcludeTest(string resultStatus, TimeSpan testDuration, Dictionary data) @@ -26,7 +28,7 @@ namespace DistTestCore.Logs public void ConcludeTest(string resultStatus, string testDuration, Dictionary data) { data.Add("timestamp", DateTime.UtcNow.ToString("o")); - data.Add("runid", NameUtils.GetRunId()); + data.Add("deployid", deployId); data.Add("status", resultStatus); data.Add("category", NameUtils.GetCategoryName()); data.Add("fixturename", fixtureName); diff --git a/Tests/DistTestCore/Logs/TestLog.cs b/Tests/DistTestCore/Logs/TestLog.cs index 6e23413..1f598b6 100644 --- a/Tests/DistTestCore/Logs/TestLog.cs +++ b/Tests/DistTestCore/Logs/TestLog.cs @@ -2,12 +2,11 @@ { public class TestLog : BaseTestLog { - private readonly string methodName; private readonly string fullName; - public TestLog(string folder, string name = "") + public TestLog(string folder, string deployId, string name = "") : base(deployId) { - methodName = NameUtils.GetTestMethodName(name); + var methodName = NameUtils.GetTestMethodName(name); fullName = Path.Combine(folder, methodName); Log($"*** Begin: {methodName}"); diff --git a/Tests/DistTestCore/NameUtils.cs b/Tests/DistTestCore/NameUtils.cs index 58b0b51..dc529b5 100644 --- a/Tests/DistTestCore/NameUtils.cs +++ b/Tests/DistTestCore/NameUtils.cs @@ -5,14 +5,6 @@ namespace DistTestCore { public static class NameUtils { - private static readonly string defaultRunId; - - static NameUtils() - { - var now = DateTime.UtcNow; - defaultRunId = now.ToString("yyyyMMdd-hhmmss"); - } - public static string GetTestMethodName(string name = "") { if (!string.IsNullOrEmpty(name)) return name; @@ -48,9 +40,9 @@ namespace DistTestCore return GetEnvVar("TESTID", "EnvVar-TESTID-NotSet"); } - public static string GetRunId() + public static string MakeDeployId() { - return GetEnvVar("RUNID", defaultRunId); + return DateTime.UtcNow.ToString("yyyyMMdd-hhmmss"); } private static string GetEnvVar(string name, string defaultValue) diff --git a/Tests/DistTestCore/TestLifecycle.cs b/Tests/DistTestCore/TestLifecycle.cs index 3ed08bb..50cb5fb 100644 --- a/Tests/DistTestCore/TestLifecycle.cs +++ b/Tests/DistTestCore/TestLifecycle.cs @@ -12,10 +12,11 @@ namespace DistTestCore { private const string TestsType = "dist-tests"; private readonly EntryPoint entryPoint; - private readonly Dictionary metadata; - private readonly List runningContainers = new List(); + private readonly Dictionary metadata; + private readonly List runningContainers = new(); + private readonly string deployId; - public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet, string testNamespace) + public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet, string testNamespace, string deployId) { Log = log; Configuration = configuration; @@ -25,6 +26,7 @@ namespace DistTestCore entryPoint = new EntryPoint(log, configuration.GetK8sConfiguration(timeSet, this, testNamespace), configuration.GetFileManagerFolder(), timeSet); metadata = entryPoint.GetPluginMetadata(); CoreInterface = entryPoint.CreateInterface(); + this.deployId = deployId; log.WriteLogTag(); } @@ -76,7 +78,7 @@ namespace DistTestCore public void OnContainerRecipeCreated(ContainerRecipe recipe) { recipe.PodLabels.Add("tests-type", TestsType); - recipe.PodLabels.Add("runid", NameUtils.GetRunId()); + recipe.PodLabels.Add("deployid", deployId); recipe.PodLabels.Add("testid", NameUtils.GetTestId()); recipe.PodLabels.Add("category", NameUtils.GetCategoryName()); recipe.PodLabels.Add("fixturename", NameUtils.GetRawFixtureName()); diff --git a/Tools/CodexNetDeployer/Configuration.cs b/Tools/CodexNetDeployer/Configuration.cs index 1d93402..675e51c 100644 --- a/Tools/CodexNetDeployer/Configuration.cs +++ b/Tools/CodexNetDeployer/Configuration.cs @@ -1,5 +1,6 @@ using ArgsUniform; using CodexPlugin; +using DistTestCore; namespace CodexNetDeployer { @@ -16,6 +17,9 @@ namespace CodexNetDeployer [Uniform("kube-namespace", "kn", "KUBENAMESPACE", true, "Kubernetes namespace to be used for deployment.")] public string KubeNamespace { get; set; } = string.Empty; + + [Uniform("deploy-id", "di", "DEPLOYID", false, "ID of the deployment. (default) to current time)")] + public string DeployId { get; set; } = NameUtils.MakeDeployId(); [Uniform("deploy-file", "df", "DEPLOYFILE", false, "Output deployment JSON file that will be written. Defaults to 'codex-deployment.json'.")] public string DeployFile { get; set; } = "codex-deployment.json"; diff --git a/Tools/CodexNetDeployer/Deployer.cs b/Tools/CodexNetDeployer/Deployer.cs index 1461784..f9d6a35 100644 --- a/Tools/CodexNetDeployer/Deployer.cs +++ b/Tools/CodexNetDeployer/Deployer.cs @@ -45,6 +45,7 @@ namespace CodexNetDeployer Console.CursorLeft = longestKey + 5; Console.WriteLine($"= {entry.Value}"); } + Log(""); } @@ -84,7 +85,8 @@ namespace CodexNetDeployer var discordBotContainer = DeployDiscordBot(ci, gethDeployment, contractsDeployment); - return new CodexDeployment(codexInstances, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc)); + return new CodexDeployment(codexInstances, gethDeployment, contractsDeployment, metricsService, + discordBotContainer, CreateMetadata(startUtc), config.DeployId); } private EntryPoint CreateEntryPoint(ILog log) @@ -98,7 +100,7 @@ namespace CodexNetDeployer kubernetesNamespace: config.KubeNamespace); var result = new EntryPoint(log, configuration, string.Empty, new FastHttpTimeSet()); - configuration.Hooks = new K8sHook(config.TestsTypePodLabel, result.GetPluginMetadata()); + configuration.Hooks = new K8sHook(config.TestsTypePodLabel, config.DeployId, result.GetPluginMetadata()); return result; } @@ -120,7 +122,8 @@ namespace CodexNetDeployer }); } - private RunningContainers? DeployDiscordBot(CoreInterface ci, GethDeployment gethDeployment, CodexContractsDeployment contractsDeployment) + private RunningContainers? DeployDiscordBot(CoreInterface ci, GethDeployment gethDeployment, + CodexContractsDeployment contractsDeployment) { if (!config.DeployDiscordBot) return null; Log("Deploying Discord bot..."); @@ -201,7 +204,8 @@ namespace CodexNetDeployer foreach (var startResult in startResults) { var watcher = startResult.CodexNode.CrashWatcher; - if (watcher == null) throw new Exception("Expected each CodexNode container to be created with a crash-watcher."); + if (watcher == null) + throw new Exception("Expected each CodexNode container to be created with a crash-watcher."); if (watcher.HasContainerCrashed()) crashes.Add(startResult.CodexNode.Container); } @@ -211,7 +215,8 @@ namespace CodexNetDeployer } else { - Log($"Check failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.Name))}"); + Log( + $"Check failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.Name))}"); throw new Exception("Deployment failed: One or more containers crashed."); } } @@ -269,4 +274,4 @@ namespace CodexNetDeployer return TimeSpan.FromSeconds(30); } } -} +} \ No newline at end of file diff --git a/Tools/CodexNetDeployer/K8sHook.cs b/Tools/CodexNetDeployer/K8sHook.cs index f586613..b4c0c16 100644 --- a/Tools/CodexNetDeployer/K8sHook.cs +++ b/Tools/CodexNetDeployer/K8sHook.cs @@ -8,11 +8,13 @@ namespace CodexNetDeployer public class K8sHook : IK8sHooks { private readonly string testsTypeLabel; + private readonly string deployId; private readonly Dictionary metadata; - public K8sHook(string testsTypeLabel, Dictionary metadata) + public K8sHook(string testsTypeLabel, string deployId, Dictionary metadata) { this.testsTypeLabel = testsTypeLabel; + this.deployId = deployId; this.metadata = metadata; } @@ -27,7 +29,7 @@ namespace CodexNetDeployer public void OnContainerRecipeCreated(ContainerRecipe recipe) { recipe.PodLabels.Add("tests-type", testsTypeLabel); - recipe.PodLabels.Add("runid", NameUtils.GetRunId()); + recipe.PodLabels.Add("deployid", deployId); recipe.PodLabels.Add("testid", NameUtils.GetTestId()); foreach (var pair in metadata) From 64ecf531bda49df3f03e0a65bf2c06ca89c33360 Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 26 Feb 2024 09:02:46 +0100 Subject: [PATCH 05/11] Adds missing error message check to marketplaceAccess --- ProjectPlugins/CodexPlugin/MarketplaceAccess.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ProjectPlugins/CodexPlugin/MarketplaceAccess.cs b/ProjectPlugins/CodexPlugin/MarketplaceAccess.cs index cde4eb6..462f468 100644 --- a/ProjectPlugins/CodexPlugin/MarketplaceAccess.cs +++ b/ProjectPlugins/CodexPlugin/MarketplaceAccess.cs @@ -56,7 +56,8 @@ namespace CodexPlugin if (response == "Purchasing not available" || response == "Expiry required" || - response == "Expiry needs to be in future") + response == "Expiry needs to be in future" || + response == "Expiry has to be before the request's end (now + duration)") { throw new InvalidOperationException(response); } From b35cf3139dc8d6ae0f706bf9a11c134ce16217e3 Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 26 Feb 2024 15:08:04 +0100 Subject: [PATCH 06/11] Bumps contracts image to latest --- .../CodexContractsPlugin/CodexContractsContainerRecipe.cs | 2 +- Tests/CodexTests/BasicTests/ExampleTests.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsContainerRecipe.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsContainerRecipe.cs index 2813307..946d665 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsContainerRecipe.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsContainerRecipe.cs @@ -7,7 +7,7 @@ namespace CodexContractsPlugin { public class CodexContractsContainerRecipe : ContainerRecipeFactory { - public static string DockerImage { get; } = "codexstorage/codex-contracts-eth:sha-b5f3399-dist-tests"; + public static string DockerImage { get; } = "codexstorage/codex-contracts-eth:sha-965529d-dist-tests"; public const string MarketplaceAddressFilename = "/hardhat/deployments/codexdisttestnetwork/Marketplace.json"; public const string MarketplaceArtifactFilename = "/hardhat/artifacts/contracts/Marketplace.sol/Marketplace.json"; diff --git a/Tests/CodexTests/BasicTests/ExampleTests.cs b/Tests/CodexTests/BasicTests/ExampleTests.cs index c73a913..7e18f53 100644 --- a/Tests/CodexTests/BasicTests/ExampleTests.cs +++ b/Tests/CodexTests/BasicTests/ExampleTests.cs @@ -60,6 +60,7 @@ namespace CodexTests.BasicTests var contracts = Ci.StartCodexContracts(geth); var seller = AddCodex(s => s + .WithName("Seller") .WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Error, CodexLogLevel.Error, CodexLogLevel.Warn)) .WithStorageQuota(11.GB()) .EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: sellerInitialBalance, isValidator: true) @@ -75,6 +76,7 @@ namespace CodexTests.BasicTests var testFile = GenerateTestFile(fileSize); var buyer = AddCodex(s => s + .WithName("Buyer") .WithBootstrapNode(seller) .EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: buyerInitialBalance)); From f0167a800f8d7c3792de9201ab1e10f9f304d807 Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 27 Feb 2024 13:55:05 +0100 Subject: [PATCH 07/11] Speed up basic tests --- .../DownloadConnectivityTests/FullyConnectedDownloadTests.cs | 4 ++-- Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs | 1 - Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs b/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs index 0acd780..b4762b9 100644 --- a/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs +++ b/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs @@ -29,8 +29,8 @@ namespace CodexTests.DownloadConnectivityTests [Test] [Combinatorial] public void FullyConnectedDownloadTest( - [Values(3, 5)] int numberOfNodes, - [Values(10, 80)] int sizeMBs) + [Values(2, 5)] int numberOfNodes, + [Values(1, 10)] int sizeMBs) { AddCodex(numberOfNodes); diff --git a/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs b/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs index 4c8a3b3..386c3d8 100644 --- a/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs +++ b/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs @@ -32,7 +32,6 @@ namespace CodexTests.PeerDiscoveryTests [TestCase(3)] [TestCase(5)] [TestCase(10)] - [TestCase(20)] public void NodeChainTest(int chainLength) { var node = Ci.StartCodexNode(); diff --git a/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs b/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs index e080faa..10c1cde 100644 --- a/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs +++ b/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs @@ -39,7 +39,6 @@ namespace CodexTests.PeerDiscoveryTests [TestCase(2)] [TestCase(3)] [TestCase(10)] - [TestCase(20)] public void VariableNodes(int number) { AddCodex(number); From 247e010fbaea8be8cd755c233b4c28f470b054b3 Mon Sep 17 00:00:00 2001 From: benbierens Date: Wed, 28 Feb 2024 10:06:11 +0100 Subject: [PATCH 08/11] Cleanup marketplace test --- Tests/CodexTests/BasicTests/ExampleTests.cs | 64 +++++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Tests/CodexTests/BasicTests/ExampleTests.cs b/Tests/CodexTests/BasicTests/ExampleTests.cs index 7e18f53..fb2edcf 100644 --- a/Tests/CodexTests/BasicTests/ExampleTests.cs +++ b/Tests/CodexTests/BasicTests/ExampleTests.cs @@ -6,6 +6,7 @@ using MetricsPlugin; using Nethereum.Hex.HexConvertors.Extensions; using NUnit.Framework; using Utils; +using Request = CodexContractsPlugin.Marketplace.Request; namespace CodexTests.BasicTests { @@ -92,27 +93,12 @@ namespace CodexTests.BasicTests purchaseContract.WaitForStorageContractStarted(fileSize); - var requests = contracts.GetStorageRequests(GetTestRunTimeRange()); - Assert.That(requests.Length, Is.EqualTo(1)); - var request = requests.Single(); - Assert.That(contracts.GetRequestState(request), Is.EqualTo(RequestState.Started)); - Assert.That(request.ClientAddress, Is.EqualTo(buyer.EthAddress)); - Assert.That(request.Ask.Slots, Is.EqualTo(1)); - AssertBalance(contracts, seller, Is.LessThan(sellerInitialBalance), "Collateral was not placed."); - var requestFulfilledEvents = contracts.GetRequestFulfilledEvents(GetTestRunTimeRange()); - Assert.That(requestFulfilledEvents.Length, Is.EqualTo(1)); - CollectionAssert.AreEqual(request.RequestId, requestFulfilledEvents[0].RequestId); - var filledSlotEvents = contracts.GetSlotFilledEvents(GetTestRunTimeRange()); - Assert.That(filledSlotEvents.Length, Is.EqualTo(1)); - var filledSlotEvent = filledSlotEvents.Single(); - Assert.That(filledSlotEvent.SlotIndex.IsZero); - Assert.That(filledSlotEvent.RequestId.ToHex(), Is.EqualTo(request.RequestId.ToHex())); - Assert.That(filledSlotEvent.Host, Is.EqualTo(seller.EthAddress)); - - var slotHost = contracts.GetSlotHost(request, 0); - Assert.That(slotHost, Is.EqualTo(seller.EthAddress)); + var request = GetOnChainStorageRequest(contracts); + AssertStorageRequest(request, contracts, buyer); + AssertSlotFilledEvents(contracts, request, seller); + AssertContractSlot(contracts, request, 0, seller); purchaseContract.WaitForStorageContractFinished(); @@ -120,12 +106,7 @@ namespace CodexTests.BasicTests AssertBalance(contracts, buyer, Is.LessThan(buyerInitialBalance), "Buyer was not charged for storage."); Assert.That(contracts.GetRequestState(request), Is.EqualTo(RequestState.Finished)); - var log = Ci.DownloadLog(seller); - log.AssertLogContains("Received a request to store a slot!"); - log.AssertLogContains("Received proof challenge"); - log.AssertLogContains("Collecting input for proof"); - - //CheckLogForErrors(seller, buyer); + // waiting for block retransmit fix: CheckLogForErrors(seller, buyer); } [Test] @@ -144,5 +125,38 @@ namespace CodexTests.BasicTests Assert.That(bootN, Is.EqualTo(followN)); Assert.That(discN, Is.LessThan(bootN)); } + + private void AssertSlotFilledEvents(ICodexContracts contracts, Request request, ICodexNode seller) + { + var requestFulfilledEvents = contracts.GetRequestFulfilledEvents(GetTestRunTimeRange()); + Assert.That(requestFulfilledEvents.Length, Is.EqualTo(1)); + CollectionAssert.AreEqual(request.RequestId, requestFulfilledEvents[0].RequestId); + var filledSlotEvents = contracts.GetSlotFilledEvents(GetTestRunTimeRange()); + Assert.That(filledSlotEvents.Length, Is.EqualTo(1)); + var filledSlotEvent = filledSlotEvents.Single(); + Assert.That(filledSlotEvent.SlotIndex.IsZero); + Assert.That(filledSlotEvent.RequestId.ToHex(), Is.EqualTo(request.RequestId.ToHex())); + Assert.That(filledSlotEvent.Host, Is.EqualTo(seller.EthAddress)); + } + + private void AssertStorageRequest(Request request, ICodexContracts contracts, ICodexNode buyer) + { + Assert.That(contracts.GetRequestState(request), Is.EqualTo(RequestState.Started)); + Assert.That(request.ClientAddress, Is.EqualTo(buyer.EthAddress)); + Assert.That(request.Ask.Slots, Is.EqualTo(1)); + } + + private Request GetOnChainStorageRequest(ICodexContracts contracts) + { + var requests = contracts.GetStorageRequests(GetTestRunTimeRange()); + Assert.That(requests.Length, Is.EqualTo(1)); + return requests.Single(); + } + + private void AssertContractSlot(ICodexContracts contracts, Request request, int contractSlotIndex, ICodexNode expectedSeller) + { + var slotHost = contracts.GetSlotHost(request, contractSlotIndex); + Assert.That(slotHost, Is.EqualTo(expectedSeller.EthAddress)); + } } } From 3c8efbd0a0ed41f87ebe586fa91fa046df5eab48 Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:32:31 +0200 Subject: [PATCH 09/11] ci: upldate actions to the latest versions (#98) --- .github/workflows/run-continuous-tests.yaml | 2 +- .github/workflows/run-dist-tests.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-continuous-tests.yaml b/.github/workflows/run-continuous-tests.yaml index d29e91c..c364fa3 100644 --- a/.github/workflows/run-continuous-tests.yaml +++ b/.github/workflows/run-continuous-tests.yaml @@ -112,7 +112,7 @@ jobs: [[ -n "${{ inputs.tests_cleanup }}" ]] && echo "TESTS_CLEANUP=${{ inputs.tests_cleanup }}" >>"$GITHUB_ENV" || echo "TESTS_CLEANUP=${{ env.TESTS_CLEANUP }}" >>"$GITHUB_ENV" - name: Kubectl - Install ${{ env.KUBE_VERSION }} - uses: azure/setup-kubectl@releases/v4.0.0 + uses: azure/setup-kubectl@v4 with: version: ${{ env.KUBE_VERSION }} diff --git a/.github/workflows/run-dist-tests.yaml b/.github/workflows/run-dist-tests.yaml index a91b818..7eb45c6 100644 --- a/.github/workflows/run-dist-tests.yaml +++ b/.github/workflows/run-dist-tests.yaml @@ -57,7 +57,7 @@ jobs: [[ -n "${{ inputs.command }}" ]] && COMMAND="${{ inputs.command }}" || COMMAND="${{ env.COMMAND }}" - name: Kubectl - Install ${{ env.KUBE_VERSION }} - uses: azure/setup-kubectl@releases/v4.0.0 + uses: azure/setup-kubectl@v4 with: version: ${{ env.KUBE_VERSION }} From d1a70d2465590098eebec15a06329b9c56f2050a Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 13 Mar 2024 10:01:14 +0100 Subject: [PATCH 10/11] Adds support for command overrides to container recipes. --- Framework/KubernetesWorkflow/K8sController.cs | 9 ++++++++- .../KubernetesWorkflow/Recipe/CommandOverride.cs | 12 ++++++++++++ .../KubernetesWorkflow/Recipe/ContainerRecipe.cs | 4 +++- .../Recipe/ContainerRecipeFactory.cs | 9 ++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 Framework/KubernetesWorkflow/Recipe/CommandOverride.cs diff --git a/Framework/KubernetesWorkflow/K8sController.cs b/Framework/KubernetesWorkflow/K8sController.cs index bfea181..8af6fd8 100644 --- a/Framework/KubernetesWorkflow/K8sController.cs +++ b/Framework/KubernetesWorkflow/K8sController.cs @@ -498,10 +498,17 @@ namespace KubernetesWorkflow Ports = CreateContainerPorts(recipe), Env = CreateEnv(recipe), VolumeMounts = CreateContainerVolumeMounts(recipe), - Resources = CreateResourceLimits(recipe) + Resources = CreateResourceLimits(recipe), + Command = CreateCommandList(recipe) }; } + private IList CreateCommandList(ContainerRecipe recipe) + { + if (recipe.CommandOverride == null || !recipe.CommandOverride.Command.Any()) return null!; + return recipe.CommandOverride.Command.ToList(); + } + private V1ResourceRequirements CreateResourceLimits(ContainerRecipe recipe) { return new V1ResourceRequirements diff --git a/Framework/KubernetesWorkflow/Recipe/CommandOverride.cs b/Framework/KubernetesWorkflow/Recipe/CommandOverride.cs new file mode 100644 index 0000000..7821c81 --- /dev/null +++ b/Framework/KubernetesWorkflow/Recipe/CommandOverride.cs @@ -0,0 +1,12 @@ +namespace KubernetesWorkflow.Recipe +{ + public class CommandOverride + { + public CommandOverride(params string[] command) + { + Command = command; + } + + public string[] Command { get; } + } +} diff --git a/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs b/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs index fb7c8a4..78fcb63 100644 --- a/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs +++ b/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs @@ -2,13 +2,14 @@ { public class ContainerRecipe { - public ContainerRecipe(int number, string? nameOverride, string image, ContainerResources resources, SchedulingAffinity schedulingAffinity, bool setCriticalPriority, Port[] exposedPorts, Port[] internalPorts, EnvVar[] envVars, PodLabels podLabels, PodAnnotations podAnnotations, VolumeMount[] volumes, ContainerAdditionals additionals) + public ContainerRecipe(int number, string? nameOverride, string image, ContainerResources resources, SchedulingAffinity schedulingAffinity, CommandOverride commandOverride, bool setCriticalPriority, Port[] exposedPorts, Port[] internalPorts, EnvVar[] envVars, PodLabels podLabels, PodAnnotations podAnnotations, VolumeMount[] volumes, ContainerAdditionals additionals) { Number = number; NameOverride = nameOverride; Image = image; Resources = resources; SchedulingAffinity = schedulingAffinity; + CommandOverride = commandOverride; SetCriticalPriority = setCriticalPriority; ExposedPorts = exposedPorts; InternalPorts = internalPorts; @@ -35,6 +36,7 @@ public string? NameOverride { get; } public ContainerResources Resources { get; } public SchedulingAffinity SchedulingAffinity { get; } + public CommandOverride CommandOverride { get; } public bool SetCriticalPriority { get; } public string Image { get; } public Port[] ExposedPorts { get; } diff --git a/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs b/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs index 931013d..6b6ae2d 100644 --- a/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs +++ b/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs @@ -14,6 +14,7 @@ namespace KubernetesWorkflow.Recipe private RecipeComponentFactory factory = null!; private ContainerResources resources = new ContainerResources(); private SchedulingAffinity schedulingAffinity = new SchedulingAffinity(); + private CommandOverride commandOverride = new CommandOverride(); private bool setCriticalPriority; public ContainerRecipe CreateRecipe(int index, int containerNumber, RecipeComponentFactory factory, StartupConfig config) @@ -24,7 +25,7 @@ namespace KubernetesWorkflow.Recipe Initialize(config); - var recipe = new ContainerRecipe(containerNumber, config.NameOverride, Image, resources, schedulingAffinity, setCriticalPriority, + var recipe = new ContainerRecipe(containerNumber, config.NameOverride, Image, resources, schedulingAffinity, commandOverride, setCriticalPriority, exposedPorts.ToArray(), internalPorts.ToArray(), envVars.ToArray(), @@ -43,6 +44,7 @@ namespace KubernetesWorkflow.Recipe this.factory = null!; resources = new ContainerResources(); schedulingAffinity = new SchedulingAffinity(); + commandOverride = new CommandOverride(); setCriticalPriority = false; return recipe; @@ -130,6 +132,11 @@ namespace KubernetesWorkflow.Recipe schedulingAffinity = new SchedulingAffinity(notIn); } + protected void OverrideCommand(params string[] command) + { + commandOverride = new CommandOverride(command); + } + protected void SetSystemCriticalPriority() { setCriticalPriority = true; From 23396f54e0ec8edbf90539d2ed00b8723a27da5d Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 13 Mar 2024 10:01:47 +0100 Subject: [PATCH 11/11] Revert "Adds support for command overrides to container recipes." This reverts commit d1a70d2465590098eebec15a06329b9c56f2050a. --- Framework/KubernetesWorkflow/K8sController.cs | 9 +-------- .../KubernetesWorkflow/Recipe/CommandOverride.cs | 12 ------------ .../KubernetesWorkflow/Recipe/ContainerRecipe.cs | 4 +--- .../Recipe/ContainerRecipeFactory.cs | 9 +-------- 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 Framework/KubernetesWorkflow/Recipe/CommandOverride.cs diff --git a/Framework/KubernetesWorkflow/K8sController.cs b/Framework/KubernetesWorkflow/K8sController.cs index 8af6fd8..bfea181 100644 --- a/Framework/KubernetesWorkflow/K8sController.cs +++ b/Framework/KubernetesWorkflow/K8sController.cs @@ -498,17 +498,10 @@ namespace KubernetesWorkflow Ports = CreateContainerPorts(recipe), Env = CreateEnv(recipe), VolumeMounts = CreateContainerVolumeMounts(recipe), - Resources = CreateResourceLimits(recipe), - Command = CreateCommandList(recipe) + Resources = CreateResourceLimits(recipe) }; } - private IList CreateCommandList(ContainerRecipe recipe) - { - if (recipe.CommandOverride == null || !recipe.CommandOverride.Command.Any()) return null!; - return recipe.CommandOverride.Command.ToList(); - } - private V1ResourceRequirements CreateResourceLimits(ContainerRecipe recipe) { return new V1ResourceRequirements diff --git a/Framework/KubernetesWorkflow/Recipe/CommandOverride.cs b/Framework/KubernetesWorkflow/Recipe/CommandOverride.cs deleted file mode 100644 index 7821c81..0000000 --- a/Framework/KubernetesWorkflow/Recipe/CommandOverride.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace KubernetesWorkflow.Recipe -{ - public class CommandOverride - { - public CommandOverride(params string[] command) - { - Command = command; - } - - public string[] Command { get; } - } -} diff --git a/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs b/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs index 78fcb63..fb7c8a4 100644 --- a/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs +++ b/Framework/KubernetesWorkflow/Recipe/ContainerRecipe.cs @@ -2,14 +2,13 @@ { public class ContainerRecipe { - public ContainerRecipe(int number, string? nameOverride, string image, ContainerResources resources, SchedulingAffinity schedulingAffinity, CommandOverride commandOverride, bool setCriticalPriority, Port[] exposedPorts, Port[] internalPorts, EnvVar[] envVars, PodLabels podLabels, PodAnnotations podAnnotations, VolumeMount[] volumes, ContainerAdditionals additionals) + public ContainerRecipe(int number, string? nameOverride, string image, ContainerResources resources, SchedulingAffinity schedulingAffinity, bool setCriticalPriority, Port[] exposedPorts, Port[] internalPorts, EnvVar[] envVars, PodLabels podLabels, PodAnnotations podAnnotations, VolumeMount[] volumes, ContainerAdditionals additionals) { Number = number; NameOverride = nameOverride; Image = image; Resources = resources; SchedulingAffinity = schedulingAffinity; - CommandOverride = commandOverride; SetCriticalPriority = setCriticalPriority; ExposedPorts = exposedPorts; InternalPorts = internalPorts; @@ -36,7 +35,6 @@ public string? NameOverride { get; } public ContainerResources Resources { get; } public SchedulingAffinity SchedulingAffinity { get; } - public CommandOverride CommandOverride { get; } public bool SetCriticalPriority { get; } public string Image { get; } public Port[] ExposedPorts { get; } diff --git a/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs b/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs index 6b6ae2d..931013d 100644 --- a/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs +++ b/Framework/KubernetesWorkflow/Recipe/ContainerRecipeFactory.cs @@ -14,7 +14,6 @@ namespace KubernetesWorkflow.Recipe private RecipeComponentFactory factory = null!; private ContainerResources resources = new ContainerResources(); private SchedulingAffinity schedulingAffinity = new SchedulingAffinity(); - private CommandOverride commandOverride = new CommandOverride(); private bool setCriticalPriority; public ContainerRecipe CreateRecipe(int index, int containerNumber, RecipeComponentFactory factory, StartupConfig config) @@ -25,7 +24,7 @@ namespace KubernetesWorkflow.Recipe Initialize(config); - var recipe = new ContainerRecipe(containerNumber, config.NameOverride, Image, resources, schedulingAffinity, commandOverride, setCriticalPriority, + var recipe = new ContainerRecipe(containerNumber, config.NameOverride, Image, resources, schedulingAffinity, setCriticalPriority, exposedPorts.ToArray(), internalPorts.ToArray(), envVars.ToArray(), @@ -44,7 +43,6 @@ namespace KubernetesWorkflow.Recipe this.factory = null!; resources = new ContainerResources(); schedulingAffinity = new SchedulingAffinity(); - commandOverride = new CommandOverride(); setCriticalPriority = false; return recipe; @@ -132,11 +130,6 @@ namespace KubernetesWorkflow.Recipe schedulingAffinity = new SchedulingAffinity(notIn); } - protected void OverrideCommand(params string[] command) - { - commandOverride = new CommandOverride(command); - } - protected void SetSystemCriticalPriority() { setCriticalPriority = true;