public ClusterFixture()
        {
            _redis = new RedisInside.Redis();
            Console.WriteLine(_redis.Endpoint.ToString());

            Console.WriteLine("Initializing Orleans TestCluster");
            var builder = new TestClusterBuilder(1);

            builder.Options.ServiceId = "Service";
            builder.Options.ClusterId = "TestCluster";
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            builder.AddClientBuilderConfigurator <ClientConfigurator>();

            //this is one of the only ways to be able to pass data (the redis connection string) to the silo(s) that TestCluster will startup
            builder.ConfigureHostConfiguration(config =>
            {
                config.AddInMemoryCollection(new Dictionary <string, string>()
                {
                    { nameof(RedisInside.Redis), _redis.Endpoint.ToString() }
                });
            });

            Cluster = builder.Build();

            Cluster.Deploy();
            Cluster.InitializeClient();
            Client = Cluster.Client;

            var redisOptions = ConfigurationOptions.Parse(_redis.Endpoint.ToString());
            var connection   = ConnectionMultiplexer.ConnectAsync(redisOptions).Result;

            Database = connection.GetDatabase();
            Console.WriteLine("Initialized Orleans TestCluster");
        }
Exemple #2
0
        /// <summary>
        /// Keeps all the fake grain storage instances in use by different clusters to facilitate parallel unit testing.
        /// </summary>
        //public static ConcurrentDictionary<string, ConcurrentBag<FakeGrainStorage>> GrainStorageGroups { get; } = new ConcurrentDictionary<string, ConcurrentBag<FakeGrainStorage>>();

        /// <summary>
        /// Gets the fake grain storage item for the given grain by searching across all silos.
        /// </summary>
        //public IGrainState GetGrainState(Type implementationType, string name, IGrain grain)
        //{
        //    return GrainStorageGroups[TestClusterId]
        //        .SelectMany(_ => _.Storage)
        //        .Where(_ => _.Key.Item1 == $"{implementationType.FullName}{(name == null ? "" : $",{typeof(PersistentGrain).Namespace}.{name}")}")
        //        .Where(_ => _.Key.Item2.Equals((GrainReference)grain))
        //        .Select(_ => _.Value)
        //        .SingleOrDefault();
        //}

        /// <summary>
        /// Keeps all the fake timer registries in use by different clusters to facilitate parallel unit testing.
        /// </summary>
        //public static ConcurrentDictionary<string, ConcurrentBag<FakeTimerRegistry>> TimerRegistryGroups { get; } = new ConcurrentDictionary<string, ConcurrentBag<FakeTimerRegistry>>();

        /// <summary>
        /// Gets all the fake timers for the target grain across all silos.
        /// </summary>
        //public IEnumerable<FakeTimerEntry> GetTimers(IGrain grain)
        //{
        //    return TimerRegistryGroups[TestClusterId]
        //        .SelectMany(_ => _.GetAll())
        //        .Where(_ => _.Grain.GrainReference.Equals((GrainReference)grain));
        //}

        /// <summary>
        /// Keeps all the fake reminder registries in use by different clusters to facilitate parallel unit testing.
        /// </summary>
        //    public static ConcurrentDictionary<string, ConcurrentBag<FakeReminderRegistry>> ReminderRegistryGroups { get; } = new ConcurrentDictionary<string, ConcurrentBag<FakeReminderRegistry>>();

        /// <summary>
        /// Gets the target fake reminder by searching across all silos.
        /// </summary>
        //public FakeReminder GetReminder(IGrain grain, string name)
        //{
        //    return ReminderRegistryGroups[TestClusterId]
        //        .Select(_ => _.GetReminder((GrainReference)grain, name).Result)
        //        .Where(_ => _ != null)
        //        .SingleOrDefault();
        //}

        public ClusterFixture()
        {
            // prepare to receive the fake services from individual silos
            //GrainStorageGroups[TestClusterId] = new ConcurrentBag<FakeGrainStorage>();
            //TimerRegistryGroups[TestClusterId] = new ConcurrentBag<FakeTimerRegistry>();
            //ReminderRegistryGroups[TestClusterId] = new ConcurrentBag<FakeReminderRegistry>();

            var builder = new TestClusterBuilder();

            // add the cluster id for this instance
            // this allows the silos to safely lookup shared data for this cluster deployment
            // without this we can only share data via static properties and that messes up parallel testing
            //builder.ConfigureHostConfiguration(config =>
            //{
            //    config.AddInMemoryCollection(new Dictionary<string, string>()
            //    {
            //        { nameof(TestClusterId), TestClusterId }
            //    });
            //});

            // a configurator allows the silos to configure themselves
            // at this time, configurators cannot take injected parameters
            // therefore we must other means of sharing objects as you can see above
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            Cluster = builder.Build();

            Cluster.Deploy();
        }
