Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void SetupFixture()
DeathStarBenchExecutor.StateConfirmationPollingTimeout = TimeSpan.FromSeconds(1);

this.mockFixture.SetupPackage("deathstarbench");
this.mockFixture.SetupPackage("libssl");
this.mockFixture.SetupFile(@"/usr/local/bin/docker-compose");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ public async Task DeathStarBenchWorkloadProfileInstallsTheExpectedDependenciesOf
new ClientInstance(this.serverAgentId, "1.2.3.5", "Server"));

this.mockFixture.SystemManagement.SetupGet(sm => sm.AgentId).Returns(this.serverAgentId);
this.mockFixture.SetupPackage("libssl");
this.mockFixture.SetupFile(@"/usr/local/bin/docker-compose");

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
{
executor.ExecuteActions = false;

await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None)
.ConfigureAwait(false);

// Workload dependency package expectations
WorkloadAssert.WorkloadPackageInstalled(this.mockFixture, "deathstarbench");
}

// Workload dependency package expectations
WorkloadAssert.WorkloadPackageInstalled(this.mockFixture, "deathstarbench");
}

[Test]
Expand Down Expand Up @@ -119,6 +120,8 @@ public void DeathStarBenchWorkloadProfileActionsWillNotBeExecutedIfTheClientWork
new ClientInstance(this.clientAgentId, "1.2.3.4", "Client"),
new ClientInstance(this.serverAgentId, "1.2.3.5", "Server"));

