Skip to content

Commit 70c2d9d

Browse files
fix: better fix for identical time-based database naming during fast tests
1 parent c6fbff1 commit 70c2d9d

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

src/Arius.Core.Tests/Features/Commands/Archive/ArchiveCommandHandlerContextTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task CreateAsync_WhenNoRemoteStateExists_ShouldCreateNewStateFile()
5252
// Verify a new state file was created (with current timestamp format)
5353
var stateFiles = stateCache.GetStateFileEntries().ToArray();
5454
stateFiles.Length.ShouldBe(1);
55-
stateFiles[0].Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
55+
stateFiles[0].Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\-\d{3}\.db");
5656

5757
// Verify no download was attempted since no remote state exists
5858
await mockArchiveStorage.DidNotReceive().DownloadStateAsync(Arg.Any<string>(), Arg.Any<FileEntry>(), Arg.Any<CancellationToken>());
@@ -101,7 +101,7 @@ await mockArchiveStorage.Received(1).DownloadStateAsync(
101101

102102
var newStateFile = stateFiles.FirstOrDefault(f => f.Name != $"{existingStateName}.db");
103103
newStateFile.ShouldNotBeNull("a new state file should be created");
104-
newStateFile.Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
104+
newStateFile.Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\-\d{3}\.db");
105105
}
106106

107107
[Fact]
@@ -139,6 +139,6 @@ public async Task CreateAsync_WhenRemoteStateExistsAndIsPresentLocally_ShouldNot
139139

140140
var newStateFile = stateFiles.FirstOrDefault(f => f.Name != $"{existingStateName}.db");
141141
newStateFile.ShouldNotBeNull("a new state file should be created");
142-
newStateFile.Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.db");
142+
newStateFile.Name.ShouldMatch(@"\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\-\d{3}\.db");
143143
}
144144
}

src/Arius.Core.Tests/Features/Commands/Archive/ArchiveCommandHandlerHandleTests.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,15 @@ private static (int FileCount, int ExistingPointerCount) GetInitialFileStatistic
6262
var command = commandBuilder.Build();
6363
var archiveStorage = storageBuilder.Build();
6464

65-
Retry:
66-
try
67-
{
68-
var builder = new HandlerContextBuilder(command, loggerFactory)
69-
.WithArchiveStorage(archiveStorage);
65+
var builder = new HandlerContextBuilder(command, loggerFactory)
66+
.WithArchiveStorage(archiveStorage);
7067

71-
if (hasher != null)
72-
builder = builder.WithHasher(hasher);
68+
if (hasher != null)
69+
builder = builder.WithHasher(hasher);
7370

74-
var handlerContext = await builder.BuildAsync();
71+
var handlerContext = await builder.BuildAsync();
7572

76-
return (command, handlerContext, storageBuilder, loggerFactory);
77-
}
78-
catch (IOException)
79-
{
80-
await Task.Delay(100); // Delay until the statefile name ("yyyy-MM-ddTHH-mm-ss") is in different seconds
81-
goto Retry;
82-
}
73+
return (command, handlerContext, storageBuilder, loggerFactory);
8374
}
8475

8576
[Fact(Skip = "TODO")]

src/Arius.Core/Features/Commands/Archive/HandlerContextBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async Task<StateRepository> BuildStateRepositoryAsync(IArchiveStorage archiveSto
8282
var stateCache = new StateCache(request.AccountName, request.ContainerName);
8383

8484
// Determine the version name for this run
85-
var versionName = DateTime.UtcNow.ToString("yyyy-MM-ddTHH-mm-ss");
85+
var versionName = DateTime.UtcNow.ToString("yyyy-MM-ddTHH-mm-ss-fff");
8686
request.ProgressReporter?.Report(new TaskProgressUpdate($"Determining version name '{versionName}'...", 0));
8787

8888
// Get the latest state from blob storage

0 commit comments

Comments
 (0)