update test endpoint
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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