Exemple #3
0
        public void Setup()
        {
            var options = new TestClusterOptions();

            _host = new TestCluster(options);
            _host.Deploy();
        }
Exemple #4
0
        public Task InitializeAsync()
        {
            Cluster = _builder.Build();
            Cluster.Deploy();

            return(Task.CompletedTask);
        }
Exemple #5
0
        public void BenchmarkSetup()
        {
            var builder = new TestClusterBuilder(1);

            _host = builder.Build();
            _host.Deploy();
        }
Exemple #6
0
        public void Setup()
        {
            var options = new TestClusterOptions();

            _host = new TestCluster(options, new IConfigurationSource[0]);
            _host.Deploy();
        }
        public void BenchmarkSetup()
        {
            var options = new TestClusterOptions(1);

            _host = new TestCluster(options);
            _host.Deploy();
        }
Exemple #8
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Starting silos");
            Console.WriteLine("Dashboard will listen on http://localhost:8080/");

            // Deploy 3 silos
            var options = new TestClusterOptions(3);

            options.ClusterConfiguration.Globals.RegisterDashboard();
            var cluster = new TestCluster(options);

            cluster.Deploy();

            // generate some calls to a test grain
            Console.WriteLine("All silos are up and running");

            var tokenSource = new CancellationTokenSource();
            var t           = new Thread(() => CallGenerator(cluster.Client, tokenSource).Wait());

            t.Start();

            Console.ReadLine();
            tokenSource.Cancel();
            try
            {
                t.Join(TimeSpan.FromSeconds(3));
            }
            catch
            { }
            cluster.StopAllSilos();
        }
        public ClusterFixture()
        {
            var builder = new TestClusterBuilder();

            builder.Options.ServiceId = Guid.NewGuid().ToString();
            Cluster = builder.Build();
            Cluster.Deploy();
        }
Exemple #10
0
        public void DeployWithoutAdditionalConfiguration()
        {
            var cluster = new TestCluster();

            cluster.Deploy();

            cluster.StopAllSilos();
        }
        public CartGrainTest()
        {
            var builder = new TestClusterBuilder();

            builder.AddSiloBuilderConfigurator <ClusterConfigurator>();
            _cluster = builder.Build();
            _cluster.Deploy();
        }
Exemple #12
0
 private void Initialize(TestClusterOptions options = null)
 {
     if (options == null)
     {
         options = new TestClusterOptions(1);
     }
     testCluster = new TestCluster(options);
     testCluster.Deploy();
 }
        public void Setup()
        {
            var options = new TestClusterOptions();

            options.ClusterConfiguration.AddMemoryStorageProvider();
            options.UseSiloBuilderFactory <SiloBuilderFactory>();
            _host = new TestCluster(options);
            _host.Deploy();
        }
Exemple #14
0
        public void SetUp()
        {
            var builder = new TestClusterBuilder();

            builder.AddSiloBuilderConfigurator <TestSiloConfigurations>();
            _testCluster = builder.Build();

            _testCluster.Deploy();
        }
Exemple #15
0
        public void BenchmarkSetup()
        {
            var options = new TestClusterOptions(1);

            options.ExtendedFallbackOptions.TraceToConsole = false;
            options.ClusterConfiguration.ApplyToAllNodes(c => c.DefaultTraceLevel = Severity.Warning);
            _host = new TestCluster(options);
            _host.Deploy();
        }
        private void Initialize(TestClusterBuilder builder = null)
        {
            if (builder == null)
            {
                builder = new TestClusterBuilder(1);
            }

            testCluster = builder.Build();
            testCluster.Deploy();
        }
Exemple #17
0
        public ClusterFixture()
        {
            var builder = new TestClusterBuilder();

            builder.AddSiloBuilderConfigurator <TestSiloConfigurations>();
            builder.AddClientBuilderConfigurator <TestClientConfigurations>();

            Cluster = builder.Build();
            Cluster.Deploy();
        }
Exemple #18
0
 private void Initialize(TestClusterOptions options = null)
 {
     if (options == null)
     {
         options = new TestClusterOptions(1);
     }
     testCluster = new TestCluster(options);
     testCluster.Deploy();
     this.logger = testCluster.Client.Logger;
 }
Exemple #19
0
        public OrleansFixture(/*ITestOutputHelper outputHelper*/)
        {
            var builder = new TestClusterBuilder();

            //TestSiloConfigurator.OutputHelper = outputHelper;
            builder.AddSiloBuilderConfigurator <TestSiloConfigurator>();

            Cluster = builder.Build();
            Cluster.Deploy();
        }
Exemple #20
0
        public GrainTest()
        {
            var builder = new TestClusterBuilder(1);

            builder.AddSiloBuilderConfigurator <SiloConfigurator>();

            TestCluster = builder.Build();

            TestCluster.Deploy();
        }
