Large test case sizes fix
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 18 Sep 2019 02:54:35 +0000 (21:54 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 18 Sep 2019 02:54:35 +0000 (21:54 -0500)
codebox/migrations.moon
codebox/nginx.conf
codebox/views/ssr/job_result.moon
executer/app/executer.coffee
executer/app/executers/c_executer.coffee
executer/app/executers/py_executer.coffee
executer/main.coffee

index 7062750e52f4136f785fe8f0eb9ee098e6916c43..2c769aa7abc5848ba0061076355f6fc7e79b2247 100644 (file)
@@ -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)"
                }
index 33c48d121cb221ff2d76912c8e380a47f861723a..6649d8f895dc687f6ac09ddb99c048aed648bb0a 100644 (file)
@@ -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";
index aaf5763c96efa62ad9914937f2ef05a06d467907..5279864c545ccdbb28f29326a205e7ef7b32d660 100644 (file)
@@ -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
index cbf394d6072dd8e44f62b990237609aedf69cde5..7428023c1e0522a1c83382349e3bf95a0886d191 100644 (file)
@@ -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
 
index 50a36536716c93b868167f6efef049cdfa441689..a0aa8f704129f734499662354d910094911c1143 100644 (file)
@@ -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 }
index a040a04af1703554784da3e24a0e36764289b4f0..60d6311d46732485b98e2f6f6ec45b4a3b286e5b 100644 (file)
@@ -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 }
index 6216e2d64e4ed90664856f29d409517165633921..254bd938ec3a3d2e7e5aaafb6363a88229438e06 100644 (file)
@@ -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)