Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfbb01757c |
@@ -2,7 +2,7 @@ name: Build and Push Docker Images
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ roman ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.nullptr.top
|
REGISTRY: git.nullptr.top
|
||||||
@@ -17,10 +17,10 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- service: gateway
|
- service: gateway
|
||||||
dockerfile: src/LiquidCode.Tester.Gateway/Dockerfile
|
dockerfile: src/LiquidCode.Tester.Gateway/Dockerfile
|
||||||
image: git.nullptr.top/liquidcode/liquidcode-tester-gateway
|
image: git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman
|
||||||
- service: worker
|
- service: worker
|
||||||
dockerfile: src/LiquidCode.Tester.Worker/Dockerfile
|
dockerfile: src/LiquidCode.Tester.Worker/Dockerfile
|
||||||
image: git.nullptr.top/liquidcode/liquidcode-tester-worker
|
image: git.nullptr.top/liquidcode/liquidcode-tester-worker-roman
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -7,5 +7,7 @@ public record SubmitForTesterModel(
|
|||||||
string LanguageVersion,
|
string LanguageVersion,
|
||||||
string SourceCode,
|
string SourceCode,
|
||||||
string PackageUrl,
|
string PackageUrl,
|
||||||
string CallbackUrl
|
string CallbackUrl,
|
||||||
|
int? TimeLimitMs = null,
|
||||||
|
int? MemoryLimitMb = null
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ public class TesterController : ControllerBase
|
|||||||
LanguageVersion: request.LanguageVersion,
|
LanguageVersion: request.LanguageVersion,
|
||||||
SourceCode: request.SourceCode,
|
SourceCode: request.SourceCode,
|
||||||
PackageUrl: packagePath, // Use local path instead of URL
|
PackageUrl: packagePath, // Use local path instead of URL
|
||||||
CallbackUrl: request.CallbackUrl
|
CallbackUrl: request.CallbackUrl,
|
||||||
|
TimeLimitMs: request.TimeLimitMs,
|
||||||
|
MemoryLimitMb: request.MemoryLimitMb
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send to appropriate worker based on language
|
// Send to appropriate worker based on language
|
||||||
|
|||||||
@@ -9,4 +9,14 @@ public class LocalSubmitModel
|
|||||||
public string SourceCode { get; set; } = string.Empty;
|
public string SourceCode { get; set; } = string.Empty;
|
||||||
public string CallbackUrl { get; set; } = string.Empty;
|
public string CallbackUrl { get; set; } = string.Empty;
|
||||||
public IFormFile? Package { get; set; }
|
public IFormFile? Package { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional time limit override in milliseconds (for testing purposes)
|
||||||
|
/// </summary>
|
||||||
|
public int? TimeLimitMs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional memory limit override in megabytes (for testing purposes)
|
||||||
|
/// </summary>
|
||||||
|
public int? MemoryLimitMb { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ public class WorkerClientService : IWorkerClientService
|
|||||||
form.Add(new StringContent(submit.SourceCode), "SourceCode");
|
form.Add(new StringContent(submit.SourceCode), "SourceCode");
|
||||||
form.Add(new StringContent(submit.CallbackUrl), "CallbackUrl");
|
form.Add(new StringContent(submit.CallbackUrl), "CallbackUrl");
|
||||||
|
|
||||||
|
// Add optional limit overrides (for testing purposes)
|
||||||
|
if (submit.TimeLimitMs.HasValue)
|
||||||
|
{
|
||||||
|
form.Add(new StringContent(submit.TimeLimitMs.Value.ToString()), "TimeLimitMs");
|
||||||
|
}
|
||||||
|
if (submit.MemoryLimitMb.HasValue)
|
||||||
|
{
|
||||||
|
form.Add(new StringContent(submit.MemoryLimitMb.Value.ToString()), "MemoryLimitMb");
|
||||||
|
}
|
||||||
|
|
||||||
// Add package file
|
// Add package file
|
||||||
var fileStream = File.OpenRead(packagePath);
|
var fileStream = File.OpenRead(packagePath);
|
||||||
var fileContent = new StreamContent(fileStream);
|
var fileContent = new StreamContent(fileStream);
|
||||||
@@ -78,10 +88,10 @@ public class WorkerClientService : IWorkerClientService
|
|||||||
{
|
{
|
||||||
var workerUrl = language.ToLowerInvariant() switch
|
var workerUrl = language.ToLowerInvariant() switch
|
||||||
{
|
{
|
||||||
"c++" or "cpp" => _configuration["Workers:Cpp"],
|
"c++" => _configuration["Workers:Cpp"],
|
||||||
"java" => _configuration["Workers:Java"],
|
"java" => _configuration["Workers:Java"],
|
||||||
"kotlin" => _configuration["Workers:Kotlin"],
|
"kotlin" => _configuration["Workers:Kotlin"],
|
||||||
"c#" or "csharp" => _configuration["Workers:CSharp"],
|
"c#" => _configuration["Workers:CSharp"],
|
||||||
"python" => _configuration["Workers:Python"],
|
"python" => _configuration["Workers:Python"],
|
||||||
_ => throw new NotSupportedException($"Language {language} is not supported")
|
_ => throw new NotSupportedException($"Language {language} is not supported")
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ public class TestController : ControllerBase
|
|||||||
SourceCode = request.SourceCode,
|
SourceCode = request.SourceCode,
|
||||||
CallbackUrl = request.CallbackUrl,
|
CallbackUrl = request.CallbackUrl,
|
||||||
Package = null, // Will use file path instead
|
Package = null, // Will use file path instead
|
||||||
PackageFilePath = packageFilePath
|
PackageFilePath = packageFilePath,
|
||||||
|
TimeLimitMs = request.TimeLimitMs,
|
||||||
|
MemoryLimitMb = request.MemoryLimitMb
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start testing in background
|
// Start testing in background
|
||||||
@@ -109,4 +111,14 @@ public class TestRequest
|
|||||||
public string CallbackUrl { get; set; } = string.Empty;
|
public string CallbackUrl { get; set; } = string.Empty;
|
||||||
public IFormFile? Package { get; set; }
|
public IFormFile? Package { get; set; }
|
||||||
public string? PackageFilePath { get; set; } // Internal use - path to saved package file
|
public string? PackageFilePath { get; set; } // Internal use - path to saved package file
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional time limit override in milliseconds (for testing purposes)
|
||||||
|
/// </summary>
|
||||||
|
public int? TimeLimitMs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional memory limit override in megabytes (for testing purposes)
|
||||||
|
/// </summary>
|
||||||
|
public int? MemoryLimitMb { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,17 @@ public class TestingService : ITestingService
|
|||||||
|
|
||||||
_logger.LogInformation("Compilation successful");
|
_logger.LogInformation("Compilation successful");
|
||||||
|
|
||||||
|
// Check for limit overrides (for testing purposes)
|
||||||
|
var timeLimitOverride = request.TimeLimitMs;
|
||||||
|
var memoryLimitOverride = request.MemoryLimitMb;
|
||||||
|
|
||||||
|
if (timeLimitOverride.HasValue || memoryLimitOverride.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Using limit overrides - TimeLimit: {TimeLimit}ms, MemoryLimit: {MemoryLimit}MB",
|
||||||
|
timeLimitOverride?.ToString() ?? "default",
|
||||||
|
memoryLimitOverride?.ToString() ?? "default");
|
||||||
|
}
|
||||||
|
|
||||||
// Send testing status
|
// Send testing status
|
||||||
await SendStatusAsync(request, State.Testing, ErrorCode.None, "Running tests", 0, package.TestCases.Count);
|
await SendStatusAsync(request, State.Testing, ErrorCode.None, "Running tests", 0, package.TestCases.Count);
|
||||||
|
|
||||||
@@ -100,12 +111,16 @@ public class TestingService : ITestingService
|
|||||||
await SendStatusAsync(request, State.Testing, ErrorCode.None,
|
await SendStatusAsync(request, State.Testing, ErrorCode.None,
|
||||||
$"Running test {testCase.Number}", testCase.Number, package.TestCases.Count);
|
$"Running test {testCase.Number}", testCase.Number, package.TestCases.Count);
|
||||||
|
|
||||||
|
// Use override limits if provided, otherwise use test case limits
|
||||||
|
var timeLimit = timeLimitOverride ?? testCase.TimeLimit;
|
||||||
|
var memoryLimit = memoryLimitOverride ?? testCase.MemoryLimit;
|
||||||
|
|
||||||
// Execute solution
|
// Execute solution
|
||||||
var executionResult = await executionService.ExecuteAsync(
|
var executionResult = await executionService.ExecuteAsync(
|
||||||
compilationResult.ExecutablePath!,
|
compilationResult.ExecutablePath!,
|
||||||
testCase.InputFilePath,
|
testCase.InputFilePath,
|
||||||
testCase.TimeLimit,
|
timeLimit,
|
||||||
testCase.MemoryLimit);
|
memoryLimit);
|
||||||
|
|
||||||
// Check for execution errors
|
// Check for execution errors
|
||||||
if (executionResult.TimeLimitExceeded)
|
if (executionResult.TimeLimitExceeded)
|
||||||
|
|||||||
Reference in New Issue
Block a user