Exemple #21
0
        public ClusterFixture()
        {
            var builder = new TestClusterBuilder(1)
                          .AddSiloBuilderConfigurator <SiloBuilderConfigurator>()
                          .AddClientBuilderConfigurator <ClientBuilderConfigurator>();

            builder.Options.ClusterId = _clusterId;

            Cluster = builder.Build();
            Cluster.Deploy();
        }
        private void Initialize(TestClusterBuilder builder = null)
        {
            if (builder == null)
            {
                builder = new TestClusterBuilder(1);
            }

            builder.ConfigureLegacyConfiguration();
            testCluster = builder.Build();
            testCluster.Deploy();
        }
Exemple #23
0
        private void Initialize(TimeSpan collectionAgeLimit, TimeSpan quantum)
        {
            var builder = new TestClusterBuilder(1);

            builder.Properties["CollectionQuantum"]         = quantum.ToString();
            builder.Properties["DefaultCollectionAgeLimit"] = collectionAgeLimit.ToString();
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            testCluster = builder.Build();
            testCluster.Deploy();
            this.logger = this.testCluster.Client.ServiceProvider.GetRequiredService <ILogger <ActivationCollectorTests> >();
        }
Exemple #24
0
        private void SetupAndDeployCluster(string defaultPlacementStrategy, params Type[] blackListedTypes)
        {
            cluster?.StopAllSilos();
            var typesName = blackListedTypes.Select(t => t.FullName).ToList();
            var options   = new TestClusterOptions(1);

            options.ClusterConfiguration.Globals.TypeMapRefreshInterval   = refreshInterval;
            options.ClusterConfiguration.Globals.DefaultPlacementStrategy = defaultPlacementStrategy;
            options.ClusterConfiguration.Overrides[Silo.PrimarySiloName].ExcludedGrainTypes = typesName;
            cluster = new TestCluster(options);
            cluster.Deploy();
        }
Exemple #25
0
        public UnitTest1()
        {
            var build = new TestClusterBuilder();

            build.AddSiloBuilderConfigurator <TestSiloConfigurator>();
            build.AddClientBuilderConfigurator <TestClientConfigurator>();
            cluster = build.Build();
            if (cluster?.Primary == null)
            {
                cluster?.Deploy();
            }
        }
Exemple #26
0
        public Task InitializeAsync()
        {
            var builder = new TestClusterBuilder(_noOfSilos);

            builder.AddSiloBuilderConfigurator <SiloBuilderConfigurator>();
            builder.AddClientBuilderConfigurator <ClientBuilderConfigurator>();

            Cluster = builder.Build();
            Cluster.Deploy();

            return(Task.CompletedTask);
        }
Exemple #27
0
        public OrleansSiloFixture()
        {
            var clusterBuilder = new TestClusterBuilder(initialSilosCount: 2);

            clusterBuilder.AddSiloBuilderConfigurator <TestSiloBuilderConfigurator>();

            Cluster = clusterBuilder.Build();
            if (Cluster.Primary == null)
            {
                Cluster.Deploy();
            }
        }
Exemple #28
0
        public void SetUp()
        {
            var builder = new TestClusterBuilder();

            builder.AddSiloBuilderConfigurator <TestSiloConfigurations>();
            _testCluster = builder.Build();

            _testCluster.Deploy();

            _guid       = new Guid();
            _orderGrain = _testCluster.GrainFactory.GetGrain <IOrderGrain>(_guid);
        }
        private void SetupAndDeployCluster(Type defaultPlacementStrategy, params Type[] blackListedTypes)
        {
            cluster?.StopAllSilos();
            var builder = new TestClusterBuilder(1);

            builder.Properties["DefaultPlacementStrategy"] = RuntimeTypeNameFormatter.Format(defaultPlacementStrategy);
            builder.Properties["BlockedGrainTypes"]        = string.Join("|", blackListedTypes.Select(t => RuntimeTypeNameFormatter.Format(t)));
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            builder.AddClientBuilderConfigurator <ClientConfigurator>();
            cluster = builder.Build();
            cluster.Deploy();
        }
Exemple #30
0
        private void Initialize(TimeSpan collectionAgeLimit, TimeSpan quantum)
        {
            GlobalConfiguration.ENFORCE_MINIMUM_REQUIREMENT_FOR_AGE_LIMIT = false;
            var options = new TestClusterOptions(1);
            var config  = options.ClusterConfiguration;

            config.Globals.CollectionQuantum = quantum;
            config.Globals.Application.SetDefaultCollectionAgeLimit(collectionAgeLimit);
            config.Globals.Application.SetCollectionAgeLimit(typeof(IdleActivationGcTestGrain2), TimeSpan.FromSeconds(10));
            config.Globals.Application.SetCollectionAgeLimit(typeof(BusyActivationGcTestGrain2), TimeSpan.FromSeconds(10));
            testCluster = new TestCluster(config);
            testCluster.Deploy();
        }