Skip to content

Commit e63d44a

Browse files
authored
Update Managed Lustre test recordings (#2376)
1 parent f9e60d7 commit e63d44a

4 files changed

Lines changed: 19 additions & 94 deletions

File tree

core/Microsoft.Mcp.Core/tests/Microsoft.Mcp.Tests/Client/RecordedCommandTestsBase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,14 @@ public string GetSessionFilePath(string displayName)
483483
var fullPath = Path.Combine(dir, fileName).Replace('\\', '/');
484484
return fullPath;
485485
}
486+
487+
/// <summary>
488+
/// Determines the polling interval to use for long-running operations. During live testing (Live or Record) the
489+
/// poll interval will use liveMilliseconds for the interval. During playback testing a static 1 millisecond poll
490+
/// interval is used.
491+
/// </summary>
492+
/// <param name="liveMilliseconds">Polling interval in milliseconds for live tests.</param>
493+
/// <returns>The polling interval TimeSpan.</returns>
494+
public TimeSpan PollInterval(long liveMilliseconds)
495+
=> TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(1) : TimeSpan.FromMilliseconds(liveMilliseconds);
486496
}

tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.LiveTests/ManagedLustreCommandTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
namespace Azure.Mcp.Tools.ManagedLustre.LiveTests;
1414

15-
public partial class ManagedLustreCommandTests(ITestOutputHelper output, TestProxyFixture fixture, LiveServerFixture liveServerFixture) : RecordedCommandTestsBase(output, fixture, liveServerFixture)
15+
public partial class ManagedLustreCommandTests(ITestOutputHelper output, TestProxyFixture fixture, LiveServerFixture liveServerFixture)
16+
: RecordedCommandTestsBase(output, fixture, liveServerFixture)
1617
{
1718
private static readonly string[] _sanitizedHeaders =
1819
[
@@ -232,7 +233,7 @@ public async Task Should_create_azure_managed_lustre_with_storage_and_cmk()
232233

233234
// Wait for filesystem to be available before creating jobs
234235
var maxWaitTime = TimeSpan.FromMinutes(30);
235-
var pollInterval = TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(100) : TimeSpan.FromSeconds(30);
236+
var pollInterval = PollInterval(30_000);
236237
var startTime = DateTime.UtcNow;
237238
var isAvailable = false;
238239

@@ -271,7 +272,7 @@ public async Task Should_create_azure_managed_lustre_with_storage_and_cmk()
271272
Assert.True(isAvailable, $"Filesystem '{fsName}' did not reach 'Succeeded' provisioning state within {maxWaitTime.TotalMinutes} minutes.");
272273

273274
// Wait for filesystem to stabilize before creating jobs
274-
await Task.Delay(TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(100) : TimeSpan.FromSeconds(15), TestContext.Current.CancellationToken);
275+
await Task.Delay(PollInterval(15_000), TestContext.Current.CancellationToken);
275276

276277
// Test autoimport job lifecycle
277278
var autoimportJobNameStr = $"autoimport-{fsName}";
@@ -336,7 +337,7 @@ public async Task Should_create_azure_managed_lustre_with_storage_and_cmk()
336337
Assert.Contains(autoimportJobNameStr, autoimportJobText);
337338

338339
// Wait 15 seconds to cancel auto import job
339-
await Task.Delay(TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(100) : TimeSpan.FromSeconds(15), TestContext.Current.CancellationToken);
340+
await Task.Delay(PollInterval(15_000), TestContext.Current.CancellationToken);
340341

341342
// Cancel autoimport job
342343
var autoimportCancelResult = await CallToolAsync(
@@ -373,7 +374,7 @@ public async Task Should_create_azure_managed_lustre_with_storage_and_cmk()
373374
Assert.Equal("Deleted", autoimportDeleteStatus.GetString());
374375

375376
// Wait for filesystem to stabilize after deleting import job and before creating export job
376-
await Task.Delay(TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(100) : TimeSpan.FromSeconds(15), TestContext.Current.CancellationToken);
377+
await Task.Delay(PollInterval(15_000), TestContext.Current.CancellationToken);
377378

378379
// Test autoexport job lifecycle.
379380
var autoexportJobNameStr = $"autoexport-{fsName}";
@@ -436,7 +437,7 @@ public async Task Should_create_azure_managed_lustre_with_storage_and_cmk()
436437
Assert.Contains(autoexportJobNameStr, autoexportJobText);
437438

438439
// Wait 15 seconds to cancel auto export job.
439-
await Task.Delay(TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(100) : TimeSpan.FromSeconds(15), TestContext.Current.CancellationToken);
440+
await Task.Delay(PollInterval(15_000), TestContext.Current.CancellationToken);
440441
// Cancel autoexport job
441442
var autoexportCancelResult = await CallToolAsync(
442443
"managedlustre_fs_blob_autoexport_cancel",
@@ -472,7 +473,7 @@ public async Task Should_create_azure_managed_lustre_with_storage_and_cmk()
472473
Assert.Equal("Deleted", autoexportDeleteStatus.GetString());
473474

474475
// Wait for filesystem to stabilize after deleting autoexport job and before creating import job
475-
await Task.Delay(TestMode == TestMode.Playback ? TimeSpan.FromMilliseconds(100) : TimeSpan.FromSeconds(15), TestContext.Current.CancellationToken);
476+
await Task.Delay(PollInterval(15_000), TestContext.Current.CancellationToken);
476477

477478
// Test import job lifecycle
478479
var importJobNameStr = $"import-{fsName}";

tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.LiveTests/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "",
44
"TagPrefix": "Azure.Mcp.Tools.ManagedLustre.LiveTests",
5-
"Tag": "Azure.Mcp.Tools.ManagedLustre.LiveTests_11ea42d368"
5+
"Tag": "Azure.Mcp.Tools.ManagedLustre.LiveTests_2f6d918693"
66
}

tools/Azure.Mcp.Tools.ManagedLustre/tests/Fix-TestRecording.ps1

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)