Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azlinux3 dnf packages for compiler installation #423

Merged
merged 33 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
066a8e7
Adding packages to install for azlinux3.
Jan 16, 2025
3e8ad0d
Adding git as a package installed via dnf.
Jan 16, 2025
81b3d1b
Merge branch 'main' into users/saibulusu/azlinux3-fixes
Jan 16, 2025
dd269c0
Upversion
Jan 16, 2025
a11774e
gcc version is empty by default. Throwing error if gcc version is not…
Jan 17, 2025
af0591d
Fixing typo.
Jan 17, 2025
95ffa31
Merge branch 'main' into users/saibulusu/azlinux3-fixes
saibulusu Jan 21, 2025
2a3a41d
Fixing test.
Jan 22, 2025
12e2b8a
Merge branch 'users/saibulusu/azlinux3-fixes' of https://github.com/m…
Jan 22, 2025
0b481fc
Adding make for RHEL/Cent OS.
Jan 22, 2025
0fa874a
Logging gcc version, only confirming version if supplied version is u…
Jan 22, 2025
7c236e0
Installing version-less packages for ubuntu/debian.
Jan 25, 2025
fc19076
Merge branch 'main' into users/saibulusu/azlinux3-fixes
saibulusu Jan 27, 2025
956dd57
Adding libnsl package for RHEL/CentOS.
Jan 27, 2025
bfc5f0d
Merge branch 'users/saibulusu/azlinux3-fixes' of https://github.com/m…
Jan 27, 2025
1ea9d73
Removed speccpu gcc limit in documentation, and checking for gcc vers…
Jan 28, 2025
818e362
Merge branch 'main' into users/saibulusu/azlinux3-fixes
Feb 6, 2025
07c2583
Removing existing version of gcc before installing new version.
Feb 6, 2025
628d2a1
Dnf remove instead of apt-get for CentOS/RHEL.
Feb 6, 2025
979111d
Getting gcc version, if already installed and not supplied, does not …
Feb 9, 2025
329d76b
Merge branch 'main' into users/saibulusu/azlinux3-fixes
Feb 9, 2025
6baec51
Fixing unit test for case where supplied version is empty.
Feb 9, 2025
b2669bc
Adding a unit test for no supplied version, with existing version.
Feb 9, 2025
5f3fe02
Splitting dumpversion output
Feb 10, 2025
a915509
upversion
Feb 10, 2025
2f79170
Removing compiler name from compiler installation, compiler version f…
Feb 11, 2025
be86c4f
Adding purge and updating unit tests.
Feb 11, 2025
9898976
Merge branch 'main' into users/saibulusu/azlinux3-fixes
saibulusu Feb 11, 2025
74edabf
upversion
Feb 11, 2025
cdc0871
Removing compiler name, setting compiler version empty.
Feb 12, 2025
10ecf06
Removing unecessary unit test.
Feb 12, 2025
9343f8f
Fixing unit test for windows speccpu.
Feb 12, 2025
b7fbff4
Fixing documentation.
Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.19
1.16.20
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public async Task CoreMarkProWorkloadProfileExecutesTheExpectedWorkloadsOnWindow
this.mockFixture.SetupLinuxPackagesInstalled(new Dictionary<string, string>
{
{ "gcc", "10" }, // Should match profile defaults.
{ "cc", "10" }
{ "cc", "10" },
{ "gfortran", "10" }
});

this.mockFixture.ProcessManager.OnGetProcess = (id) => null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace VirtualClient.Actions
using System.IO.Abstractions;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using global::VirtualClient;
Expand Down Expand Up @@ -55,6 +56,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInLin
{
$"sudo mount -t iso9660 -o ro,exec,loop {this.mockPackage.Path}/speccpu.iso {this.mockFixture.GetPackagePath()}/speccpu_mount",
$"sudo ./install.sh -f -d {this.mockPackage.Path}",
$"sudo gcc -dumpversion",
$"sudo chmod -R ugo=rwx {this.mockPackage.Path}",
$"sudo umount {this.mockFixture.GetPackagePath()}/speccpu_mount",
$"sudo bash runspeccpu.sh \"--config vc-linux-x64.cfg --iterations 2 --copies 4 --threads 8 --tune all --reportable intrate\""
Expand All @@ -66,25 +68,43 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInLin
Assert.AreEqual(expectedCommands.ElementAt(processCount), $"{exe} {arguments}");
processCount++;

return new InMemoryProcess
if (exe == "sudo" && arguments == "gcc -dumpversion")
{
StartInfo = new ProcessStartInfo
return new InMemoryProcess
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true
};
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
StandardOutput = new ConcurrentBuffer(new StringBuilder("10")),
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true
};
}
else
{
return new InMemoryProcess
{
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true
};
}
};

using (TestSpecCpuExecutor specCpuExecutor = new TestSpecCpuExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters))
{
await specCpuExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
}

