protected async Task Grain_GuidKey_AWSStore_Read_Write()
        {
            Guid id = Guid.NewGuid();
            IAWSStorageTestGrain grain = this.fixture.GrainFactory.GetGrain <IAWSStorageTestGrain>(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"
        }
        protected async Task Grain_AWSStore_SiloRestart()
        {
            var initialServiceId    = this.HostedCluster.Options.ServiceId;
            var initialDeploymentId = this.HostedCluster.Options.ClusterId;
            var serviceId           = await this.HostedCluster.Client.GetGrain <IServiceIdGrain>(Guid.Empty).GetServiceId();

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

            Guid id = Guid.NewGuid();
            IAWSStorageTestGrain grain = this.fixture.GrainFactory.GetGrain <IAWSStorageTestGrain>(id);

            int val = await grain.GetValue();

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

            await grain.DoWrite(1);

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

            await this.HostedCluster.InitializeClientAsync();

            output.WriteLine("Silos restarted");

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

            output.WriteLine("ClusterId={0} ServiceId={1}", this.HostedCluster.Options.ClusterId, serviceId);
            Assert.Equal(initialServiceId, serviceId);                               // "ServiceId same after restart."
            Assert.Equal(initialDeploymentId, this.HostedCluster.Options.ClusterId); // "ClusterId same after restart."

            // Since the client was destroyed and restarted, the grain reference needs to be recreated.
            grain = this.fixture.GrainFactory.GetGrain <IAWSStorageTestGrain>(id);

            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"
        }
        protected async Task Grain_AWSStore_Read()
        {
            Guid id = Guid.NewGuid();
            IAWSStorageTestGrain grain = this.fixture.GrainFactory.GetGrain <IAWSStorageTestGrain>(id);

            int val = await grain.GetValue();

            Assert.Equal(0, val);  // "Initial value"
        }
        protected async Task Grain_AWSStore_Delete()
        {
            Guid id = Guid.NewGuid();
            IAWSStorageTestGrain grain = this.fixture.GrainFactory.GetGrain <IAWSStorageTestGrain>(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"
        }
Ejemplo n.º 5
0
        protected async Task Grain_AWSStore_SiloRestart()
        {
            var initialServiceId    = this.HostedCluster.ClusterConfiguration.Globals.ServiceId;
            var initialDeploymentId = this.HostedCluster.DeploymentId;

            output.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId);

            Guid id = Guid.NewGuid();
            IAWSStorageTestGrain grain = this.fixture.GrainFactory.GetGrain <IAWSStorageTestGrain>(id);

            int val = await grain.GetValue();

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

            await grain.DoWrite(1);

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

            output.WriteLine("Silos restarted");

            output.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId);
            Assert.Equal(initialServiceId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); // "ServiceId same after restart."
            Assert.Equal(initialDeploymentId, this.HostedCluster.DeploymentId);                        // "DeploymentId 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"
        }
Ejemplo n.º 6
0
        protected async Task Grain_AWSStore_SiloRestart()
        {
            var initialServiceId    = this.HostedCluster.Globals.ServiceId;
            var initialDeploymentId = this.HostedCluster.DeploymentId;

            output.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.Globals.ServiceId);

            Guid id = Guid.NewGuid();
            IAWSStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <IAWSStorageTestGrain>(id);

            int val = await grain.GetValue();

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

            await grain.DoWrite(1);

            output.WriteLine("About to reset Silos");
            this.HostedCluster.RestartDefaultSilos(true);
            output.WriteLine("Silos restarted");

            output.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.Globals.ServiceId);
            Assert.Equal(initialServiceId, this.HostedCluster.Globals.ServiceId);  // "ServiceId same after restart."
            Assert.NotEqual(initialDeploymentId, this.HostedCluster.DeploymentId); // "DeploymentId different 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"
        }