Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tester: use job id instead of submission id #1102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -445,9 +445,9 @@ public Collection<WorkItem> run(Path scratchPath) {

var lines = List.of(
"<!-- TEST STARTED -->",
"<!-- " + jobId + " -->",
"<!-- " + job.id() + " -->",
"<!-- " + fetchHead.hex() + " -->",
"A test job has been started with id: " + jobId
"A test job has been started with id: " + job.id()
);
pr.addComment(String.join("\n", lines));
} else {
@@ -553,10 +553,13 @@ void approvedPendingRequestShouldBeStarted() throws IOException {
var approveComment = new Comment("2", "/test approve", member, now, now);
pr.comments.add(approveComment);

var expectedJobId = "null-1337-17-0";
var expectedSubmissionId = "null-1337-17-0";
var expectedId = "0-17-1337-null";
var expectedJob = new InMemoryJob();
expectedJob.id = expectedId;
expectedJob.status = new Job.Status(0, 1, 7);
ci.jobs.put(expectedJobId, expectedJob);
ci.jobs.put(expectedId, expectedJob);
ci.jobs.put(expectedSubmissionId, expectedJob);

item.run(scratch);

@@ -569,15 +572,15 @@ void approvedPendingRequestShouldBeStarted() throws IOException {
var fourthComment = comments.get(3);
lines = fourthComment.body().split("\n");
assertEquals("<!-- TEST STARTED -->", lines[0]);
assertEquals("<!-- " + expectedJobId + " -->", lines[1]);
assertEquals("<!-- " + expectedId + " -->", lines[1]);
assertEquals("<!-- " + head.hex() + " -->", lines[2]);
assertEquals("A test job has been started with id: " + expectedJobId, lines[3]);
assertEquals("A test job has been started with id: " + expectedId, lines[3]);

assertEquals(1, ci.submissions.size());
var submission = ci.submissions.get(0);
assertTrue(submission.source.startsWith(storage));
assertEquals(List.of("tier1"), submission.jobs);
assertEquals(expectedJobId, submission.id);
assertEquals(expectedSubmissionId, submission.id);

var checks = pr.checks(pr.headHash());
assertEquals(1, checks.keySet().size());
@@ -662,10 +665,13 @@ void cancellingApprovedPendingRequestShouldBeCancel() throws IOException {
var approveComment = new Comment("2", "/test approve", member, now, now);
pr.comments.add(approveComment);

var expectedJobId = "null-1337-17-0";
var expectedSubmissionId = "null-1337-17-0";
var expectedId = "0-17-1337-null";
var expectedJob = new InMemoryJob();
expectedJob.status = new Job.Status(0, 1, 7);
ci.jobs.put(expectedJobId, expectedJob);
expectedJob.id = expectedId;
ci.jobs.put(expectedId, expectedJob);
ci.jobs.put(expectedSubmissionId, expectedJob);

item.run(scratch);

@@ -678,15 +684,15 @@ void cancellingApprovedPendingRequestShouldBeCancel() throws IOException {
var fourthComment = comments.get(3);
lines = fourthComment.body().split("\n");
assertEquals("<!-- TEST STARTED -->", lines[0]);
assertEquals("<!-- " + expectedJobId + " -->", lines[1]);
assertEquals("<!-- " + expectedId + " -->", lines[1]);
assertEquals("<!-- " + head.hex() + " -->", lines[2]);
assertEquals("A test job has been started with id: " + expectedJobId, lines[3]);
assertEquals("A test job has been started with id: " + expectedId, lines[3]);

assertEquals(1, ci.submissions.size());
var submission = ci.submissions.get(0);
assertTrue(submission.source.startsWith(storage));
assertEquals(List.of("tier1"), submission.jobs);
assertEquals(expectedJobId, submission.id);
assertEquals(expectedSubmissionId, submission.id);

var checks = pr.checks(pr.headHash());
assertEquals(1, checks.keySet().size());
@@ -711,7 +717,7 @@ void cancellingApprovedPendingRequestShouldBeCancel() throws IOException {
.get()
.contains("## Status\n0 jobs completed, 1 job running, 7 jobs not yet started\n"));

assertEquals(expectedJobId, ci.cancelled.get(0));
assertEquals(expectedId, ci.cancelled.get(0));
}
}

@@ -877,10 +883,13 @@ void finishedJobShouldResultInFinishedComment() throws IOException {
var approveComment = new Comment("2", "/test approve", member, now, now);
pr.comments.add(approveComment);

var expectedJobId = "null-1337-17-0";
var expectedSubmissionId = "null-1337-17-0";
var expectedId = "0-17-1337-null";
var expectedJob = new InMemoryJob();
expectedJob.status = new Job.Status(0, 1, 7);
ci.jobs.put(expectedJobId, expectedJob);
expectedJob.id = expectedId;
ci.jobs.put(expectedId, expectedJob);
ci.jobs.put(expectedSubmissionId, expectedJob);

item.run(scratch);

@@ -893,15 +902,15 @@ void finishedJobShouldResultInFinishedComment() throws IOException {
var fourthComment = comments.get(3);
lines = fourthComment.body().split("\n");
assertEquals("<!-- TEST STARTED -->", lines[0]);
assertEquals("<!-- " + expectedJobId + " -->", lines[1]);
assertEquals("<!-- " + expectedId + " -->", lines[1]);
assertEquals("<!-- " + head.hex() + " -->", lines[2]);
assertEquals("A test job has been started with id: " + expectedJobId, lines[3]);
assertEquals("A test job has been started with id: " + expectedId, lines[3]);

assertEquals(1, ci.submissions.size());
var submission = ci.submissions.get(0);
assertTrue(submission.source.startsWith(storage));
assertEquals(List.of("tier1"), submission.jobs);
assertEquals(expectedJobId, submission.id);
assertEquals(expectedSubmissionId, submission.id);

var checks = pr.checks(pr.headHash());
assertEquals(1, checks.keySet().size());
@@ -912,7 +921,7 @@ void finishedJobShouldResultInFinishedComment() throws IOException {
.get()
.contains("0 jobs completed, 1 job running, 7 jobs not yet started"));

var job = ci.jobs.get(expectedJobId);
var job = ci.jobs.get(expectedId);
assertNotNull(job);
job.id = "id";
job.state = Job.State.COMPLETED;
@@ -931,9 +940,9 @@ void finishedJobShouldResultInFinishedComment() throws IOException {
var finishedComment = comments.get(4);
lines = finishedComment.body().split("\n");
assertEquals("<!-- TEST FINISHED -->", lines[0]);
assertEquals("<!-- " + expectedJobId +" -->", lines[1]);
assertEquals("<!-- " + expectedId +" -->", lines[1]);
assertEquals("<!-- " + head.hex() +" -->", lines[2]);
assertEquals("@duke your test job with id " + expectedJobId + " for commits up until " +
assertEquals("@duke your test job with id " + expectedId + " for commits up until " +
head.abbreviate() + " has finished.", lines[3]);

checks = pr.checks(pr.headHash());
@@ -1002,10 +1011,13 @@ void userOnApprovelistDoesNotNeedApproval() throws IOException {
var item = new TestWorkItem(ci, approvers, Set.of("0"), available, defaultJobs, name, storage, pr,
u -> true);

var expectedJobId = "null-1337-17-0";
var expectedSubmissionId = "null-1337-17-0";
var expectedId = "0-17-1337-null";
var expectedJob = new InMemoryJob();
expectedJob.status = new Job.Status(0, 1, 7);
ci.jobs.put(expectedJobId, expectedJob);
expectedJob.id = expectedId;
ci.jobs.put(expectedId, expectedJob);
ci.jobs.put(expectedSubmissionId, expectedJob);

item.run(scratch);

@@ -1017,15 +1029,15 @@ void userOnApprovelistDoesNotNeedApproval() throws IOException {

var lines = secondComment.body().split("\n");
assertEquals("<!-- TEST STARTED -->", lines[0]);
assertEquals("<!-- " + expectedJobId + " -->", lines[1]);
assertEquals("<!-- " + expectedId + " -->", lines[1]);
assertEquals("<!-- " + head.hex() + " -->", lines[2]);
assertEquals("A test job has been started with id: " + expectedJobId, lines[3]);
assertEquals("A test job has been started with id: " + expectedId, lines[3]);

assertEquals(1, ci.submissions.size());
var submission = ci.submissions.get(0);
assertTrue(submission.source.startsWith(storage));
assertEquals(List.of("tier1"), submission.jobs);
assertEquals(expectedJobId, submission.id);
assertEquals(expectedSubmissionId, submission.id);

var checks = pr.checks(pr.headHash());
assertEquals(1, checks.keySet().size());