mirror of
https://github.com/ohwgiles/laminar.git
synced 2026-11-02 08:34:44 +00:00
Fix page count underflow for jobs with no completed runs
The job status page computes the number of pages as (nRuns-1) / runsPerPage + 1 with nRuns unsigned. A job whose first run is still in progress has no completed builds, so nRuns is 0 and the subtraction wraps, displaying "Page 1 of 214748365". Report a single page in that case, and add a functional test for it.
This commit is contained in:
committed by
Oliver Giles
parent
9d928ccad8
commit
9968f74ae9
@@ -307,7 +307,7 @@ std::string Laminar::getStatus(MonitorScope scope) {
|
||||
.bind(scope.job)
|
||||
.fetch<uint,uint>([&](uint nRuns, uint averageRuntime){
|
||||
j.set("averageRuntime", averageRuntime);
|
||||
j.set("pages", (nRuns-1) / runsPerPage + 1);
|
||||
j.set("pages", nRuns ? (nRuns-1) / runsPerPage + 1 : 1);
|
||||
j.startObject("sort");
|
||||
j.set("page", scope.page)
|
||||
.set("field", scope.field)
|
||||
|
||||
@@ -163,6 +163,18 @@ TEST_F(LaminarFixture, JobDescription) {
|
||||
EXPECT_STREQ("bar", data["description"].GetString());
|
||||
}
|
||||
|
||||
TEST_F(LaminarFixture, JobPagesWithoutRuns) {
|
||||
defineJob("foo", "true");
|
||||
auto es = eventSource("/jobs/foo");
|
||||
ioContext->waitScope.poll();
|
||||
ASSERT_EQ(1, es->messages().size());
|
||||
auto json = es->messages().front().GetObject();
|
||||
ASSERT_TRUE(json.HasMember("data"));
|
||||
auto data = json["data"].GetObject();
|
||||
ASSERT_TRUE(data.HasMember("pages"));
|
||||
EXPECT_EQ(1, data["pages"].GetInt());
|
||||
}
|
||||
|
||||
TEST_F(LaminarFixture, QueueFront) {
|
||||
setNumExecutors(0);
|
||||
defineJob("foo", "true");
|
||||
|
||||
Reference in New Issue
Block a user