Exemplo n.º 1
0
        public async Task Grain_GuidKey_GrainStorage_Read_Write()
        {
            Guid id = Guid.NewGuid();
            IGrainStorageTestGrain grain = this.GrainFactory.GetGrain <IGrainStorageTestGrain>(id);

            int val = await grain.GetValue();

            Assert.Equal(0, val);  // "Initial value"

            await grain.DoWrite(1);

            val = await grain.GetValue();

            Assert.Equal(1, val);  // "Value after Write-1"

            await grain.DoWrite(2);

            val = await grain.GetValue();

            Assert.Equal(2, val);  // "Value after Write-2"

            val = await grain.DoRead();

            Assert.Equal(2, val);  // "Value after Re-Read"
        }
Exemplo n.º 2
0
        public async Task Grain_GrainStorage_SiloRestart()
        {
            var initialServiceId = fixture.GetClientServiceId();

            output.WriteLine("ClusterId={0} ServiceId={1}", this.HostedCluster.Options.ClusterId, initialServiceId);

            Guid id = Guid.NewGuid();
            IGrainStorageTestGrain grain = this.GrainFactory.GetGrain <IGrainStorageTestGrain>(id, this.grainNamespace);

            int val = await grain.GetValue();

            Assert.Equal(0, val);  // "Initial value"

            await grain.DoWrite(1);

            var serviceId = await this.GrainFactory.GetGrain <IServiceIdGrain>(Guid.Empty).GetServiceId();

            Assert.Equal(initialServiceId, serviceId);  // "ServiceId same before restart."

            output.WriteLine("About to reset Silos");
            foreach (var silo in this.HostedCluster.GetActiveSilos().ToList())
            {
                await this.HostedCluster.RestartSiloAsync(silo);
            }

            await this.HostedCluster.InitializeClientAsync();

            output.WriteLine("Silos restarted");

            serviceId = await this.GrainFactory.GetGrain <IServiceIdGrain>(Guid.Empty).GetServiceId();

            grain = this.GrainFactory.GetGrain <IGrainStorageTestGrain>(id, this.grainNamespace);
            output.WriteLine("ClusterId={0} ServiceId={1}", this.HostedCluster.Options.ClusterId, serviceId);
            Assert.Equal(initialServiceId, serviceId);  // "ServiceId same after restart."

            val = await grain.GetValue();

            Assert.Equal(1, val);  // "Value after Write-1"

            await grain.DoWrite(2);

            val = await grain.GetValue();

            Assert.Equal(2, val);  // "Value after Write-2"

            val = await grain.DoRead();

            Assert.Equal(2, val);  // "Value after Re-Read"
        }
Exemplo n.º 3
0
        public async Task Grain_GrainStorage_Read()
        {
            Guid id = Guid.NewGuid();
            IGrainStorageTestGrain grain = this.GrainFactory.GetGrain <IGrainStorageTestGrain>(id);

            int val = await grain.GetValue();

            Assert.Equal(0, val);  // "Initial value"
        }
Exemplo n.º 4
0
        public async Task Grain_GrainStorage_Delete()
        {
            Guid id = Guid.NewGuid();
            IGrainStorageTestGrain grain = this.GrainFactory.GetGrain <IGrainStorageTestGrain>(id);

            await grain.DoWrite(1);

            await grain.DoDelete();

            int val = await grain.GetValue(); // Should this throw instead?

            Assert.Equal(0, val);             // "Value after Delete"

            await grain.DoWrite(2);

            val = await grain.GetValue();

            Assert.Equal(2, val);  // "Value after Delete + New Write"
        }