Beispiel #1
0
        public EHPurgeLogicTests()
        {
            //an mock eh settings
            this.ehSettings = new EventHubPartitionSettings
            {
                Hub             = new EventHubOptions(),
                Partition       = "MockPartition",
                ReceiverOptions = new EventHubReceiverOptions()
            };

            //set up cache pressure monitor and purge predicate
            this.cachePressureInjectionMonitor = new CachePressureInjectionMonitor();
            this.purgePredicate = new PurgeDecisionInjectionPredicate(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(30));

            //set up serialization env
            var environment = SerializationTestEnvironment.InitializeWithDefaults();

            this.serializationManager = environment.SerializationManager;

            //set up buffer pool, small buffer size make it easy for cache to allocate multiple buffers
            var oneKB = 1024;

            this.bufferPool        = new ObjectPool <FixedSizeBuffer>(() => new FixedSizeBuffer(oneKB));
            this.telemetryProducer = NullTelemetryProducer.Instance;
        }
Beispiel #2
0
        private void InitializeSerializer(SerializerToUse serializerToUse)
        {
            TypeInfo fallback = null;

            switch (serializerToUse)
            {
            case SerializerToUse.Default:
                break;

            case SerializerToUse.IlBasedFallbackSerializer:
                fallback = typeof(ILBasedSerializer).GetTypeInfo();
                break;

#if !NETSTANDARD_TODO
            case SerializerToUse.BinaryFormatterFallbackSerializer:
                fallback = typeof(BinaryFormatterSerializer).GetTypeInfo();
                break;
#endif
            default:
                throw new InvalidOperationException("Invalid Serializer was selected");
            }

            var config = new ClientConfiguration
            {
                FallbackSerializationProvider = fallback
            };
            this.environment          = SerializationTestEnvironment.InitializeWithDefaults(config);
            this.serializationManager = this.environment.SerializationManager;
        }
 public StreamTypeSerializationTests()
 {
     // FakeSerializer definied in ExternalSerializerTest.cs
     SerializationTestEnvironment.Initialize(new List <TypeInfo> {
         typeof(FakeSerializer).GetTypeInfo()
     });
 }
        public DynamoDBStorageProviderTests()
        {
            if (!AWSTestConstants.IsDynamoDbAvailable)
            {
                throw new SkipException("Unable to connect to DynamoDB simulator");
            }

            var testEnvironment = new SerializationTestEnvironment();

            DefaultProviderRuntime = new StorageProviderManager(
                testEnvironment.GrainFactory,
                null,
                new ClientProviderRuntime(testEnvironment.GrainFactory, null));
            ((StorageProviderManager)DefaultProviderRuntime).LoadEmptyStorageProviders().WaitWithThrow(TestConstants.InitTimeout);
            testEnvironment.InitializeForTesting();

            var properties = new Dictionary <string, string>();

            properties["DataConnectionString"] = $"Service={AWSTestConstants.Service}";
            var config   = new ProviderConfiguration(properties, null);
            var provider = new DynamoDBStorageProvider();

            provider.Init("DynamoDBStorageProviderTests", DefaultProviderRuntime, config).Wait();
            PersistenceStorageTests = new CommonStorageTests(provider);
        }
Beispiel #5
0
        public EHPurgeLogicTests()
        {
            //an mock eh settings
            this.ehSettings      = new EventHubPartitionSettings();
            ehSettings.Hub       = new EventHubSettings();
            ehSettings.Partition = "MockPartition";

            //set up cache pressure monitor and purge predicate
            this.cachePressureInjectionMonitor = new CachePressureInjectionMonitor();
            this.purgePredicate = new PurgeDecisionInjectionPredicate(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(30));

            //set up serialization env
            var environment = SerializationTestEnvironment.InitializeWithDefaults();

            this.serializationManager = environment.SerializationManager;

            //set up buffer pool, small buffer size make it easy for cache to allocate multiple buffers
            this.bufferPoolSizeInMB = EventHubStreamProviderSettings.DefaultCacheSizeMb;
            var oneKB = 1024;

            this.bufferPool = new FixedSizeObjectPool <FixedSizeBuffer>(this.bufferPoolSizeInMB, () => new FixedSizeBuffer(oneKB));

            //set up logger
            this.logger = new NoOpTestLogger().GetLogger(this.GetType().Name);
        }
