Skip to content

Commit

Permalink
ENG-1788 - Reverts PR#3 and adds test for queue specific polling
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoruDev committed Jan 11, 2024
1 parent 6d68ff7 commit 05a3210
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (c *Collector) collectAllQueues(httpClient *http.Client, result *Result) er
result.Queues[queueName][RunningJobsCount] = queueJobMetrics.Running
result.Queues[queueName][UnfinishedJobsCount] = queueJobMetrics.Total
result.Queues[queueName][WaitingJobsCount] = queueJobMetrics.Waiting
result.Queues[queueName][BintiRequiredAgentCount] = queueJobMetrics.Waiting
result.Queues[queueName][BintiRequiredAgentCount] = queueJobMetrics.Waiting + queueJobMetrics.Running
}

for queueName, queueAgentMetrics := range allMetrics.Agents.Queues {
Expand All @@ -236,7 +236,6 @@ func (c *Collector) collectAllQueues(httpClient *http.Client, result *Result) er
result.Queues[queueName][BusyAgentCount] = queueAgentMetrics.Busy
result.Queues[queueName][TotalAgentCount] = queueAgentMetrics.Total
result.Queues[queueName][BusyAgentPercentage] = busyAgentPercentage(queueAgentMetrics)
result.Queues[queueName][BintiRequiredAgentCount] = result.Queues[queueName][BintiRequiredAgentCount] + queueAgentMetrics.Total
}

return nil
Expand Down Expand Up @@ -324,7 +323,7 @@ func (c *Collector) collectQueue(httpClient *http.Client, result *Result, queue
BusyAgentCount: queueMetrics.Agents.Busy,
TotalAgentCount: queueMetrics.Agents.Total,
BusyAgentPercentage: busyAgentPercentage(queueMetrics.Agents),
BintiRequiredAgentCount: queueMetrics.Jobs.Waiting + queueMetrics.Agents.Busy,
BintiRequiredAgentCount: queueMetrics.Jobs.Waiting + queueMetrics.Jobs.Running,
}
return nil
}
Expand Down
6 changes: 5 additions & 1 deletion collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func TestCollectorWithSomeJobsAndAgentsForAllQueues(t *testing.T) {
"waiting": 1
},
"binti": {
"waiting": 1
"waiting": 1,
"running": 1
}
}
},
Expand Down Expand Up @@ -249,6 +250,7 @@ func TestCollectorWithSomeJobsAndAgentsForAQueue(t *testing.T) {
},
"jobs": {
"scheduled": 3,
"waiting": 2,
"running": 1,
"total": 4
},
Expand Down Expand Up @@ -285,6 +287,8 @@ func TestCollectorWithSomeJobsAndAgentsForAQueue(t *testing.T) {
{"Queue.deploy", res.Queues["deploy"], ScheduledJobsCount, 3},
{"Queue.deploy", res.Queues["deploy"], UnfinishedJobsCount, 4},
{"Queue.deploy", res.Queues["deploy"], TotalAgentCount, 1},
{"Queue.deploy", res.Queues["deploy"], WaitingJobsCount, 2},
{"Queue.deploy", res.Queues["deploy"], BintiRequiredAgentCount, 3},
{"Queue.deploy", res.Queues["deploy"], BusyAgentCount, 1},
{"Queue.deploy", res.Queues["deploy"], IdleAgentCount, 0},
{"Queue.deploy", res.Queues["deploy"], BusyAgentPercentage, 100},
Expand Down

0 comments on commit 05a3210

Please sign in to comment.