forked from opensearch-project/performance-analyzer
-
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.
Signed-off-by: Gagan Juneja <[email protected]>
- Loading branch information
Gagan Juneja
committed
Jul 19, 2024
1 parent
1a3b223
commit 7b2e1e8
Showing
5 changed files
with
98 additions
and
68 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
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
27 changes: 27 additions & 0 deletions
27
src/test/java/org/opensearch/performanceanalyzer/util/UtilsTests.java
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,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.performanceanalyzer.util; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class UtilsTests { | ||
|
||
@Test | ||
public void testCPUUtilization() { | ||
Assert.assertEquals(0.5, Utils.calculateCPUUtilization(2, 5, 5), 0.0); | ||
Assert.assertEquals(1.0, Utils.calculateCPUUtilization(1, 5, 5), 0.0); | ||
Assert.assertEquals( | ||
Double.valueOf(10 / 15.0), Utils.calculateCPUUtilization(3, 5, 10), 0.0); | ||
} | ||
|
||
@Test | ||
public void testCPUUtilizationZeroValue() { | ||
Assert.assertEquals(0.0, Utils.calculateCPUUtilization(2, 5, 0), 0.0); | ||
Assert.assertEquals(0.0, Utils.calculateCPUUtilization(2, 0, 5), 0.0); | ||
Assert.assertEquals(0.0, Utils.calculateCPUUtilization(0, 5, 5), 0.0); | ||
} | ||
} |