Beispiel #6
0
        public SerializationTests()
        {
            var config = new ClientConfiguration {
                SerializationProviders = { typeof(OrleansJsonSerializer).GetTypeInfo() }
            };

            this.environment = SerializationTestEnvironment.InitializeWithDefaults(config);
        }
 public OrleansJsonSerializerTests()
 {
     this.environment = SerializationTestEnvironment.InitializeWithDefaults(
         builder => builder.ConfigureServices(services =>
     {
         services.AddSingleton <IGeneralizedCodec>(new NewtonsoftJsonCodec(isSupportedFunc: type => type.HasAttribute <JsonTypeAttribute>()));
     }));
 }
Beispiel #8
0
 public SQSAdapterTests(ITestOutputHelper output)
 {
     this.output       = output;
     this.deploymentId = MakeDeploymentId();
     LogManager.Initialize(new NodeConfiguration());
     BufferPool.InitGlobalBufferPool(new MessagingConfiguration(false));
     SerializationTestEnvironment.Initialize();
 }
Beispiel #9
0
        protected BaseClusterFixture()
        {
            TestDefaultConfiguration.InitializeDefaults();
            GrainClient.Uninitialize();
            SerializationTestEnvironment.Initialize();
            var hostedCluster = CreateClusterHost();

            this.HostedCluster = hostedCluster;
        }
Beispiel #10
0
        public SerializationTestsBase(SerializationTestEnvironment environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }

            _environment = environment;
        }
Beispiel #11
0
 public SerializationOrderTests()
 {
     FakeTypeToSerialize.Reset();
     FakeSerializer1.Reset();
     FakeSerializer2.Reset();
     this.environment = SerializationTestEnvironment.InitializeWithDefaults(
         builder => builder.Configure <SerializationProviderOptions>(
             options => options.SerializationProviders.AddRange(new[] { typeof(FakeSerializer1), typeof(FakeSerializer2) })));
 }
Beispiel #12
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public CommonFixture()
        {
            var testEnvironment = new SerializationTestEnvironment();
            DefaultProviderRuntime = new StorageProviderManager(testEnvironment.GrainFactory, null);
            ((StorageProviderManager)DefaultProviderRuntime).LoadEmptyStorageProviders(
                new ClientProviderRuntime(testEnvironment.GrainFactory, null)).WaitWithThrow(TestConstants.InitTimeout);

            testEnvironment.InitializeForTesting();
        }
Beispiel #13
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public CommonFixture()
        {
            var testEnvironment = new SerializationTestEnvironment();

            DefaultProviderRuntime = new StorageProviderManager(testEnvironment.GrainFactory, null);
            ((StorageProviderManager)DefaultProviderRuntime).LoadEmptyStorageProviders(
                new ClientProviderRuntime(testEnvironment.GrainFactory, null)).WaitWithThrow(TestConstants.InitTimeout);

            testEnvironment.InitializeForTesting();
        }
 public ProtoBufNetSerializationTests() : base(SerializationTestEnvironment.InitializeWithDefaults(
                                                   new ClientConfiguration
 {
     SerializationProviders =
     {
         typeof(ProtobufNetSerializer).GetTypeInfo()
     }
 }))
 {
 }
 public RequestContextTests_Local()
 {
     SerializationTestEnvironment.Initialize();
     oldPropagateActivityId              = RequestContext.PropagateActivityId;
     RequestContext.PropagateActivityId  = true;
     Trace.CorrelationManager.ActivityId = Guid.Empty;
     RequestContext.Clear();
     headers.Clear();
     GrainClient.ClientInvokeCallback = null;
 }
 public OrleansJsonSerializerTests()
 {
     this.environment = SerializationTestEnvironment.InitializeWithDefaults(
         builder =>
         builder.ConfigureServices(services =>
                                   services.AddSerializer(serializerBuilder =>
     {
         serializerBuilder.AddNewtonsoftJsonSerializer(type => type.GetCustomAttribute <JsonTypeAttribute>() is not null);
     })));
 }
Beispiel #17
0
 public GoogleProtoBufSerializationTests() : base(SerializationTestEnvironment.InitializeWithDefaults(
                                                      new ClientConfiguration
 {
     SerializationProviders =
     {
         typeof(ProtobufSerializer)
     }
 }))
 {
 }
 public ProtobufSerializationTests()
 {
     this.environment = SerializationTestEnvironment.InitializeWithDefaults(
         new ClientConfiguration
     {
         SerializationProviders =
         {
             typeof(ProtobufSerializer).GetTypeInfo()
         }
     });
 }
        public MessageSerializerTests(ITestOutputHelper output)
        {
            this.output = output;
            MessagingStatisticsGroup.Init(false);

            var orleansConfig = ClusterConfiguration.LocalhostPrimarySilo();

            BufferPool.InitGlobalBufferPool(orleansConfig.Globals);

            SerializationTestEnvironment.Initialize();
        }
