Skip to content

Commit

Permalink
Fix unit test in linux (#269)
Browse files Browse the repository at this point in the history
* Fix unit test in linux

* Fix linux unit test

* Temp fix dotnet version

* Update

* test

* Fix tests

* Update

* Fix linux unit test

* Fix linux unit test

* Fix tests

* Linux only run unit test
  • Loading branch information
yangpanMS authored Feb 18, 2024
1 parent 9d69294 commit 5e798d8
Show file tree
Hide file tree
Showing 63 changed files with 850 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 8.0.101

- name: Add permission to run shell
run: chmod -R +x *.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 8.0.101

- name: Restore dependencies
run: ./build-restore.cmd
Expand Down
2 changes: 1 addition & 1 deletion build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ echo "[Running Tests]"
echo "--------------------------------------------------"

for file in $(find "$(dirname "$0")/src" -type f -name "*Tests.csproj"); do
dotnet test -c Release "$file" --no-restore --no-build --filter "(Category=Unit|Category=Functional)" --logger "console;verbosity=normal"
dotnet test -c Release "$file" --no-restore --no-build --filter "(Category=Unit)" --logger "console;verbosity=normal"
result=$?
if [ $result -ne 0 ]; then
Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ApacheBenchMetricsParserTests
public void Setup()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\ApacheBench\ApacheBenchResultsExample.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "ApacheBench", "ApacheBenchResultsExample.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new ApacheBenchMetricsParser(this.rawText);
}
Expand Down Expand Up @@ -54,7 +54,7 @@ public void ApacheBenchMetricsParserParsesInputAsExpected()
public void ApacheBenchResultsParserReturnsEmptyResultWhenInvalidResultsAreProvided()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\ApacheBench\ApacheBenchResultsInvalidExample.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "ApacheBench", "ApacheBenchResultsInvalidExample.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new ApacheBenchMetricsParser(this.rawText);
Assert.Throws<WorkloadException>(() => this.testParser.Parse());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Compressor7zipMetricsParserTests
public void Setup()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\Compressor7zip\Compressor7zipResultsExample.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "Compressor7zip", "Compressor7zipResultsExample.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new Compression7zipMetricsParser(this.rawText);
}
Expand All @@ -52,8 +52,8 @@ public void Compressor7zipResultsParserCreatesTheExpectedMetricsFromResults()
public void Compressor7zipResultsParserThrowsWhenInvalidResultsAreProvided()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string IncorrectCompressor7zipoutputPath = Path.Combine(workingDirectory, @"Examples\Compressor7zip\Compressor7zipResultsInvalidExample.txt");
this.rawText = File.ReadAllText(IncorrectCompressor7zipoutputPath);
string incorrectCompressor7zipoutputPath = Path.Combine(workingDirectory, "Examples", "Compressor7zip", "Compressor7zipResultsInvalidExample.txt");
this.rawText = File.ReadAllText(incorrectCompressor7zipoutputPath);
this.testParser = new Compression7zipMetricsParser(this.rawText);
SchemaException exception = Assert.Throws<SchemaException>(() => this.testParser.Parse());
StringAssert.Contains("The Compressor7zip results file has incorrect data for parsing", exception.Message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CtsTrafficMetricsParserTests
public void Setup()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\CtsTraffic\CtsTrafficResultsExample.csv");
string outputPath = Path.Combine(workingDirectory, "Examples", "CtsTraffic", "CtsTrafficResultsExample.csv");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new CtsTrafficMetricsParser(this.rawText);
}
Expand All @@ -41,7 +41,7 @@ public void CtsTrafficParserVerifyMetrics()
MetricAssert.Exists(metrics, "RecvBps(TimeSlice-0.006)", 1, "B/s");
MetricAssert.Exists(metrics, "InFlight(TimeSlice-0.006)", 1);
MetricAssert.Exists(metrics, "Completed(TimeSlice-0.006)", 0);
MetricAssert.Exists(metrics, "NetworkError(TimeSlice-0.006)",0);
MetricAssert.Exists(metrics, "NetworkError(TimeSlice-0.006)", 0);
MetricAssert.Exists(metrics, "DataError(TimeSlice-0.006)", 0);
MetricAssert.Exists(metrics, "SendBps(TimeSlice-20.007)", 27375465, "B/s");
MetricAssert.Exists(metrics, "RecvBps(TimeSlice-20.007)", 119906898, "B/s");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class DeathStarBenchClientExecutorTests
private DependencyPath currentDirectoryPath;
private string apiClientId;
private IPAddress ipAddress;

