Skip to content

Commit 9889f19

Browse files
authored
Merge pull request #25 from problem-judge/dev/improve-testing
Improve testing
2 parents c42bc21 + ff901c3 commit 9889f19

File tree

53 files changed

+1185
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1185
-127
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ clients/clients
77
.DS_Store
88
clients/configs
99
custom
10+
tools/polygon_importer/polygon_importer
11+
tools/polygon_importer/run.sh

clients/frontend/admin/components/submission/CompilationData.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function RenderCompilationData(compilationData, submission, changeCompila
4444
action: "show",
4545
})
4646
}
47-
47+
4848
return (
4949
<>
5050
<h5 className="mb-3">Compilation result</h5>

clients/frontend/admin/pages/NewSubmission.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import axios from "axios";
66
import {useNavigate, useSearchParams} from "react-router-dom";
77

88
export default function NewSubmission() {
9-
const [params, setParams] = useSearchParams()
9+
const [params, _] = useSearchParams()
1010

1111
const [alert, setAlert] = useState({
1212
hasAlert: false,
@@ -56,7 +56,7 @@ export default function NewSubmission() {
5656
name="problem_id"
5757
id="problem_id"
5858
required={true}
59-
defaultValue={params.problem_id || ""}
59+
defaultValue={params.get("problem_id") || ""}
6060
/>
6161
</div>
6262
</div>

clients/frontend/admin/pages/Problem.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ export default function Problems() {
6161
<div className="mb-3">
6262
<Link to={`/admin/submissions?problem_id=${problem.id}`}>Submissions</Link>
6363
</div>
64+
<div className="mb-3">
65+
<Link to={`/admin/new/submission?problem_id=${problem.id}`}>Send submission</Link>
66+
</div>
6467
</div>
6568
<hr className="mt-4 mb-4"/>
6669
<div className="px-4 px-sm-5 mx-2 pb-5">
67-
{content}
70+
{content}
6871
</div>
6972
</div>
7073
)

clients/frontend/admin/pages/Status.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default function Status() {
9494
</tr>
9595
</thead>
9696
<tbody>
97-
{invoker.active_jobs.map((job, jobIndex) => (
97+
{invoker.testing_jobs.map((job, jobIndex) => (
9898
<tr key={`${index}-${jobIndex}`}>
9999
<td>{getJobType(job.type)}</td>
100100
<td>{job.submit_id}</td>

clients/frontend/admin/pages/Submission.jsx

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -89,71 +89,73 @@ export default function Submission() {
8989
</tr>
9090
</thead>
9191
<tbody>
92-
<tr key={submission.id}>
93-
<th scope="row">{submission.id}</th>
94-
<td><Link to={`/admin/problem/${submission.problem_id}`}>{submission.problem_id}</Link></td>
95-
<td>{submission.language}</td>
96-
<td>{submission.score}</td>
97-
<td>{SubmissionVerdict(submission)}</td>
98-
</tr>
92+
<tr key={submission.id}>
93+
<th scope="row">{submission.id}</th>
94+
<td><Link to={`/admin/problem/${submission.problem_id}`}>{submission.problem_id}</Link></td>
95+
<td>{submission.language}</td>
96+
<td>{submission.score}</td>
97+
<td>{SubmissionVerdict(submission)}</td>
98+
</tr>
9999
</tbody>
100100
</table>
101+
<p>Время начала тестирования: {submission.created_at}</p>
102+
<p>Время окончания тестирования: {submission.updated_at}</p>
101103
{RenderCompilationData(compilationData, submission, changeCompilationData)}
102104
{submission.group_results ? (
103105
<>
104-
<h5 className="mb-3">Group results</h5>
105-
<div className="row">
106-
<div className="col-12 col-md-10 col-lg-8">
107-
<table className="table mb-3">
108-
<thead>
109-
<tr>
110-
<th scope="row">Name</th>
111-
<th scope="row">Score</th>
112-
<th scope="row">Passed</th>
113-
</tr>
114-
</thead>
115-
<tbody>
116-
{submission.group_results.map((group, index) => (
117-
<tr key={index}>
118-
<td>{group.group_name}</td>
119-
<td>{group.points}</td>
120-
<td>{group.passed ? (
121-
<span className="text-success">Yes</span>
122-
) : (
123-
<span className="text-danger">No</span>
124-
)}</td>
106+
<h5 className="mb-3">Group results</h5>
107+
<div className="row">
108+
<div className="col-12 col-md-10 col-lg-8">
109+
<table className="table mb-3">
110+
<thead>
111+
<tr>
112+
<th scope="row">Name</th>
113+
<th scope="row">Score</th>
114+
<th scope="row">Passed</th>
125115
</tr>
126-
))}
127-
</tbody>
128-
</table>
116+
</thead>
117+
<tbody>
118+
{submission.group_results.map((group, index) => (
119+
<tr key={index}>
120+
<td>{group.group_name}</td>
121+
<td>{group.points}</td>
122+
<td>{group.passed ? (
123+
<span className="text-success">Yes</span>
124+
) : (
125+
<span className="text-danger">No</span>
126+
)}</td>
127+
</tr>
128+
))}
129+
</tbody>
130+
</table>
131+
</div>
129132
</div>
130-
</div>
131133
</>
132134
) : null}
133135
{submission.test_results ? (
134136
<>
135-
<h5 className="mb-3">Test results</h5>
136-
<table className="table mb-3">
137-
<thead>
138-
<tr>
139-
<th scope="row">#</th>
140-
<th scope="row">Verdict</th>
141-
<th scope="row">Points</th>
142-
<th scope="row">Time</th>
143-
<th scope="row">Memory</th>
144-
<th scope="row">Wall time</th>
145-
<th scope="row">Exit code</th>
146-
<th scope="row">More info</th>
147-
</tr>
148-
</thead>
149-
<tbody>
150-
{
151-
submission.test_results.map(testResult => (
152-
RenderTest(tests[testResult.test_number - 1], testResult, changeTests)
153-
))
154-
}
155-
</tbody>
156-
</table>
137+
<h5 className="mb-3">Test results</h5>
138+
<table className="table mb-3">
139+
<thead>
140+
<tr>
141+
<th scope="row">#</th>
142+
<th scope="row">Verdict</th>
143+
<th scope="row">Points</th>
144+
<th scope="row">Time</th>
145+
<th scope="row">Memory</th>
146+
<th scope="row">Wall time</th>
147+
<th scope="row">Exit code</th>
148+
<th scope="row">More info</th>
149+
</tr>
150+
</thead>
151+
<tbody>
152+
{
153+
submission.test_results.map(testResult => (
154+
RenderTest(tests[testResult.test_number - 1], testResult, changeTests)
155+
))
156+
}
157+
</tbody>
158+
</table>
157159
</>
158160
) : null}
159161
</div>

clients/resources/static/admin/admin.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/config/config.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Config struct {
1717
Invoker *InvokerConfig `yaml:"Invoker,omitempty"`
1818
Master *MasterConfig `yaml:"Master,omitempty"`
1919
Storage *StorageConfig `yaml:"Storage,omitempty"`
20-
// TODO: Add instances here
2120

2221
DB DBConfig `yaml:"DB"`
2322
// if instance is set up on server, leave connection empty
@@ -48,7 +47,13 @@ func fillInConfig(config *Config) {
4847
}
4948

5049
fillInConnections(config)
51-
fillInMasterConfig(config.Master)
52-
fillInStorageConfig(config.Storage)
53-
FillInInvokerConfig(config.Invoker)
50+
if config.Master != nil {
51+
fillInMasterConfig(config.Master)
52+
}
53+
if config.Storage != nil {
54+
fillInStorageConfig(config.Storage)
55+
}
56+
if config.Invoker != nil {
57+
FillInInvokerConfig(config.Invoker)
58+
}
5459
}

common/config/invoker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import "time"
44

55
type InvokerConfig struct {
66
// PublicAddress defines address for public access to invoker from master if the server is set up locally with some proxy
7-
PublicAddress *string `yaml:"PublicAddress,omitempty"`
7+
PublicAddress *string `yaml:"PublicAddress,omitempty"`
8+
AutodetectPublicAddress *bool `yaml:"AutodetectPublicAddress,omitempty"`
89

910
Threads int `yaml:"Threads"`
1011
Sandboxes int `yaml:"Sandboxes"`

common/connectors/invokerconn/connector.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ func (c *Connector) ResetCache() error {
3333
r := c.connection.R()
3434
return connector.ReceiveEmpty(r, "/invoker/reset_cache", resty.MethodPost)
3535
}
36+
37+
func (c *Connector) StopJob(jobID string) error {
38+
r := c.connection.R()
39+
r.SetBody(jobID)
40+
return connector.ReceiveEmpty(r, "/invoker/job/stop", resty.MethodPost)
41+
}

0 commit comments

Comments
 (0)