Beispiel #20
0
        public SerializationOrderTests()
        {
            FakeTypeToSerialize.Reset();
            FakeSerializer1.Reset();
            FakeSerializer2.Reset();
            SerializationTestEnvironment.Initialize(new List <TypeInfo> {
                typeof(FakeSerializer1).GetTypeInfo(), typeof(FakeSerializer2).GetTypeInfo()
            }, null);

            SerializationManager.Register(typeof(FakeTypeToSerialize), typeof(FakeTypeToSerialize));
        }
 public BondSerializationTests()
 {
     this.environment = SerializationTestEnvironment.InitializeWithDefaults(
         new ClientConfiguration
     {
         SerializationProviders =
         {
             typeof(BondSerializer)
         }
     });
 }
        public PersistenceProviderTests_Local(ITestOutputHelper output)
        {
            this.output = output;
            var testEnvironment = new SerializationTestEnvironment();

            storageProviderManager = new StorageProviderManager(testEnvironment.GrainFactory, null);
            storageProviderManager.LoadEmptyStorageProviders(new ClientProviderRuntime(testEnvironment.GrainFactory, null)).WaitWithThrow(TestConstants.InitTimeout);
            providerCfgProps.Clear();
            testEnvironment.InitializeForTesting();
            LocalDataStoreInstance.LocalDataStore = null;
        }
        public ExternalSerializerTest()
        {
            var config = new ClientConfiguration
            {
                SerializationProviders =
                {
                    typeof(FakeSerializer).GetTypeInfo()
                }
            };

            this.environment = SerializationTestEnvironment.InitializeWithDefaults(config);
        }
        private static async Task <AzureTransactionLogStorage> StorageFactory(AzureTransactionLogOptions azureOptions, AzureTransactionArchiveLogOptions archiveOptions)
        {
            var config      = new ClientConfiguration();
            var environment = SerializationTestEnvironment.InitializeWithDefaults(config);
            var azureConfig = Options.Create(azureOptions);
            AzureTransactionLogStorage storage = new AzureTransactionLogStorage(environment.SerializationManager, azureConfig,
                                                                                Options.Create(archiveOptions), Options.Create(new ClusterOptions()
            {
                ClusterId = Guid.NewGuid().ToString(),
                ServiceId = ClusterServiceId
            }));
            await storage.Initialize();

            return(storage);
        }
        private static async Task <ITransactionLogStorage> AzureStorageFactory()
        {
            var config      = new ClientConfiguration();
            var environment = SerializationTestEnvironment.InitializeWithDefaults(config);
            var azureConfig = Options.Create(new AzureTransactionLogOptions()
            {
                // TODO: Find better way for test isolation.
                TableName        = $"TransactionLog{((uint)Guid.NewGuid().GetHashCode()) % 100000}",
                ConnectionString = TestDefaultConfiguration.DataConnectionString
            });
            AzureTransactionLogStorage storage = new AzureTransactionLogStorage(environment.SerializationManager, azureConfig);
            await storage.Initialize();

            return(storage);
        }
