mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 04:18:00 +00:00
Added backups of all data, restorable on another computer (#1008)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
ab45580473
commit
936043319c
144 files changed
+10417
-424
No files matched your search
@@ -0,0 +1,50 @@
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
namespace AIStudio.Tests.Tools;
|
||||
|
||||
/// <summary>
|
||||
/// Checks that indexing waits for the plugins before its first run, but never for good.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The embedding providers of an organization come with its configuration plugin. Right after a
|
||||
/// backup was restored, the settings do not hold them yet, and a first run which starts before the
|
||||
/// plugins were loaded finds the data sources of the user without their embedding provider. Should
|
||||
/// loading fail, though, waiting for it must not keep every data source from being indexed.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class FirstPluginLoadTests
|
||||
{
|
||||
[Test]
|
||||
public async Task TheFirstRunWaitsUntilThePluginsWereLoaded()
|
||||
{
|
||||
var firstLoad = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var wait = DataSourceEmbeddingService.WaitForFirstPluginLoadAsync(firstLoad.Task, TimeSpan.FromMinutes(1), CancellationToken.None);
|
||||
|
||||
await Task.Delay(50);
|
||||
Assert.That(wait.IsCompleted, Is.False, "The plugins are still loading.");
|
||||
|
||||
firstLoad.SetResult();
|
||||
Assert.That(await wait, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheFirstRunStartsAnywayWhenLoadingThePluginsTakesTooLong()
|
||||
{
|
||||
var neverLoaded = new TaskCompletionSource();
|
||||
|
||||
var loadedInTime = await DataSourceEmbeddingService.WaitForFirstPluginLoadAsync(neverLoaded.Task, TimeSpan.FromMilliseconds(50), CancellationToken.None);
|
||||
|
||||
Assert.That(loadedInTime, Is.False, "Loading may fail for good, and the data sources must be indexed all the same.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StoppingAIStudioEndsTheWait()
|
||||
{
|
||||
var neverLoaded = new TaskCompletionSource();
|
||||
using var stopping = new CancellationTokenSource();
|
||||
stopping.Cancel();
|
||||
|
||||
var waiting = DataSourceEmbeddingService.WaitForFirstPluginLoadAsync(neverLoaded.Task, TimeSpan.FromMinutes(1), stopping.Token);
|
||||
Assert.That(async () => await waiting, Throws.InstanceOf<OperationCanceledException>());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user