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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.0
3.4.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,6 @@ public void SetupTest()
};
}

[Test]
public void TestElasticsearchRallyServerExecutorInitializeYmlNotFound()
{
SetupTest();

bool commandExecuted = false;

using (TestElasticsearchRallyServerExecutor executor = new TestElasticsearchRallyServerExecutor(this.Dependencies, this.Parameters))
{
executor.OnRunCommand = (command, arguments) =>
{
commandExecuted = true;
};

Assert.ThrowsAsync<WorkloadException>(() => executor.InitializeAsync(EventContext.None, CancellationToken.None));
}

Assert.IsTrue(commandExecuted);
}

[Test]
[TestCase(true)]
[TestCase(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private async Task StartElasticsearch(EventContext telemetryContext, Cancellatio
}
}

private void StartElasticsearchLinux(EventContext telemetryContext, CancellationToken cancellationToken, string mountPoint)
private async Task StartElasticsearchLinux(EventContext telemetryContext, CancellationToken cancellationToken, string mountPoint)
{
string scriptsDirectory = this.PlatformSpecifics.GetScriptPath(this.PackageName.ToLower());
int port = this.Port;
Expand Down Expand Up @@ -176,7 +176,8 @@ private void StartElasticsearchLinux(EventContext telemetryContext, Cancellation
this.RunCommandAsRoot(telemetryContext, cancellationToken, "ElasticsearchDaemonReexec", "systemctl daemon-reexec");
this.RunCommandAsRoot(telemetryContext, cancellationToken, "ElasticsearchEnable", "systemctl enable elasticsearch");
bool ok = this.RunCommandAsRoot(telemetryContext, cancellationToken, "ElasticsearchStart", "systemctl start elasticsearch.service");
Thread.Sleep(30000); // wait for elasticsearch to start

await this.WaitAsync(TimeSpan.FromSeconds(30), cancellationToken); // wait for elasticsearch to start

if (!ok)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,24 @@ public string DiskFilter
/// </summary>
protected override async Task InitializeAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
await base.InitializeAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
await base.InitializeAsync(telemetryContext, cancellationToken);

this.InitializeApiClients();

await MongoDBServerExecutor.OpenFirewallPortsAsync(this.Port, this.systemManagement.FirewallManager, cancellationToken)
.ConfigureAwait(false);
await MongoDBServerExecutor.OpenFirewallPortsAsync(this.Port, this.systemManagement.FirewallManager, cancellationToken);

// Initialize disk if DiskFilter is specified
if (!string.IsNullOrWhiteSpace(this.DiskFilter))
{
await this.InitializeDiskPathAsync(cancellationToken).ConfigureAwait(false);
await this.ConfigureDiskForMongoDBAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
await this.InitializeDiskPathAsync(cancellationToken);
await this.ConfigureDiskForMongoDBAsync(telemetryContext, cancellationToken);
}

// Ensure MongoDB is configured to listen on all interfaces
await this.ConfigureMongoDBBindAddressAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
await this.ConfigureMongoDBBindAddressAsync(telemetryContext, cancellationToken);

// Start MongoDB server
await this.StartMongoDBServerAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
await this.StartMongoDBServerAsync(telemetryContext, cancellationToken);
}

/// <summary>
Expand All @@ -106,14 +105,13 @@ protected override Task ExecuteAsync(EventContext telemetryContext, Cancellation
{
this.SetServerOnline(false);

await this.ServerApiClient.PollForHeartbeatAsync(TimeSpan.FromMinutes(5), cancellationToken)
.ConfigureAwait(false);
await this.ServerApiClient.PollForHeartbeatAsync(TimeSpan.FromMinutes(5), cancellationToken);

// Server is now online and ready to accept connections
this.SetServerOnline(true);

// Keep the server running until cancelled
await Task.Delay(Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(false);
await Task.Delay(Timeout.InfiniteTimeSpan, cancellationToken);
}
catch (OperationCanceledException)
{
Expand Down Expand Up @@ -174,7 +172,7 @@ await this.ExecuteMongoDBCommandAsync(
$"-c \"{setBindIpCmd}\"",
"ConfigureBindAddress",
telemetryContext,
cancellationToken).ConfigureAwait(false);
cancellationToken);

this.Logger.LogMessage(
$"{nameof(MongoDBServerExecutor)}.BindAddressConfigured",
Expand All @@ -201,13 +199,13 @@ private async Task StartMongoDBServerAsync(EventContext telemetryContext, Cancel
try
{
// Restart MongoDB to apply all configurations
await this.ExecuteMongoDBServiceCommandAsync("restart", telemetryContext, cancellationToken).ConfigureAwait(false);
await this.ExecuteMongoDBServiceCommandAsync("restart", telemetryContext, cancellationToken);

// Wait a bit for MongoDB to fully start
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken).ConfigureAwait(false);
await this.WaitAsync(TimeSpan.FromSeconds(5), cancellationToken);

// Verify MongoDB is running
await this.VerifyMongoDBIsRunningAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
await this.VerifyMongoDBIsRunningAsync(telemetryContext, cancellationToken);

this.Logger.LogMessage(
$"{nameof(MongoDBServerExecutor)}.MongoDBServerStarted",
Expand All @@ -230,7 +228,7 @@ private async Task VerifyMongoDBIsRunningAsync(EventContext telemetryContext, Ca
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateElevatedProcess(
this.Platform, "mongosh", "--eval \"db.runCommand({ping: 1})\""))
{
await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
await process.StartAndWaitAsync(cancellationToken);

if (process.ExitCode != 0)
{
Expand Down Expand Up @@ -272,31 +270,31 @@ private async Task ConfigureDiskForMongoDBAsync(EventContext telemetryContext, C
string mongoDataPath = "/mnt/mongodb-data";

// Stop MongoDB service before mounting
await this.ExecuteMongoDBServiceCommandAsync("stop", telemetryContext, cancellationToken).ConfigureAwait(false);
await this.ExecuteMongoDBServiceCommandAsync("stop", telemetryContext, cancellationToken);

// Create filesystem on disk
await this.ExecuteMongoDBCommandAsync(
"bash",
$"-c \"sudo mkfs.ext4 -F {diskDevicePath}\"",
"CreateFilesystem",
telemetryContext,
cancellationToken).ConfigureAwait(false);
cancellationToken);

// Create mount point
await this.ExecuteMongoDBCommandAsync(
"bash",
$"-c \"sudo mkdir -p {mongoDataPath}\"",
"CreateMountPoint",
telemetryContext,
cancellationToken).ConfigureAwait(false);
cancellationToken);

// Mount the disk
await this.ExecuteMongoDBCommandAsync(
"bash",
$"-c \"sudo mount -t ext4 {diskDevicePath} {mongoDataPath}\"",
"MountDisk",
telemetryContext,
cancellationToken).ConfigureAwait(false);
cancellationToken);

// Set permissions. The MongoDB service account name differs by package format:
// Debian/Ubuntu packages create 'mongodb' whereas RPM-based distributions
Expand All @@ -310,7 +308,7 @@ await this.ExecuteMongoDBCommandAsync(
$"-c \"{resolveServiceUser}\"",
"SetPermissions",
telemetryContext,
cancellationToken).ConfigureAwait(false);
cancellationToken);

// Update mongod.conf to use the new dbPath
string configFile = "/etc/mongod.conf";
Expand All @@ -320,7 +318,7 @@ await this.ExecuteMongoDBCommandAsync(
$"-c \"{setDbPathCmd}\"",
"UpdateMongoConf",
telemetryContext,
cancellationToken).ConfigureAwait(false);
cancellationToken);

this.Logger.LogMessage(
$"{nameof(MongoDBServerExecutor)}.DiskConfigurationComplete",
Expand Down Expand Up @@ -353,12 +351,11 @@ private async Task ExecuteMongoDBCommandAsync(
this.CleanupTasks.Add(() => process.SafeKill());
this.LogProcessTrace(process);

await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
await process.StartAndWaitAsync(cancellationToken);

if (!cancellationToken.IsCancellationRequested)
{
await this.LogProcessDetailsAsync(process, telemetryContext, $"MongoDBServer-{scenario}", logToFile: true)
.ConfigureAwait(false);
await this.LogProcessDetailsAsync(process, telemetryContext, $"MongoDBServer-{scenario}", logToFile: true);

if (process.ExitCode != 0)
{
Expand Down Expand Up @@ -395,12 +392,11 @@ private async Task ExecuteMongoDBServiceCommandAsync(string action, EventContext
this.CleanupTasks.Add(() => process.SafeKill());
this.LogProcessTrace(process);

await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false);
await process.StartAndWaitAsync(cancellationToken);

if (!cancellationToken.IsCancellationRequested)
{
await this.LogProcessDetailsAsync(process, telemetryContext, $"MongoDBServer-Service-{action}", logToFile: true)
.ConfigureAwait(false);
await this.LogProcessDetailsAsync(process, telemetryContext, $"MongoDBServer-Service-{action}", logToFile: true);

if (process.ExitCode != 0)
{
Expand Down Expand Up @@ -433,8 +429,7 @@ private async Task InitializeDiskPathAsync(CancellationToken cancellationToken)
return;
}

IEnumerable<Disk> disks = await this.systemManagement.DiskManager.GetDisksAsync(cancellationToken)
.ConfigureAwait(false);
IEnumerable<Disk> disks = await this.systemManagement.DiskManager.GetDisksAsync(cancellationToken);

if (disks == null || !disks.Any())
{
Expand Down
10 changes: 10 additions & 0 deletions src/VirtualClient/VirtualClient.Contracts/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ public static class EnvironmentVariable
/// </summary>
public const string PATH = nameof(PATH);

/// <summary>
/// Name = SDK_EXPERIMENT_ID
/// </summary>
public const string SDK_EXPERIMENT_ID = nameof(SDK_EXPERIMENT_ID);

/// <summary>
/// Name = SDK_METADATA
/// </summary>
public const string SDK_METADATA = nameof(SDK_METADATA);

/// <summary>
/// Name = SUDO_USER
/// </summary>
Expand Down
Loading
Loading