From 26628c24ec84f83658ca8081f607892c84b6ae50 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 17 Sep 2019 21:54:35 -0500 Subject: [PATCH] Large test case sizes fix --- codebox/migrations.moon | 4 ++-- codebox/nginx.conf | 2 ++ codebox/views/ssr/job_result.moon | 5 ++++- executer/app/executer.coffee | 4 +++- executer/app/executers/c_executer.coffee | 4 ++-- executer/app/executers/py_executer.coffee | 4 ++-- executer/main.coffee | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/codebox/migrations.moon b/codebox/migrations.moon index 7062750..2c769aa 100644 --- a/codebox/migrations.moon +++ b/codebox/migrations.moon @@ -47,8 +47,8 @@ import insert from require "lapis.db" { "uuid", types.varchar unique: true }, { "problem_id", types.foreign_key }, { "testcase_order", types.integer, default: 1 } - { "input", types.varchar }, - { "output", types.varchar }, + { "input", types.text }, + { "output", types.text }, "PRIMARY KEY (id)" } diff --git a/codebox/nginx.conf b/codebox/nginx.conf index 33c48d1..6649d8f 100644 --- a/codebox/nginx.conf +++ b/codebox/nginx.conf @@ -19,6 +19,8 @@ http { server { listen ${{PORT}}; lua_code_cache ${{CODE_CACHE}}; + client_max_body_size 0; + client_body_buffer_size 200000k; location / { set $_url "http://192.168.0.4:8080"; diff --git a/codebox/views/ssr/job_result.moon b/codebox/views/ssr/job_result.moon index aaf5763..5279864 100644 --- a/codebox/views/ssr/job_result.moon +++ b/codebox/views/ssr/job_result.moon @@ -70,6 +70,9 @@ class JobResultView extends html.Widget div class: "highlight pad-l-12 pad-r-12 pad-t-4 pad-b-4 split-lr", -> div "Problem:" a href: (@url_for 'problem.description', { problem_name: @problem.short_name }), "#{@problem.name}" + div class: 'hightlight pad-l-12 pad-r-12 pad-t-4 pad-b-4 split-lr', -> + div "Time limit:" + div "#{@problem.time_limit}ms" div class: "highlight pad-l-12 pad-r-12 pad-t-4 pad-b-4 split-lr", -> div "Time submittted:" div "#{ os.date '%c', @time_started }" @@ -105,7 +108,7 @@ class JobResultView extends html.Widget p "------------" if type(@json_data.run_times[i]) == 'number' - p "Run time: #{@json_data.run_times[i] / 1000000}s" + p "Run time: #{@json_data.run_times[i]}ms" else div class: 'header-line', -> div @message diff --git a/executer/app/executer.coffee b/executer/app/executer.coffee index cbf394d..7428023 100644 --- a/executer/app/executer.coffee +++ b/executer/app/executer.coffee @@ -69,7 +69,9 @@ class Executer yield { status: 3, data: { completed: completed, total: total_cases, run_times: run_times } } for test_case in test_cases - res = await executer.execute exec_file.file_path, test_case.input, time_limit + test_case_file = new TempFile test_case.input + res = await executer.execute exec_file.file_path, test_case_file.file_path, time_limit + test_case_file.delete_file() await new Promise (res) -> setTimeout res, 200 diff --git a/executer/app/executers/c_executer.coffee b/executer/app/executers/c_executer.coffee index 50a3653..a0aa8f7 100644 --- a/executer/app/executers/c_executer.coffee +++ b/executer/app/executers/c_executer.coffee @@ -12,13 +12,13 @@ class CExecuter extends BaseExecuter err_output = "" bash_shell.stderr.on 'data', (data) => err_output += data.toString() - bash_shell.stdin.end "echo #{input} | timeout -s SIGKILL #{time_limit / 1000.0} #{path}" + bash_shell.stdin.end "cat #{input} | timeout -s SIGKILL #{time_limit / 1000.0} #{path}" start_time = process.hrtime() res_code = await on_child_exit bash_shell diff_time = process.hrtime start_time - run_time = diff_time[0] * 1000000 + Math.floor(diff_time[1] / 1000) / 1000000 + run_time = (diff_time[0] * 1000000 + Math.floor(diff_time[1] / 1000)) / 1000000 if res_code == 0 return { status: 'SUCCESS', output: output, run_time: run_time } diff --git a/executer/app/executers/py_executer.coffee b/executer/app/executers/py_executer.coffee index a040a04..60d6311 100644 --- a/executer/app/executers/py_executer.coffee +++ b/executer/app/executers/py_executer.coffee @@ -12,13 +12,13 @@ class PyExecuter extends BaseExecuter err_output = "" bash_shell.stderr.on 'data', (data) => err_output += data.toString() - bash_shell.stdin.end "echo #{input} | timeout -s SIGKILL #{time_limit / 1000.0} python3 #{path}" + bash_shell.stdin.end "cat #{input} | timeout -s SIGKILL #{time_limit / 1000.0} python3 #{path}" start_time = process.hrtime() res_code = await on_child_exit bash_shell diff_time = process.hrtime start_time - run_time = diff_time[0] * 1000000 + Math.floor(diff_time[1] / 1000) / 1000000 + run_time = (diff_time[0] * 1000000 + Math.floor(diff_time[1] / 1000)) / 1000000 if res_code == 0 return { status: 'SUCCESS', output: output, run_time: run_time } diff --git a/executer/main.coffee b/executer/main.coffee index 6216e2d..254bd93 100644 --- a/executer/main.coffee +++ b/executer/main.coffee @@ -5,7 +5,7 @@ bodyParser = require 'body-parser' app = express() app.use (morgan 'dev') -app.use bodyParser.urlencoded { extended: true } +app.use bodyParser.urlencoded { extended: true, limit: '20mb' } routes = require './app/routes' routes(app) -- 2.25.1