Skip to content

Commit

Permalink
RavenDB-23102 move long running tests to nightly / stress v6
Browse files Browse the repository at this point in the history
  • Loading branch information
garayx committed Jan 12, 2025
1 parent aed994d commit da08546
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 167 deletions.
2 changes: 1 addition & 1 deletion test/SlowTests/Server/Documents/ETL/Olap/FailoverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public FailoverTests(ITestOutputHelper output) : base(output)
{
}

[RavenFact(RavenTestCategory.Etl)]
[RavenFact(RavenTestCategory.Etl, NightlyBuildRequired = true)]
public async Task OlapTaskShouldBeHighlyAvailable()
{
var cluster = await CreateRaftCluster(3);
Expand Down
160 changes: 3 additions & 157 deletions test/SlowTests/Sharding/Cluster/SubscriptionsWithReshardingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,48 +733,6 @@ public async Task GetDocumentsWithFilteringAndModifications()
}
}

[RavenFact(RavenTestCategory.Sharding | RavenTestCategory.Subscriptions)]
public async Task GetDocumentsWithFilteringAndModifications2()
{
using var store = Sharding.GetDocumentStore();
var id = await store.Subscriptions.CreateAsync<User>(predicate: u => u.Age > 0);
var users = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

await CreateItems(store, 0, 2);
await ProcessSubscription(store, id, users);
await Sharding.Resharding.MoveShardForId(store, "users/1-A");
await CreateItems(store, 2, 4, update: true);
await ProcessSubscription(store, id, users);
await Sharding.Resharding.MoveShardForId(store, "users/1-A");
await CreateItems(store, 4, 6, update: true);
await ProcessSubscription(store, id, users);
await Sharding.Resharding.MoveShardForId(store, "users/1-A");
await CreateItems(store, 6, 7, update: true);
await ProcessSubscription(store, id, users);
await Sharding.Resharding.MoveShardForId(store, "users/1-A");
await CreateItems(store, 7, 8, update: true);
await ProcessSubscription(store, id, users);
await Sharding.Resharding.MoveShardForId(store, "users/1-A");
await CreateItems(store, 9, 10, update: true);
await ProcessSubscription(store, id, users);

using (var session = store.OpenAsyncSession())
{
var total = await session.Query<User>().CountAsync();
Assert.Equal(195, total);

var usersByQuery = await session.Query<User>().Where(u => u.Age > 0).ToListAsync();
foreach (var user in usersByQuery)
{
Assert.True(users.TryGetValue(user.Id, out var age), $"Missing {user.Id} from subscription");
Assert.True(age == user.Age, $"From sub:{age}, from shard: {user.Age} for {user.Id} cv:{session.Advanced.GetChangeVectorFor(user)}");
users.Remove(user.Id);
}
}

await Sharding.Subscriptions.AssertNoItemsInTheResendQueueAsync(store, id);
}

[RavenFact(RavenTestCategory.Sharding | RavenTestCategory.Subscriptions)]
public async Task GetDocumentsWithFilteringAndModifications3()
{
Expand Down Expand Up @@ -814,7 +772,7 @@ public async Task GetDocumentsWithFilteringAndModifications3()
await Sharding.Subscriptions.AssertNoItemsInTheResendQueueAsync(store, id);
}