Assert.AreEqual(5, processCount);
Assert.AreEqual(expectedCommands.Count, processCount);
}

[Test]
Expand All @@ -99,6 +119,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin
$"powershell -Command \"Mount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"",
$"powershell -Command \"(Get-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso| Get-Volume).DriveLetter\"",
$"cmd /c echo 1 | X:\\install.bat {this.mockPackage.Path}",
"gcc -dumpversion",
$"powershell -Command \"Dismount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"",
$"cmd /c runspeccpu.bat --config vc-win-x64.cfg --iterations 2 --copies 4 --threads 8 --tune all --noreportable intrate"
};
Expand All @@ -114,26 +135,44 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin
output.Append("X");
}

return new InMemoryProcess
if (exe == "gcc" && arguments == "-dumpversion")
{
StartInfo = new ProcessStartInfo
return new InMemoryProcess
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true,
StandardOutput = output
};
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true,
StandardOutput = new ConcurrentBuffer(new StringBuilder("10")),
};
}
else
{
return new InMemoryProcess
{
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true,
StandardOutput = output
};
}
};

using (TestSpecCpuExecutor specCpuExecutor = new TestSpecCpuExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters))
{
await specCpuExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
}

Assert.AreEqual(5, processCount);
Assert.AreEqual(processCount, expectedCommands.Count);
}

[Test]
Expand Down Expand Up @@ -273,7 +312,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithDifferentProfiles
{
commandCalled = true;
}

return new InMemoryProcess
{
StartInfo = new ProcessStartInfo
Expand Down Expand Up @@ -353,7 +392,6 @@ private void SetupLinux()

this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
{
{ nameof(SpecCpuExecutor.CompilerVersion), "10" },
{ nameof(SpecCpuExecutor.SpecProfile), "intrate" },
{ nameof(SpecCpuExecutor.PackageName), "speccpu" },
{ nameof(SpecCpuExecutor.RunPeak), true },
Expand Down Expand Up @@ -385,7 +423,6 @@ private void SetupWindows()

this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
{
{ nameof(SpecCpuExecutor.CompilerVersion), "10" },
{ nameof(SpecCpuExecutor.SpecProfile), "intrate" },
{ nameof(SpecCpuExecutor.PackageName), "speccpu" },
{ nameof(SpecCpuExecutor.RunPeak), true },
Expand Down
48 changes: 36 additions & 12 deletions src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace VirtualClient.Actions
using global::VirtualClient.Contracts;
using Microsoft.Extensions.DependencyInjection;
using VirtualClient.Contracts.Metadata;
using VirtualClient.Metadata;

/// <summary>
/// The SpecCpu workload executor.
Expand Down Expand Up @@ -86,17 +87,6 @@ public string BaseOptimizingFlags
}
}

/// <summary>
/// Compiler version
/// </summary>
public string CompilerVersion
{
get
{
return this.Parameters.GetValue<string>(nameof(SpecCpuExecutor.CompilerVersion));
}
}

/// <summary>
/// Iterations.
/// Recommand Default: 2
Expand Down Expand Up @@ -432,16 +422,50 @@ private async Task WriteSpecCpuConfigAsync(CancellationToken cancellationToken)
true);
}

string compilerVersion = await this.GetInstalledCompilerDumpVersionAsync("gcc", cancellationToken);

if (string.IsNullOrEmpty(compilerVersion))
{
throw new WorkloadException("gcc version not found.");
}

templateText = templateText.Replace(SpecCpuConfigPlaceHolder.BaseOptimizingFlags, this.BaseOptimizingFlags, StringComparison.OrdinalIgnoreCase);
templateText = templateText.Replace(SpecCpuConfigPlaceHolder.PeakOptimizingFlags, this.PeakOptimizingFlags, StringComparison.OrdinalIgnoreCase);
templateText = templateText.Replace(
SpecCpuConfigPlaceHolder.Gcc10Workaround,
Convert.ToInt32(this.CompilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
Convert.ToInt32(compilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
StringComparison.OrdinalIgnoreCase);

await this.fileSystem.File.WriteAllTextAsync(this.Combine(this.PackageDirectory, "config", configurationFile), templateText, cancellationToken);
}

private async Task<string> GetInstalledCompilerDumpVersionAsync(string compilerName, CancellationToken cancellationToken)
{
string command = compilerName;
string commandArguments = "-dumpversion";

string version = string.Empty;

using (IProcessProxy process = this.systemManager.ProcessManager.CreateElevatedProcess(this.Platform, command, commandArguments))
{
try
{
await process.StartAndWaitAsync(cancellationToken);

if (!cancellationToken.IsCancellationRequested)
{
version = process.StandardOutput.ToString().Trim().Split(".")[0];
}
}
catch
{
version = string.Empty;
}
}

return version;
}

internal class SpecCpuState : State
{
public SpecCpuState(IDictionary<string, IConvertible> properties = null)
Expand Down
Loading
Loading