Beispiel #26
0
        /// <summary>
        /// Constructors -- Registers Orleans system performance counters, 
        /// plus any grain-specific activation conters that can be detected when this installer is run.
        /// </summary>
        public OrleansPerformanceCounterInstaller()
        {
            SerializationTestEnvironment.Initialize();
            Trace.Listeners.Clear();
            var cfg = new NodeConfiguration { TraceFilePattern = null, TraceToConsole = false };
            LogManager.Initialize(cfg);

            consumer = new OrleansPerfCounterTelemetryConsumer();

            if (GrainTypeManager.Instance == null)
            {
                var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>());
                var typeManager = new GrainTypeManager(false, loader, new RandomPlacementDefaultStrategy());
                GrainTypeManager.Instance.Start(false);
            }
        }
        private static async Task <ITransactionLogStorage> StorageFactory()
        {
            TestFixture.CheckForDynamoDBStorage();
            var config       = new ClientConfiguration();
            var environment  = SerializationTestEnvironment.InitializeWithDefaults(config);
            var dynamoConfig = Options.Create(new DynamoDBTransactionLogOptions()
            {
                // TODO: Find better way for test isolation.
                TableName = $"TransactionLog{((uint)Guid.NewGuid().GetHashCode()) % 100000}",
                Service   = AWSTestConstants.Service
            });
            DynamoDBTransactionLogStorage storage = new DynamoDBTransactionLogStorage(environment.SerializationManager, dynamoConfig, environment.Client.ServiceProvider.GetRequiredService <ILoggerFactory>());
            await storage.Initialize();

            return(storage);
        }
        public SerializationOrderTests()
        {
            FakeTypeToSerialize.Reset();
            FakeSerializer1.Reset();
            FakeSerializer2.Reset();
            var config = new ClientConfiguration()
            {
                SerializationProviders =
                {
                    typeof(FakeSerializer1).GetTypeInfo(),
                    typeof(FakeSerializer2).GetTypeInfo()
                }
            };

            this.environment = SerializationTestEnvironment.InitializeWithDefaults(config);
        }
        public DynamoDBStorageProviderTests()
        {
            if (!AWSTestConstants.IsDynamoDbAvailable)
                throw new SkipException("Unable to connect to DynamoDB simulator");

            var testEnvironment = new SerializationTestEnvironment();
            DefaultProviderRuntime = new StorageProviderManager(testEnvironment.GrainFactory, null);
            ((StorageProviderManager)DefaultProviderRuntime).LoadEmptyStorageProviders(new ClientProviderRuntime(testEnvironment.GrainFactory, null)).WaitWithThrow(TestConstants.InitTimeout);
            testEnvironment.InitializeForTesting();

            var properties = new Dictionary<string, string>();
            properties["DataConnectionString"] = $"Service={AWSTestConstants.Service}";
            var config = new ProviderConfiguration(properties, null);
            var provider = new DynamoDBStorageProvider();
            provider.Init("DynamoDBStorageProviderTests", DefaultProviderRuntime, config).Wait();
            PersistenceStorageTests = new CommonStorageTests(provider);
        }
Beispiel #30
0
        public int Run()
        {
            if (NeedRunAsAdministrator && !IsRunningAsAdministrator)
            {
                ConsoleText.WriteError("Need to be running in Administrator role to perform the requested operations.");
                return(1);
            }

            SerializationTestEnvironment.Initialize();

            InitConsoleLogging();

            try
            {
                if (Unregister)
                {
                    ConsoleText.WriteStatus("Unregistering Orleans performance counters with Windows");
                    UnregisterWindowsPerfCounters(this.BruteForce);
                }
                else
                {
                    ConsoleText.WriteStatus("Registering Orleans performance counters with Windows");
                    RegisterWindowsPerfCounters(true); // Always reinitialize counter registrations, even if already existed
                }

                ConsoleText.WriteStatus("Operation completed successfully.");
                return(0);
            }
            catch (Exception exc)
            {
                ConsoleText.WriteError("Error running " + typeof(CounterControl).GetTypeInfo().Assembly.GetName().Name + ".exe", exc);

                if (!BruteForce)
                {
                    return(2);
                }

                ConsoleText.WriteStatus("Ignoring error due to brute-force mode");
                return(0);
            }
        }
Beispiel #31
0
        private static async Task <ITransactionLogStorage> StorageFactory()
        {
            TestFixture.CheckForAzureStorage(TestDefaultConfiguration.DataConnectionString);
            var config      = new ClientConfiguration();
            var environment = SerializationTestEnvironment.InitializeWithDefaults(config);
            var azureConfig = Options.Create(new AzureTransactionLogOptions()
            {
                // TODO: Find better way for test isolation.
                TableName        = "TransactionLog",
                ConnectionString = TestDefaultConfiguration.DataConnectionString
            });
            AzureTransactionLogStorage storage = new AzureTransactionLogStorage(environment.SerializationManager, azureConfig,
                                                                                Options.Create(new AzureTransactionArchiveLogOptions()), Options.Create(new ClusterOptions()
            {
                ClusterId = Guid.NewGuid().ToString(),
                ServiceId = Guid.NewGuid().ToString()
            }));
            await storage.Initialize();

            return(storage);
        }
Beispiel #32
0
 public CustomSerializerTests()
 {
     LogManager.Initialize(new NodeConfiguration());
     SerializationTestEnvironment.Initialize();
 }