private async Task ProcessSubscription(IDocumentStore store, string id, Dictionary<string, int> users, int timoutSec = 15)
internal static async Task ProcessSubscription(IDocumentStore store, string id, Dictionary<string, int> users, int timoutSec = 15)
{
await using (var subscription = store.Subscriptions.GetSubscriptionWorker<User>(new SubscriptionWorkerOptions(id)
{
Expand Down Expand Up @@ -867,7 +825,7 @@ private async Task ProcessSubscription(IDocumentStore store, string id, Dictiona
}
}

private static async Task<int> CreateItems(IDocumentStore store, int from, int to, bool update = false)
internal static async Task<int> CreateItems(IDocumentStore store, int from, int to, bool update = false)
{
var added = 0;
try
Expand Down Expand Up @@ -1049,119 +1007,7 @@ public async Task ContinueSubscriptionAfterReshardingInAClusterWithFailover()
}
}

[RavenFact(RavenTestCategory.Sharding | RavenTestCategory.Subscriptions)]
public async Task ContinueSubscriptionAfterReshardingInAClusterRF3WithOrchestratorFailover()
{
var cluster = await CreateRaftCluster(5, watcherCluster: true, shouldRunInMemory: false);
// 5 node, 2 orch, 3 shard, rf 3
// drop orch

var first3 = cluster.Nodes.Select(x => x.ServerStore.NodeTag).Take(3).ToList();
var last2 = cluster.Nodes.Select(x => x.ServerStore.NodeTag).Skip(3).Take(2).ToList();
Assert.All(first3, x => Assert.DoesNotContain(x, last2));
var ops = new Options
{
ModifyDatabaseRecord = record =>
{
record.Sharding ??= new ShardingConfiguration()
{
Shards = new Dictionary<int, DatabaseTopology>()
{
{ 0, new DatabaseTopology() { ReplicationFactor = 3, Members = first3 } },
{ 1, new DatabaseTopology() { ReplicationFactor = 3, Members = first3 } },
{ 2, new DatabaseTopology() { ReplicationFactor = 3, Members = first3 } }
},
Orchestrator = new OrchestratorConfiguration { Topology = new OrchestratorTopology { ReplicationFactor = 2, Members = last2 } }
};
},
ReplicationFactor = 3,
Server = cluster.Leader,
RunInMemory = false
};

using var store = Sharding.GetDocumentStore(ops);
var id = await store.Subscriptions.CreateAsync<User>(predicate: u => u.Age > 0);
int.TryParse(id, out var id2);

await Cluster.WaitForRaftIndexToBeAppliedOnClusterNodesAsync(id2, cluster.Nodes);

var users = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
var t = Task.Run(async () => await ProcessSubscription(store, id, users, timoutSec: 60));

using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1)))
{
var fail = Task.Run(async () =>
{
(string DataDirectory, string Url, string NodeTag) result = default;
var recoveryOptions = new ServerCreationOptions
{
RunInMemory = false, DeletePrevious = false, RegisterForDisposal = true, CustomSettings = DefaultClusterSettings
};
recoveryOptions.CustomSettings[RavenConfiguration.GetKey(x => x.Cluster.ElectionTimeout)] =
cluster.Leader.Configuration.Cluster.ElectionTimeout.AsTimeSpan.TotalMilliseconds.ToString();

while (cts.IsCancellationRequested == false)
{
var tag = last2[Random.Shared.Next(0, 2)];
var node = cluster.Nodes.First(x => x.ServerStore.NodeTag == tag);
if (node.ServerStore.IsLeader())
continue;

var position = cluster.Nodes.IndexOf(node);
result = await DisposeServerAndWaitForFinishOfDisposalAsync(node);

await Cluster.WaitForNodeToBeRehabAsync(store, result.NodeTag);
await Task.Delay(TimeSpan.FromSeconds(3));

Assert.Equal(cluster.Nodes[position].ServerStore.NodeTag, tag);
cluster.Nodes[position] = await ReviveNodeAsync(result, recoveryOptions);
await Cluster.WaitForAllNodesToBeMembersAsync(store);
}
});

try
{
var added1 = await CreateItems(store, 0, 2);
await Sharding.Resharding.MoveShardForId(store, "users/1-A", servers: cluster.Nodes);
var added2 = await CreateItems(store, 2, 4, update: true);
await Sharding.Resharding.MoveShardForId(store, "users/1-A", servers: cluster.Nodes);
var added3 = await CreateItems(store, 4, 6, update: true);
await Sharding.Resharding.MoveShardForId(store, "users/1-A", servers: cluster.Nodes);
var added4 = await CreateItems(store, 6, 7, update: true);
await Sharding.Resharding.MoveShardForId(store, "users/1-A", servers: cluster.Nodes);
var added5 = await CreateItems(store, 7, 8, update: true);
await Sharding.Resharding.MoveShardForId(store, "users/1-A", servers: cluster.Nodes);
var added6 = await CreateItems(store, 8, 10, update: true);
}
finally
{
cts.Cancel();
await fail;
await t;
}
}

// await PrintCollectionAndSubscriptionChangeVectors(store, cluster, id);

await Indexes.WaitForIndexingInTheClusterAsync(store);
using (var session = store.OpenAsyncSession())
{
var total = await session.Query<User>().CountAsync();
Assert.Equal(195, total);

var usersByQuery = await session.Query<User>().Where(u => u.Age > 0).ToListAsync();
foreach (var user in usersByQuery)
{
Assert.True(users.TryGetValue(user.Id, out var age), $"Missing {user.Id} from subscription");
Assert.True(age == user.Age, $"From sub:{age}, from shard: {user.Age} for {user.Id} cv:{session.Advanced.GetChangeVectorFor(user)}");
users.Remove(user.Id);
}
}

await Sharding.Subscriptions.AssertNoItemsInTheResendQueueAsync(store, id, cluster.Nodes);
}

[RavenFact(RavenTestCategory.Sharding | RavenTestCategory.Subscriptions)]
[RavenFact(RavenTestCategory.Sharding | RavenTestCategory.Subscriptions, NightlyBuildRequired = true)]
public async Task ContinueSubscriptionAfterReshardingInAClusterRF1WithOrchestratorFailover()
{
var cluster = await CreateRaftCluster(5, watcherCluster: true, shouldRunInMemory: false);
Expand Down
2 changes: 1 addition & 1 deletion test/SlowTests/Tests/TestsInheritanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ where Filter(method)

var array = types.ToArray();

const int numberToTolerate = 4537;
const int numberToTolerate = 4536;

if (array.Length == numberToTolerate)
return;
Expand Down
9 changes: 2 additions & 7 deletions test/SlowTests/Voron/Issues/RavenDB_19278.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,8 @@ public void StopRecoveryAndRaisePartiallyRecoveredAlertAfterGettingInvalidHashOf
StartDatabase();
}

[NightlyBuildFact]
public void PartialRecoveryMustUpdateEnvironmentHeaderAndEraseCorruptedDataInJournal_Nightly()
{
PartialRecoveryMustUpdateEnvironmentHeaderAndEraseCorruptedDataInJournal(true, false, false);
}

[Theory]
[NightlyBuildTheory]
[InlineData(true, false, false)]
[InlineData(false, true, false)]
[InlineData(false, false, false)]
[InlineData(true, true, false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Xunit;
using Xunit.Abstractions;

namespace SlowTests.Voron
namespace StressTests.Issues
{
public class RavenDB_19471 : StorageTest
{
Expand Down
Loading

0 comments on commit da08546

Please sign in to comment.