private string resultsPath;
private string rawString;

[SetUp]
Expand Down Expand Up @@ -237,7 +235,7 @@ private void SetupDefaultMockFileSystemBehavior()
this.fixture.File.Setup(f => f.Exists(It.IsAny<string>()))
.Returns(true);

resultsPath = this.fixture.PlatformSpecifics.Combine(this.currentDirectoryPath.Path, @"Examples\DeathStarBench\DeathStarBenchOutputExample.txt");
string resultsPath = this.fixture.PlatformSpecifics.Combine(this.currentDirectoryPath.Path, "Examples", "DeathStarBench", "DeathStarBenchOutputExample.txt");

this.rawString = File.ReadAllText(resultsPath);
this.fixture.File.Setup(f => f.ReadAllTextAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DeathStarBenchMetricsParserUnitTests
public void Setup()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\DeathStarBench\DeathStarBenchOutputExample.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "DeathStarBench", "DeathStarBenchOutputExample.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new DeathStarBenchMetricsParser(this.rawText);
}
Expand Down Expand Up @@ -56,9 +56,9 @@ public void DeathStarBenchMetricsParserVerifyMetrics()
public void DeathStarBenchMetricsParserThrowIfInvalidOutputFormat()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string IncorrectDeathBenchoutputPath = Path.Combine(workingDirectory, @"Examples\DeathStarbench\DeathStarbenchIncorrectOutputExample.txt");
string incorrectDeathBenchoutputPath = Path.Combine(workingDirectory, "Examples", "DeathStarBench", "DeathStarBenchIncorrectOutputExample.txt");

this.rawText = File.ReadAllText(IncorrectDeathBenchoutputPath);
this.rawText = File.ReadAllText(incorrectDeathBenchoutputPath);
this.testParser = new DeathStarBenchMetricsParser(this.rawText);

WorkloadResultsException exception = Assert.Throws<WorkloadResultsException>(() => this.testParser.Parse());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace VirtualClient.Actions.DiskPerformance

[TestFixture]
[Category("Unit")]
[Platform(Exclude = "Unix,Linux,MacOsX")]
public class DiskSpdExecutorTests
{
private DependencyFixture fixture;
Expand All @@ -46,7 +47,7 @@ public void SetupDefaultBehavior()
};

string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\DiskSpd\DiskSpdExample-ReadWrite.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "DiskSpd", "DiskSpdExample-ReadWrite.txt");
this.output = File.ReadAllText(outputPath);

this.fixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DiskSpdMetricsParserTests
public void DiskSpdParserVerifyReadWrite()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\DiskSpd\DiskSpdExample-ReadWrite.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "DiskSpd", "DiskSpdExample-ReadWrite.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new DiskSpdMetricsParser(this.rawText);

Expand Down Expand Up @@ -133,7 +133,7 @@ public void DiskSpdParserVerifyReadWrite()
public void DiskSpdParserVerifyWriteOnly()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\DiskSpd\DiskSpdExample-WriteOnly.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "DiskSpd", "DiskSpdExample-WriteOnly.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new DiskSpdMetricsParser(this.rawText);

Expand Down Expand Up @@ -221,7 +221,7 @@ public void DiskSpdParserVerifyWriteOnly()
public void DiskSpdParserVerifyForCoreCountGreaterThan64WhichAddsProcessorGrouping()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\DiskSpd\Read8k.txt");
string outputPath = Path.Combine(workingDirectory, "Examples", "DiskSpd", "Read8k.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new DiskSpdMetricsParser(this.rawText);

Expand Down
Loading

0 comments on commit 5e798d8

Please sign in to comment.