this.mockFixture.SetupPackage("libssl");

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
DependencyException error = Assert.ThrowsAsync<DependencyException>(() => executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ public async Task DeathStarBenchClientExecutorExecutesExpectedCommands_SocialNet
// exactly the same as what is executed.
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/dockerComposeScript.sh",
$"sudo chmod +x \"/usr/local/bin/docker-compose\"",
$"sudo python3 -m pip install -U pip",
$"sudo python3 -m pip install -U setuptools",
$"sudo -H python3 -m pip install aiohttp asyncio",
$"sudo apt install python3-venv -y",
$"sudo python3 -m venv {this.mockPackage.Path}/linux-x64/venv",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install -U pip",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install -U setuptools",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install aiohttp asyncio",
$"sudo luarocks install luasocket",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/isSwarmNode.sh",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/isSwarmNode.sh",
Expand Down Expand Up @@ -198,9 +200,11 @@ public async Task DeathStarBenchClientExecutorExecutesExpectedCommands_MediaMicr
$"sudo chmod +x \"{this.mockPackage.Path}/linux-x64/mediamicroservices/wrk2/deps/luajit/src/luajit\"",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/dockerComposeScript.sh",
$"sudo chmod +x \"/usr/local/bin/docker-compose\"",
$"sudo python3 -m pip install -U pip",
$"sudo python3 -m pip install -U setuptools",
$"sudo -H python3 -m pip install aiohttp asyncio",
$"sudo apt install python3-venv -y",
$"sudo python3 -m venv {this.mockPackage.Path}/linux-x64/venv",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install -U pip",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install -U setuptools",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install aiohttp asyncio",
$"sudo luarocks install luasocket",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/isSwarmNode.sh",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/isSwarmNode.sh",
Expand Down Expand Up @@ -243,9 +247,11 @@ public async Task DeathStarBenchClientExecutorExecutesExpectedCommands_HotelRese
// exactly the same as what is executed.
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/dockerComposeScript.sh",
$"sudo chmod +x \"/usr/local/bin/docker-compose\"",
$"sudo python3 -m pip install -U pip",
$"sudo python3 -m pip install -U setuptools",
$"sudo -H python3 -m pip install aiohttp asyncio",
$"sudo apt install python3-venv -y",
$"sudo python3 -m venv {this.mockPackage.Path}/linux-x64/venv",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install -U pip",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install -U setuptools",
$"sudo {this.mockPackage.Path}/linux-x64/venv/bin/pip install aiohttp asyncio",
$"sudo luarocks install luasocket",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/isSwarmNode.sh",
$"sudo bash {this.mockPackage.Path}/linux-x64/scripts/isSwarmNode.sh",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ public async Task DeathStarBenchExecutorInstallsDepedenciesAsExpected()
{
@"bash /home/user/tools/VirtualClient/packages/deathstarbench/linux-x64/scripts/dockerComposeScript.sh",
@"chmod +x ""/usr/local/bin/docker-compose""",
@"python3 -m pip install -U pip",
@"python3 -m pip install -U setuptools",
@"-H python3 -m pip install aiohttp asyncio",
@"apt install python3-venv -y",
@"python3 -m venv /home/user/tools/VirtualClient/packages/deathstarbench/linux-x64/venv",
@"/home/user/tools/VirtualClient/packages/deathstarbench/linux-x64/venv/bin/pip install -U pip",
@"/home/user/tools/VirtualClient/packages/deathstarbench/linux-x64/venv/bin/pip install -U setuptools",
@"/home/user/tools/VirtualClient/packages/deathstarbench/linux-x64/venv/bin/pip install aiohttp asyncio",
@"luarocks install luasocket",
};

Expand All @@ -116,7 +118,7 @@ public async Task DeathStarBenchExecutorInstallsDepedenciesAsExpected()

await executor.OnInitialize(EventContext.None, CancellationToken.None);

Assert.AreEqual(6, executed);
Assert.AreEqual(8, executed);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public string ServiceName
/// </summary>
protected string ScriptsDirectory { get; set; }

/// <summary>
/// Path to Python executable in virtual environment.
/// </summary>
protected string PythonExecutablePath { get; set; }

/// <summary>
/// An interface that can be used to communicate with the underlying system.
/// </summary>
Expand Down Expand Up @@ -546,16 +551,29 @@ await this.ExecuteCommandAsync(dockerComposeCommand, this.PackageDirectory, canc
await this.SystemManager.MakeFileExecutableAsync(dockerComposeFilePath, this.Platform, cancellationToken)
.ConfigureAwait();

string pipUpgradeCommand = "python3 -m pip install -U pip";
string installVenvCommand = "apt install python3-venv -y";
await this.ExecuteCommandAsync(installVenvCommand, this.PackageDirectory, cancellationToken)
.ConfigureAwait();

// Create Python virtual environment to isolate dependencies
string venvPath = this.PlatformSpecifics.Combine(this.PackageDirectory, "venv");
string createVenvCommand = $"python3 -m venv {venvPath}";
await this.ExecuteCommandAsync(createVenvCommand, this.PackageDirectory, cancellationToken)
.ConfigureAwait();

this.PythonExecutablePath = this.PlatformSpecifics.Combine(venvPath, "bin", "python3");
string venvPip = this.PlatformSpecifics.Combine(venvPath, "bin", "pip");

string pipUpgradeCommand = $"{venvPip} install -U pip";
await this.ExecuteCommandAsync(pipUpgradeCommand, this.PackageDirectory, cancellationToken)
.ConfigureAwait();

string setupToolsUpgradeCommand = "python3 -m pip install -U setuptools";
string setupToolsUpgradeCommand = $"{venvPip} install -U setuptools";
await this.ExecuteCommandAsync(setupToolsUpgradeCommand, this.PackageDirectory, cancellationToken)
.ConfigureAwait();

// python3-pip installs pip3 and not pip, better to leave it on python which version of pip to use
string pipInstallPackagesCommand = "-H python3 -m pip install aiohttp asyncio";
// Install required Python packages in virtual environment
string pipInstallPackagesCommand = $"{venvPip} install aiohttp asyncio";
await this.ExecuteCommandAsync(pipInstallPackagesCommand, this.PackageDirectory, cancellationToken)
.ConfigureAwait();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ await this.WaitAsync(DeathStarBenchExecutor.ServerWarmUpTime, cancellationToken)

if (string.Equals(this.ServiceName, DeathStarBenchExecutor.MediaMicroservices, StringComparison.OrdinalIgnoreCase))
{
await this.ExecuteCommandAsync("python3 scripts/write_movie_info.py -c datasets/tmdb/casts.json -m datasets/tmdb/movies.json", this.ServiceDirectory, cancellationToken)
await this.ExecuteCommandAsync($"{this.PythonExecutablePath} scripts/write_movie_info.py -c datasets/tmdb/casts.json -m datasets/tmdb/movies.json", this.ServiceDirectory, cancellationToken)
.ConfigureAwait();
}
else if (string.Equals(this.ServiceName, DeathStarBenchExecutor.SocialNetwork, StringComparison.OrdinalIgnoreCase))
{
await this.ExecuteCommandAsync(@$"bash -c ""python3 scripts/init_social_graph.py --graph={this.GraphType} --limit=1000""", this.ServiceDirectory, cancellationToken)
await this.ExecuteCommandAsync(@$"bash -c ""{this.PythonExecutablePath} scripts/init_social_graph.py --graph={this.GraphType} --limit=1000""", this.ServiceDirectory, cancellationToken)
.ConfigureAwait();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,54 @@
}
}
],
"Dependencies": [
{
"Type": "DependencyPackageInstallation",
"Parameters": {
"Scenario": "InstallDeathStarBenchPackage",
"BlobContainer": "packages",
"BlobName": "deathstarbench.3.0.0.zip",
"PackageName": "deathstarbench",
"Extract": true
}
},
{
"Type": "DockerInstallation",
"Parameters": {
"Scenario": "InstallDocker"
}
},
{
"Type": "LinuxPackageInstallation",
"Parameters": {
"Scenario": "InstallLinuxPackages",
"Repositories-Apt": "deb http://security.ubuntu.com/ubuntu xenial-security main",
"Packages-Apt": "python3-pip,libssl-dev,libz-dev,luarocks,libssl1.0.0"
}
},
{
"Type": "ApiServer",
"Parameters": {
"Scenario": "StartAPIServer"
}
}
]
"Dependencies": [
{
"Type": "DependencyPackageInstallation",
"Parameters": {
"Scenario": "InstallDeathStarBenchPackage",
"BlobContainer": "packages",
"BlobName": "deathstarbench.3.0.0.zip",
"PackageName": "deathstarbench",
"Extract": true
}
},
{
"Type": "DockerInstallation",
"Parameters": {
"Scenario": "InstallDocker"
}
},
{
"Type": "WgetPackageInstallation",
"Parameters": {
"Scenario": "InstallLibsslPackage",
"PackageName": "libssl",
"PackageUri": "http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.13_amd64.deb",
"SupportedPlatforms": "linux-x64",
"Notes": "Example path to package -> /packages/libssl"
}
},
{
"Type": "ExecuteCommand",
"Parameters": {
"Scenario": "InstallLibssl",
"SupportedPlatforms": "linux-x64",
"Command": "dpkg -i libssl1.0.0_1.0.2n-1ubuntu5.13_amd64.deb",
"WorkingDirectory": "{PackagePath:libssl}"
}
},
{
"Type": "LinuxPackageInstallation",
"Parameters": {
"Scenario": "InstallLinuxPackages",
"Packages-Apt": "python3-pip,libssl-dev,libz-dev,luarocks,libssl1.0.0,python3.12-venv"
}
},
{
"Type": "ApiServer",
"Parameters": {
"Scenario": "StartAPIServer"
}
}
]
}
Loading