public async Task Test_Lookup_5Grains_FT_TI_LZ_PK()
        {
            //await base.StartAndWaitForSecondSilo();

            IPlayer_FT_TI_LZ_PK p1 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(1);
            await p1.SetLocation(ITC.Seattle);

            IPlayer_FT_TI_LZ_PK p2 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(2);
            IPlayer_FT_TI_LZ_PK p3 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(3);
            IPlayer_FT_TI_LZ_PK p4 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(4);
            IPlayer_FT_TI_LZ_PK p5 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(5);

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

            await p4.SetLocation(ITC.Tehran);

            await p5.SetLocation(ITC.Yazd);

            for (int i = 0; i < 100; ++i)
            {
                var       tasks  = new List <Task>();
                const int offset = 10000;   // Make unique to avoid conflict with other tests using this grain interface
                for (int j = offset; j < offset + 10; ++j)
                {
                    p1 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(j);
                    tasks.Add(p1.SetLocation(ITC.Yazd + i + "-" + j));
                }
                await Task.WhenAll(tasks);
            }
        }
        public async Task Test_Lookup_3Grains_FT_TI_LZ_PK()
        {
            IPlayer_FT_TI_LZ_PK p1 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(1);
            await p1.SetLocation(ITC.Seattle);

            IPlayer_FT_TI_LZ_PK p2 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(2);
            IPlayer_FT_TI_LZ_PK p3 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(3);

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

            var locIdx = await base.GetAndWaitForIndex <string, IPlayer_FT_TI_LZ_PK>(ITC.LocationProperty);

            Task <int> getLocationCount(string location) => this.GetPlayerLocationCount <IPlayer_FT_TI_LZ_PK, PlayerProperties_FT_TI_LZ_PK>(location, ITC.DelayUntilIndexesAreUpdatedLazily);

            Assert.Equal(2, await getLocationCount(ITC.Seattle));

            await p2.Deactivate();

            await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);

            Assert.Equal(2, await getLocationCount(ITC.Seattle));

            p2 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(2);
            Assert.Equal(ITC.Seattle, await p2.GetLocation());

            Assert.Equal(2, await getLocationCount(ITC.Seattle));
        }
Example #3
0
        public async Task Test_Lookup_3Grains_FT_TI_LZ_PK()
        {
            await base.StartAndWaitForSecondSilo();

            IPlayer_FT_TI_LZ_PK p1 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(1);
            await p1.SetLocation(ITC.Seattle);

            IPlayer_FT_TI_LZ_PK p2 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(2);
            IPlayer_FT_TI_LZ_PK p3 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(3);

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

            var locIdx = await base.GetAndWaitForIndex <string, IPlayer_FT_TI_LZ_PK>(ITC.LocationProperty);

            Task <int> getLocationCount(string location) => this.GetPlayerLocationCount <IPlayer_FT_TI_LZ_PK, PlayerProperties_FT_TI_LZ_PK>(location, ITC.DelayUntilIndexesAreUpdatedLazily);

            base.Output.WriteLine("Before check 1");
            Assert.Equal(2, await getLocationCount(ITC.Seattle));

            await p2.Deactivate();

            await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);

            base.Output.WriteLine("Before check 2");
            Assert.Equal(2, await getLocationCount(ITC.Seattle));   // Deactivate does not affect Total indexes

            p2 = base.GetGrain <IPlayer_FT_TI_LZ_PK>(2);
            base.Output.WriteLine("Before check 3");
            Assert.Equal(ITC.Seattle, await p2.GetLocation());

            base.Output.WriteLine("Before check 4");
            Assert.Equal(2, await getLocationCount(ITC.Seattle));
            base.Output.WriteLine("Done.");
        }