-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/cpuutil strategy segfault (#28)
fixed cpu-util calc bug - when tasks complete exec. When tasks complete execution, task-ranker would no longer receive cpu usage data for those retired tasks. Previously, the cpu-util calculation depended on the previously recorded cpu usage information. The tasks for which cpu usage data is retrieved can be assumed to be currently active and therefore, cpu utilization is calculated just for these if cpu usage was previously recorded for them (we need two data points to calculate cpu utilization). Added test case that tests cpu-util ranking strategy when tasks retire and new tasks are co-located. To reduce redundant code, moved *model.Sample generation into a function. Moved getMockDataSample(), uniqueTaskSets, hostname, availableCpus and elapsedTimeSeconds into strategies/testutil.go. Added mockDataSampleStream() to be used by cpushares test code. Refactored cpushares test code to use mockDataSampleStream(). consolidated test utilities in strategies/testutil. Added additional tests for cpu-util strategy testing. 1. Test when there is no cpu usage data. 2. Test when the cpu usage information is available for a different set of tasks compared to the previous fetch.
- Loading branch information
1 parent
0f0da6c
commit eea6f06
Showing
6 changed files
with
405 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2020 Pradyumna Kaushik | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package strategies | ||
|
||
import ( | ||
"github.com/pradykaushik/task-ranker/logger" | ||
"log" | ||
"testing" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
err := logger.Configure() | ||
if err != nil { | ||
log.Println("could not configure logger for strategy testing") | ||
} | ||
m.Run() | ||
err = logger.Done() | ||
if err != nil { | ||
log.Println("could not close logger after strategy testing") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.