Skip to content

Commit 5be7e80

Browse files
authored
Fix hpcg error (#539)
* fix hpcg error * resolving unittests
1 parent afe8699 commit 5be7e80

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

src/VirtualClient/VirtualClient.Actions.UnitTests/Hpcg/HpcgExecutorTests.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33

44
namespace VirtualClient.Actions
55
{
6+
using Microsoft.Azure.Amqp.Framing;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
9+
using Moq;
10+
using Newtonsoft.Json;
11+
using Newtonsoft.Json.Linq;
12+
using NUnit.Framework;
613
using System;
14+
using System.Collections;
715
using System.Collections.Generic;
816
using System.Diagnostics;
917
using System.IO;
1018
using System.Linq;
19+
using System.Runtime.Intrinsics.X86;
1120
using System.Threading;
1221
using System.Threading.Tasks;
13-
using Microsoft.Extensions.DependencyInjection;
14-
using Moq;
15-
using Newtonsoft.Json;
16-
using Newtonsoft.Json.Linq;
17-
using NUnit.Framework;
18-
using VirtualClient.Contracts;
22+
using VirtualClient.Common.Contracts;
1923
using VirtualClient.Common.Extensions;
2024
using VirtualClient.Common.Telemetry;
21-
using VirtualClient.Common.Contracts;
25+
using VirtualClient.Contracts;
2226

2327
[TestFixture]
2428
[Category("Unit")]
@@ -176,8 +180,12 @@ public async Task HpcgExecutorWritesExpectedRunShellFile()
176180
.Returns(false)
177181
.Returns(true);
178182

183+
179184
string expectedFile = $". {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit/share/spack/setup-env.sh" + Environment.NewLine
180-
+ "spack install --reuse -n -y hpcg@9.8 %gcc +openmp ^openmpi@6.66.666" + Environment.NewLine
185+
+ $"mkdir -p {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit/opt/spack/.spack-db" + Environment.NewLine
186+
+ $"sudo chown -R $(whoami):$(whoami) {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit" + Environment.NewLine
187+
+ $"chmod -R u+rwx {this.mockFixture.GetPackagePath()}/JavaDevelopmentKit" + Environment.NewLine
188+
+ "spack install --reuse -n -y hpcg@9.8 %gcc ^openmpi@6.66.666" + Environment.NewLine
181189
+ $"spack load hpcg@9.8 %gcc ^openmpi@6.66.666" + Environment.NewLine
182190
+ $"mpirun --np 7 --use-hwthread-cpus --allow-run-as-root xhpcg";
183191

src/VirtualClient/VirtualClient.Actions/HPCG/HpcgExecutor.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,14 @@ private async Task WriteHpcgRunShellAsync(CancellationToken cancellationToken)
237237
// . spack/share/spack/setup-env.sh
238238
string spackSetupCommand = $". {this.spackDirectory}/share/spack/setup-env.sh";
239239

240+
// Giving permissions to the required files
241+
string createSpackDbDirCmd = $"mkdir -p {this.spackDirectory}/opt/spack/.spack-db";
242+
string chownSpackDirCmd = $"sudo chown -R $(whoami):$(whoami) {this.spackDirectory}";
243+
string chmodSpackDirCmd = $"chmod -R u+rwx {this.spackDirectory}";
244+
240245
// If gcc>= 9, use zen2. if <=8, use zen.
241-
// spack install -n -y hpcg %gcc@10.3.0 +openmp target=zen2 ^openmpi@4.1.1
242-
string installCommand = $"spack install --reuse -n -y hpcg@{this.HpcgVersion} %gcc +openmp ^openmpi@{this.OpenMpiVersion}";
246+
// spack install -n -y hpcg %gcc@10.3.0 target=zen2 ^openmpi@4.1.1
247+
string installCommand = $"spack install --reuse -n -y hpcg@{this.HpcgVersion} %gcc ^openmpi@{this.OpenMpiVersion}";
243248

244249
// spack load hpcg %gcc@10.3.0
245250
string loadCommand = $"spack load hpcg@{this.HpcgVersion} %gcc ^openmpi@{this.OpenMpiVersion}";
@@ -249,7 +254,7 @@ private async Task WriteHpcgRunShellAsync(CancellationToken cancellationToken)
249254
int coreCount = cpuInfo.PhysicalCoreCount;
250255
string mpirunCommand = $"mpirun --np {coreCount} --use-hwthread-cpus --allow-run-as-root xhpcg";
251256

252-
this.runShellText = string.Join(Environment.NewLine, spackSetupCommand, installCommand, loadCommand, mpirunCommand);
257+
this.runShellText = string.Join(Environment.NewLine, spackSetupCommand, createSpackDbDirCmd, chownSpackDirCmd, chmodSpackDirCmd, installCommand, loadCommand, mpirunCommand);
253258

254259
await this.systemManagement.FileSystem.File.WriteAllTextAsync(this.hpcgRunShellPath, this.runShellText, cancellationToken).ConfigureAwait(false);
255260
}

0 commit comments

Comments
 (0)