public GridSPSTest(ClusterFixture fixture) { _client = fixture.Client; var builder = new GridSpatialPubSubBuilder(); builder.Configure(config => { config.PartitionSize = 0.2d; }); _pubSub = builder.Build(_client).GetAwaiter().GetResult(); }
public GrainTests(ClusterFixture fixture) { // extract the TestCluster instance here and save it... _cluster = fixture?.Cluster ?? throw new ArgumentNullException(nameof(fixture)); // create a single grain to test if you want here, or alternately create a grain in the test itself _calculatorGrain = _cluster.GrainFactory.GetGrain <ICalculatorGrain>(Guid.NewGuid()); }
public async Task TestScaleDown() { await using var fixture = new ClusterFixture(options => { options.NumKvConnections = 1; options.MaxKvConnections = 2; options.Experiments.ChannelConnectionPools = false; }); await fixture.InitializeAsync(); var bucket = await fixture.GetDefaultBucket(); var nodes = ((CouchbaseBucket)bucket).Nodes.OfType <ClusterNode>().ToArray(); Assert.Single(nodes); var connectionPools = nodes.Select(p => p.ConnectionPool).ToArray(); // Scale up to two connections await Task.WhenAll(connectionPools.Select(p => p.ScaleAsync(1))); Assert.All(connectionPools, p => Assert.Equal(2, p.Size)); // We'll write 10KB for each operation so that we have some real load on the send side var transcoder = new RawBinaryTranscoder(); var fakeBytes = new byte[10 * 1024]; var collection = bucket.DefaultCollection(); using var limitedParallelization = new SemaphoreSlim(100); // Run a bunch of get operations, but make sure we don't start too many at once. // We don't want timeouts just because we flood the connections var operations = Enumerable.Range(0, 20000 * connectionPools.Length).Select(async _ => { await limitedParallelization.WaitAsync(); try { var key = Guid.NewGuid().ToString(); await collection.UpsertAsync(key, fakeBytes, new KeyValue.UpsertOptions().Transcoder(transcoder)); await collection.RemoveAsync(key); } finally { limitedParallelization.Release(); } }).ToList(); // Give some time for the tasks to get cranking await Task.Delay(500); // Scale back down to one connection await Task.WhenAll(connectionPools.Select(p => p.ScaleAsync(-1))); Assert.All(connectionPools, p => Assert.Equal(1, p.Size)); // Wait for the operations to all complete. Some of them should fail with timeouts if they get dropped during scale down. await Task.WhenAll(operations); }
public async Task AddCount_PassValue_ReturnsTotalCount() { using (var fixture = new ClusterFixture()) { var grain = fixture.Cluster.GrainFactory.GetGrain <ICounterGrain>(Guid.Empty); var count = await grain.AddCount(10L); Assert.Equal(10L, count); } }
public async Task GetCount_Default_ReturnsTotalCount() { using (var fixture = new ClusterFixture()) { var grain = fixture.Cluster.GrainFactory.GetGrain <ICounterGrain>(Guid.Empty); var count = await grain.GetCount(); Assert.Equal(0L, count); } }
public async Task Test_BootStrap_Error_Propagates_To_View_Operations() { var settings = ClusterFixture.GetSettings(); var cluster = await Cluster.ConnectAsync(settings.ConnectionString, "Administrator", "password").ConfigureAwait(false); var bucket = await cluster.BucketAsync("doesnotexist").ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => bucket.ViewQueryAsync <object, object>("designdoc", "viewname")).ConfigureAwait(false); }).ConfigureAwait(false); }
public async Task SubscribedGrainStillSubscribedAfterDeactivation() { using (var clusterFixture = new ClusterFixture()) await clusterFixture.Dispatch(async() => { var grain = clusterFixture.GrainFactory.GetGrain <ITestGrain>(Guid.Empty); await grain.Subscribe(); await grain.Deactivate(); await clusterFixture.PublishToStream(StreamProviderName, Guid.Empty, DefaultStreamNamespace, "some item"); await TestGrain.Semaphore.WaitAsync(GetDefaultBlockingToken()); Assert.True(TestGrain.DidResumeSubscription); }); }
public async Task SubscribeCallToGrainCallsRedisStringSet() { using (var clusterFixture = new ClusterFixture()) await clusterFixture.Dispatch(async() => { var writeSemaphore = new SemaphoreSlim(0); clusterFixture.Redis .Setup(x => x.StringSet(It.IsAny <RedisKey>(), It.IsAny <RedisValue>(), It.IsAny <TimeSpan?>(), It.IsAny <When>(), It.IsAny <CommandFlags>())) .Callback((RedisKey key, RedisValue value, TimeSpan? timeSpan, When when, CommandFlags flags) => writeSemaphore.Release()); var grain = clusterFixture.GrainFactory.GetGrain <ITestGrain>(Guid.Empty); await grain.Subscribe(); await writeSemaphore.WaitAsync(GetDefaultBlockingToken()); }); }
public async Task VerifyMockedGuidGrainThrowsNotActivatedWhenMethodNotCalled() { var clusterFixture = new ClusterFixture { OutputHelper = testOutputHelper }; await clusterFixture.Start(); using (clusterFixture) await clusterFixture.Dispatch(() => { var primaryKey = Guid.NewGuid(); clusterFixture.Mock.GuidGrain <ITestGuidGrain>(primaryKey); Assert.ThrowsAny <Exception>(() => clusterFixture.Mock.VerifyGuidGrainActivated <ITestGuidGrain>(primaryKey)); return(Task.CompletedTask); }); }
public async Task Increment_Default_EventuallyIncrementsTotalCount() { using (var fixture = new ClusterFixture()) { var grain = fixture.Cluster.GrainFactory.GetGrain <ICounterStatelessGrain>(0L); var counterGrain = fixture.Cluster.GrainFactory.GetGrain <ICounterGrain>(Guid.Empty); await grain.Increment(); var countBefore = await counterGrain.GetCount(); Assert.Equal(0L, countBefore); await Task.Delay(TimeSpan.FromSeconds(2)); var countAfter = await counterGrain.GetCount(); } }
public async Task VerifyMockedGuidGrainDoesNotThrowOnVerifyActivatedWhenMethodCalled() { var clusterFixture = new ClusterFixture { OutputHelper = testOutputHelper }; await clusterFixture.Start(); using (clusterFixture) await clusterFixture.Dispatch(async() => { var primaryKey = Guid.NewGuid(); clusterFixture.Mock.GuidGrain <ITestGuidGrain>(primaryKey); var mockGrain = clusterFixture.Mock.Mock.Object.GetGrain <ITestGuidGrain>(primaryKey); await mockGrain.Foo(); clusterFixture.Mock.VerifyGuidGrainActivated <ITestGuidGrain>(primaryKey); }); }
public Test_NeonNodeTask(ClusterFixture fixture, ITestOutputHelper testOutputHelper) { this.fixture = fixture; var options = new ClusterFixtureOptions(); //################################################################ // $debug(jefflill): Restore this after manual testing is complete //var status = fixture.StartWithNeonAssistant(options: options); //################################################################ var status = fixture.StartWithCurrentCluster(options: options); if (status == TestFixtureStatus.Disabled) { return; } else if (status == TestFixtureStatus.AlreadyRunning) { fixture.ResetCluster(); } }
public CallingGrainTests(ClusterFixture fixture) { this.fixture = fixture; }
private async Task <(Guid StreamId, string StreamNamespace, Task <List <dynamic> > Awaiter)> CreateProducerConsumerStreamAwaiter(ClusterFixture clusterFixture, int messageCount) { var streamId = Guid.NewGuid(); var streamNamespace = Guid.NewGuid().ToString(); var streamSubscriptionAwaiter = await clusterFixture.SubscribeAndGetTaskAwaiter <string>(StreamProviderName, streamId, streamNamespace, messageCount); var publishTask = Task.Factory.StartNew(async() => { for (var i = 0; i < messageCount; i++) { await clusterFixture.PublishToStream(StreamProviderName, streamId, streamNamespace, $"test:{streamId}-{streamNamespace} message:{i}"); } }); return(streamId, streamNamespace, streamSubscriptionAwaiter); }
private async Task <List <(Guid StreamId, string StreamNamespace, Task <List <dynamic> > Awaiter)> > CreateProducerConsumerStreamAwaiter(ClusterFixture clusterFixture, int n, int messageCount) { var dataSets = new List <(Guid StreamId, string StreamNamespace, Task <List <dynamic> > Awaiter)>(); for (var i = 0; i < n; i++) { dataSets.Add(await CreateProducerConsumerStreamAwaiter(clusterFixture, messageCount)); } return(dataSets); }
public TimerGrainTests(ClusterFixture fixture) { this.fixture = fixture; }
public PubActor_Test(ClusterFixture fixture) { this.cluster = fixture.Cluster; }
public BasicGrainTests(ClusterFixture fixture) { this.fixture = fixture; }
public HelloGrainTests(ClusterFixture fixture) { _cluster = fixture.Cluster; _eventStore = fixture.EventStore; }
public static async Task <(ICouchbaseCollection collection, string docId, SampleDoc sampleDoc)> PrepSampleDoc(ClusterFixture fixture, ITestOutputHelper outputHelper, [CallerMemberName] string testName = nameof(PrepSampleDoc)) { var defaultCollection = await fixture.OpenDefaultCollection(outputHelper); var docId = Guid.NewGuid().ToString(); var sampleDoc = new SampleDoc(docId, testName, "bar", 100); return(defaultCollection, docId, sampleDoc); }
public async Task Test_BootStrap_Error_Propagates_To_Collection_Operations() { const string id = "key;"; var value = new { x = "y" }; var settings = ClusterFixture.GetSettings(); var cluster = await Cluster.ConnectAsync(settings.ConnectionString, "Administrator", "password").ConfigureAwait(false); // This test may be invalid. It is throwing BucketNotFoundException here, and that is appropriate,. as far as I can tell. var bucket = await cluster.BucketAsync("doesnotexist").ConfigureAwait(false); var defaultCollection = bucket.DefaultCollection(); // We would have to inject a bootstrapping error *after* BucketAsync succeeds, to continue with the test. await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.ExistsAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAndLockAsync(id, TimeSpan.MaxValue)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAndTouchAsync(id, TimeSpan.MaxValue)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAnyReplicaAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.LookupInAsync(id, null)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.MutateInAsync(id, null)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.RemoveAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.TouchAsync(id, TimeSpan.Zero)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.InsertAsync(id, value)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.ReplaceAsync(id, value)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.UnlockAsync <dynamic>(id, 0)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.UpsertAsync(id, value)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAllReplicasAsync(id).First()).ConfigureAwait(false); }).ConfigureAwait(false); }
public TestWindowAgg(ClusterFixture fixture) { _cluster = fixture.Cluster; }
public async Task Test_BootStrap_Error_Propagates_To_Collection_Operations() { const string id = "key;"; var value = new { x = "y" }; var settings = ClusterFixture.GetSettings(); var cluster = await Cluster.ConnectAsync(settings.ConnectionString, "Administrator", "password").ConfigureAwait(false); var bucket = await cluster.BucketAsync("doesnotexist").ConfigureAwait(false); var defaultCollection = bucket.DefaultCollection(); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.ExistsAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAndLockAsync(id, TimeSpan.MaxValue)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAndTouchAsync(id, TimeSpan.MaxValue)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAnyReplicaAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.LookupInAsync(id, null)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.MutateInAsync(id, null)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.RemoveAsync(id)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.TouchAsync(id, TimeSpan.Zero)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.InsertAsync(id, value)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.ReplaceAsync(id, value)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.UnlockAsync <dynamic>(id, 0)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.UpsertAsync(id, value)).ConfigureAwait(false); }).ConfigureAwait(false); await Assert.ThrowsAsync <AuthenticationFailureException>(async() => { await ThrowAuthenticationException(() => defaultCollection.GetAllReplicasAsync(id).First()).ConfigureAwait(false); }).ConfigureAwait(false); }
public StreamTopicTests(ClusterFixture fixture) { _fixture = fixture; }
public EventSourcedGrainTests(ClusterFixture fixture) =>
public InnerTxActor_Test(ClusterFixture fixture) { this.cluster = fixture.Cluster; }
public TestWatermarkGeneration(ClusterFixture fixture) { _cluster = fixture.Cluster; }
public TestMapOperator(ClusterFixture fixture) { _cluster = fixture.Cluster; }
public EventSourcedRegistryGrainTests(ClusterFixture fixture) =>
public WeightHoldLockActor_Test(ClusterFixture fixture) { this.cluster = fixture.Cluster; }