fix: final
Co-authored-by: cxy004 <cxy004@qq.com> Co-authored-by: wzt <w.zhongtao@qq.com>
This commit is contained in:
parent
3140a60e67
commit
593e8eb92e
2
Makefile
2
Makefile
@ -16,7 +16,7 @@ all: clean build
|
|||||||
server: swagger dep
|
server: swagger dep
|
||||||
$(GOBUILD) -o server ./cmd/server
|
$(GOBUILD) -o server ./cmd/server
|
||||||
|
|
||||||
runner: dep
|
runner: swagger dep
|
||||||
$(GOBUILD) -o runner ./cmd/runner
|
$(GOBUILD) -o runner ./cmd/runner
|
||||||
|
|
||||||
build: runner server
|
build: runner server
|
||||||
|
@ -39,6 +39,7 @@ func (h *handler) Details(c *gin.Context) {
|
|||||||
pv, status := h.problemService.QueryLatestVersion(req.Pid)
|
pv, status := h.problemService.QueryLatestVersion(req.Pid)
|
||||||
if status != e.Success {
|
if status != e.Success {
|
||||||
e.Pong(c, status, nil)
|
e.Pong(c, status, nil)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
e.Pong(c, e.Success, gin.H{
|
e.Pong(c, e.Success, gin.H{
|
||||||
"problem": p,
|
"problem": p,
|
||||||
|
@ -19,7 +19,7 @@ type queryByVersionRequest struct {
|
|||||||
// @Accept application/x-www-form-urlencoded
|
// @Accept application/x-www-form-urlencoded
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param pvid formData uint true "problem version id"
|
// @Param pvid formData uint true "problem version id"
|
||||||
// @Param offset formData int true "start position"
|
// @Param offset formData int false "start position"
|
||||||
// @Param limit formData int true "limit number of records"
|
// @Param limit formData int true "limit number of records"
|
||||||
// @Response 200 {object} e.Response "[]*model.status"
|
// @Response 200 {object} e.Response "[]*model.status"
|
||||||
// @Router /v1/status/query/problem_version [post]
|
// @Router /v1/status/query/problem_version [post]
|
||||||
|
@ -23,13 +23,12 @@ type queryResponse struct {
|
|||||||
// @Description Query submissions
|
// @Description Query submissions
|
||||||
// @Accept application/x-www-form-urlencoded
|
// @Accept application/x-www-form-urlencoded
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param pid formData uint true "problem id"
|
// @Param pid formData uint false "problem id"
|
||||||
// @Param uid formData uint true "user id"
|
// @Param uid formData uint false "user id"
|
||||||
// @Param offset formData int true "start position"
|
// @Param offset formData int false "start position"
|
||||||
// @Param limit formData int true "limit number of records"
|
// @Param limit formData int true "limit number of records"
|
||||||
// @Response 200 {object} e.Response "queryResponse"
|
// @Response 200 {object} e.Response "queryResponse"
|
||||||
// @Router /v1/submission/query [post]
|
// @Router /v1/submission/query [post]
|
||||||
|
|
||||||
func (h *handler) Query(c *gin.Context) {
|
func (h *handler) Query(c *gin.Context) {
|
||||||
req := new(queryRequest)
|
req := new(queryRequest)
|
||||||
|
|
||||||
|
70
resource/bench/bench.py
Normal file
70
resource/bench/bench.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
|
from locust import HttpUser, task
|
||||||
|
|
||||||
|
|
||||||
|
def randomstring(length):
|
||||||
|
return ''.join(random.choice(string.ascii_letters) for i in range(length))
|
||||||
|
|
||||||
|
|
||||||
|
class WOJUser(HttpUser):
|
||||||
|
|
||||||
|
def on_start(self):
|
||||||
|
self.username = randomstring(16)
|
||||||
|
self.nickname = randomstring(16)
|
||||||
|
self.password = randomstring(16)
|
||||||
|
|
||||||
|
with self.client.post("/api/v1/user/create", data={
|
||||||
|
"username": self.username,
|
||||||
|
"nickname": self.nickname,
|
||||||
|
"password": self.password
|
||||||
|
}) as resp:
|
||||||
|
j = resp.json()
|
||||||
|
if j["code"] != 0:
|
||||||
|
resp.failure("create user failed")
|
||||||
|
else:
|
||||||
|
self.token = j["body"]
|
||||||
|
|
||||||
|
@task
|
||||||
|
def view_problem(self):
|
||||||
|
pid = []
|
||||||
|
|
||||||
|
with self.client.post("/api/v1/problem/search") as resp:
|
||||||
|
j = resp.json()
|
||||||
|
if j["code"] != 0:
|
||||||
|
resp.failure("search problem failed")
|
||||||
|
else:
|
||||||
|
for p in j["body"]:
|
||||||
|
pid.append(p["meta"]["ID"])
|
||||||
|
|
||||||
|
for p in pid:
|
||||||
|
with self.client.post("/api/v1/problem/details", data={"pid": pid}) as resp:
|
||||||
|
if resp.json()["code"] != 0:
|
||||||
|
resp.failure("view problem failed")
|
||||||
|
|
||||||
|
@task
|
||||||
|
def submit_code(self):
|
||||||
|
code = """
|
||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
int a, b;
|
||||||
|
cin >> a >> b;
|
||||||
|
cout << a + b;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
with self.client.post("/api/v1/submission/create",
|
||||||
|
headers={"Authorization": "Bearer " + self.token},
|
||||||
|
data={"pid": 5, "language": "cpp", "code": code}
|
||||||
|
) as resp:
|
||||||
|
if resp.json()["code"] != 0:
|
||||||
|
resp.failure("submit code failed")
|
||||||
|
|
||||||
|
@task
|
||||||
|
def view_submission(self):
|
||||||
|
with self.client.post("/api/v1/submission/query", data={"pid": 5, "limit": 100}) as resp:
|
||||||
|
if resp.json()["code"] != 0:
|
||||||
|
resp.failure("view submission failed")
|
0
resource/frontend/.gitignore
vendored
Normal file
0
resource/frontend/.gitignore
vendored
Normal file
@ -5,7 +5,7 @@
|
|||||||
function docker_run() {
|
function docker_run() {
|
||||||
local timeout=${TIMEOUT:-10}
|
local timeout=${TIMEOUT:-10}
|
||||||
local log_file=${LOG_FILE:-"/dev/stderr"}
|
local log_file=${LOG_FILE:-"/dev/stderr"}
|
||||||
local log_limit=${LOG_LIMIT:-1K}
|
local log_limit=${LOG_LIMIT:-4K}
|
||||||
log_info "$DOCKER run with timeout $timeout"
|
log_info "$DOCKER run with timeout $timeout"
|
||||||
CONTAINER_NAME=$(uuidgen)
|
CONTAINER_NAME=$(uuidgen)
|
||||||
(
|
(
|
||||||
@ -15,4 +15,5 @@ function docker_run() {
|
|||||||
$DOCKER run --rm --name "$CONTAINER_NAME" "$@" 2>&1 | head -c "$log_limit" >"$log_file"
|
$DOCKER run --rm --name "$CONTAINER_NAME" "$@" 2>&1 | head -c "$log_limit" >"$log_file"
|
||||||
pkill -P $$
|
pkill -P $$
|
||||||
$DOCKER kill "$CONTAINER_NAME" >/dev/null 2>&1
|
$DOCKER kill "$CONTAINER_NAME" >/dev/null 2>&1
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user