Exemplo n.º 1
0
        public static void DefineBuilder(this EndpointConfiguration config, RunSettings settings)
        {
            Type builderType;
            if (!settings.TryGet("Builder", out builderType))
            {
                var builderDescriptor = Builders.Default;

                if (builderDescriptor == null)
                {
                    return; //go with the default builder
                }

                settings.Merge(builderDescriptor.Settings);
            }

            builderType = settings.Get<Type>("Builder");

            var typeName = "Configure" + builderType.Name;

            var configurerType = Type.GetType(typeName, false);

            if (configurerType != null)
            {
                var configurer = Activator.CreateInstance(configurerType);

                dynamic dc = configurer;

                dc.Configure(config);
            }

            config.UseContainer(builderType);
        }
Exemplo n.º 2
0
        static async Task ConfigureTestExecution(TestDependencyType type, EndpointConfiguration config, RunSettings settings, string endpointName, PublisherMetadata publisherMetadata)
        {
            var dependencyTypeString = type.ToString();

            var dependencyType = settings.Get<Type>(dependencyTypeString);

            var typeName = "ConfigureEndpoint" + dependencyType.Name;

            var configurerType = Type.GetType(typeName, false);

            if (configurerType == null)
            {
                throw new InvalidOperationException($"Acceptance Test project must include a non-namespaced class named '{typeName}' implementing {typeof(IConfigureEndpointTestExecution).Name}. See {typeof(ConfigureEndpointMsmqTransport).FullName} for an example.");
            }

            var configurer = Activator.CreateInstance(configurerType) as IConfigureEndpointTestExecution;

            if (configurer == null)
            {
                throw new InvalidOperationException($"{typeName} does not implement {typeof(IConfigureEndpointTestExecution).Name}.");
            }

            await configurer.Configure(endpointName, config, settings, publisherMetadata).ConfigureAwait(false);

            ActiveTestExecutionConfigurer cleaners;
            var cleanerKey = "ConfigureTestExecution." + endpointName;
            if (!settings.TryGet(cleanerKey, out cleaners))
            {
                cleaners = new ActiveTestExecutionConfigurer();
                settings.Set(cleanerKey, cleaners);
            }
            cleaners.Add(configurer);
        }
Exemplo n.º 3
0
        public static Task DefineTransport(this EndpointConfiguration config, RunSettings settings, EndpointCustomizationConfiguration endpointCustomizationConfiguration)
        {
            Type transportType;
            if (!settings.TryGet("Transport", out transportType))
            {
                settings.Merge(Transports.Default.Settings);
            }

            return ConfigureTestExecution(TestDependencyType.Transport, config, settings, endpointCustomizationConfiguration.EndpointName, endpointCustomizationConfiguration.PublisherMetadata);
        }
Exemplo n.º 4
0
        public static Task DefinePersistence(this EndpointConfiguration config, RunSettings settings, EndpointCustomizationConfiguration endpointCustomizationConfiguration)
        {
            Type persistenceType;
            if (!settings.TryGet("Persistence", out persistenceType))
            {
                settings.Merge(Persistence.Default.Settings);
            }

            return ConfigureTestExecution(TestDependencyType.Persistence, config, settings, endpointCustomizationConfiguration.EndpointName, endpointCustomizationConfiguration.PublisherMetadata);
        }
        public static Task DefineTransport(this EndpointConfiguration config, RunSettings settings, string endpointName)
        {
            Type transportType;
            if (!settings.TryGet("Transport", out transportType))
            {
                settings.Merge(Transports.Default.Settings);
            }

            return ConfigureTestExecution(TestDependencyType.Transport, config, settings, endpointName);
        }
        public static Task DefinePersistence(this EndpointConfiguration config, RunSettings settings, string endpointName)
        {
            Type persistenceType;
            if (!settings.TryGet("Persistence", out persistenceType))
            {
                settings.Merge(Persistence.Default.Settings);
            }

            return ConfigureTestExecution(TestDependencyType.Persistence, config, settings, endpointName);
        }
    public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings runSettings, PublisherMetadata publisherMetadata)
    {
        queueBindings = configuration.GetSettings().Get <QueueBindings>();
        settings      = configuration.GetSettings();
        settings.Set("SqlServer.SubscriptionTableQuotedQualifiedNameSetter", (Action <string>)SetSubscriptionTableName);

        doNotCleanNativeSubscriptions = runSettings.TryGet <bool>("DoNotCleanNativeSubscriptions", out _);
        connectionString = Environment.GetEnvironmentVariable("SqlServerTransportConnectionString");

        if (string.IsNullOrEmpty(connectionString))
        {
            throw new Exception("The 'SqlServerTransportConnectionString' environment variable is not set.");
        }

        var transportConfig = configuration.UseTransport <SqlServerTransport>();

        transportConfig.ConnectionString(connectionString);
        transportConfig.SubscriptionSettings().DisableSubscriptionCache();

#if !NETFRAMEWORK
        transportConfig.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
#endif
        return(Task.FromResult(0));
    }
Exemplo n.º 8
0
    public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
    {
        if (configuration.GetSettings().Get <bool>("Endpoint.SendOnly"))
        {
            return(Task.FromResult(0));
        }

        var persistence = configuration.UsePersistence <CosmosPersistence>();

        persistence.DisableContainerCreation();
        persistence.CosmosClient(SetupFixture.CosmosDbClient);
        persistence.DatabaseName(SetupFixture.DatabaseName);

        if (!settings.TryGet <DoNotRegisterDefaultPartitionKeyProvider>(out _))
        {
            configuration.RegisterComponents(services => services.AddSingleton <IPartitionKeyFromMessageExtractor, PartitionKeyProvider>());
        }
        if (!settings.TryGet <DoNotRegisterDefaultContainerInformationProvider>(out _))
        {
            configuration.RegisterComponents(services => services.AddSingleton <IContainerInformationFromMessagesExtractor, ContainerInformationProvider>());
        }

        return(Task.FromResult(0));
    }
Exemplo n.º 9
0
        /// <summary>
        /// The main entry point for the application.  This instantiates and runs our game (within XAGE.Engine.Core.dll)
        /// </summary>
        static void Main(string[] args)
        {
            // Must do this before anything else
            DllMap.Initialise();

            // Create Script Delegates that get injected into the engine
            RunSettings runSettings = new RunSettings(
                Release,
                AllowDebugging,
                LogLevel,
                LogAsync,
                OnNotImplemented,
                LastnFurious.CSharpScript.Load,
                LastnFurious.CSharpScript.Serialize,
                LastnFurious.CSharpScript.Deserialize,
                typeof(LastnFurious.CSharpScript));

            // Run the game - any unhandled exceptions will be caught in Release mode only
            // In Debug mode it will stop in place, which is generally more useful for debugging
            try
            {
                using (XNAGame game = new XNAGame(runSettings))
                {
                    game.Run();
                }
            }
            catch (Exception exc) when(CatchFatalExceptions)
            {
                Logger.Fatal("Unhandled exception: " + exc.Message);
                Logger.Fatal("StackTrace: " + exc.StackTrace);
            }
            finally
            {
                Logger.Reset();
            }
        }
Exemplo n.º 10
0
    public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
    {
        queueBindings = configuration.GetSettings().Get <QueueBindings>();

        var transportConfig = configuration.UseTransport <SqlServerTransport>();

        transportConfig.ConnectionString(ConnectionString);

#if !NET452
        transportConfig.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
#endif

        var routingConfig = transportConfig.Routing();

        foreach (var publisher in publisherMetadata.Publishers)
        {
            foreach (var eventType in publisher.Events)
            {
                routingConfig.RegisterPublisher(eventType, publisher.PublisherName);
            }
        }

        return(Task.FromResult(0));
    }
Exemplo n.º 11
0
        public void InitializeShouldEnableMultipleCollectorsWhenCalledMoreThanOnce()
        {
            var runsettingsString = string.Format(DefaultRunSettings, string.Empty);
            var runsettings       = new RunSettings();

            runsettings.LoadSettingsXml(runsettingsString);
            this.settingsProvider.SetActiveRunSettings(runsettings);
            this.executor.Initialize("MyDataCollector");
            this.executor.Initialize("MyDataCollector1");

            Assert.AreEqual(string.Join(Environment.NewLine,
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
                                        "<RunSettings>",
                                        "  <RunConfiguration>",
                                        "    <TestAdaptersPaths>c:\\AdapterFolderPath</TestAdaptersPaths>",
                                        "  </RunConfiguration>",
                                        "  <DataCollectionRunSettings>",
                                        "    <DataCollectors>",
                                        "      <DataCollector friendlyName=\"MyDataCollector\" enabled=\"True\" />",
                                        "      <DataCollector friendlyName=\"MyDataCollector1\" enabled=\"True\" />",
                                        "    </DataCollectors>",
                                        "  </DataCollectionRunSettings>",
                                        "</RunSettings>"), this.settingsProvider.ActiveRunSettings.SettingsXml);
        }
Exemplo n.º 12
0
        public void InitializeShouldCreateEntryForDataCollectorInRunSettingsIfNotAlreadyPresent()
        {
            var runsettingsString = string.Format(DefaultRunSettings, "");
            var runsettings       = new RunSettings();

            runsettings.LoadSettingsXml(runsettingsString);
            this.settingsProvider.SetActiveRunSettings(runsettings);

            this.executor.Initialize("MyDataCollector");

            Assert.IsNotNull(this.settingsProvider.ActiveRunSettings);
            Assert.AreEqual(string.Join(Environment.NewLine,
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
                                        "<RunSettings>",
                                        "  <RunConfiguration>",
                                        "    <TestAdaptersPaths>c:\\AdapterFolderPath</TestAdaptersPaths>",
                                        "  </RunConfiguration>",
                                        "  <DataCollectionRunSettings>",
                                        "    <DataCollectors>",
                                        "      <DataCollector friendlyName=\"MyDataCollector\" enabled=\"True\" />",
                                        "    </DataCollectors>",
                                        "  </DataCollectionRunSettings>",
                                        "</RunSettings>"), this.settingsProvider.ActiveRunSettings.SettingsXml);
        }
Exemplo n.º 13
0
 /// <summary>
 ///  Main app run point
 ///  Due to depency with static Console this proved to be untestable
 ///  To be fixed
 /// </summary>
 public void Run(RunSettings runSettings)
 {
     Console.WriteLine($"Starting in {runSettings.Mode} mode...");
     echoApp = echoAppFactory.GetEchoApp(runSettings.Mode);
     Console.WriteLine("Attempting to connect...");
     echoApp.MessageHandler = Console.WriteLine;
     echoApp.Start(runSettings);
     while (true)
     {
         Console.WriteLine("Enter a message to send and press enter or enter exit to stop the the program");
         var input = Console.ReadLine();
         if (input == "exit")
         {
             echoApp.Stop();
             Console.WriteLine("Press any key to exit");
             break;
         }
         var messageSentSuccessfully = echoApp.SendMessage(input);
         if (!messageSentSuccessfully)
         {
             Console.WriteLine($"Could not send message {input}");
         }
     }
 }
Exemplo n.º 14
0
        public void DiscoverTests(IEnumerable <string> executables, IDiscoveryContext discoveryContext,
                                  IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            ILogger loggerAdapter = new VsTestFrameworkLogger(logger);

            if (TestEnvironment == null || TestEnvironment.Options.GetType() == typeof(Options)) // check whether we have a mock
            {
                var         settingsProvider = discoveryContext.RunSettings.GetSettings(GoogleTestConstants.SettingsName) as RunSettingsProvider;
                RunSettings ourRunSettings   = settingsProvider != null ? settingsProvider.Settings : new RunSettings();

                TestEnvironment = new TestEnvironment(new Options(ourRunSettings, loggerAdapter), loggerAdapter);
                Discoverer      = new GoogleTestDiscoverer(TestEnvironment);
            }

            try
            {
                VsTestFrameworkReporter reporter = new VsTestFrameworkReporter(discoverySink);
                Discoverer.DiscoverTests(executables, reporter);
            }
            catch (Exception e)
            {
                TestEnvironment.LogError("Exception while discovering tests: " + e);
            }
        }
Exemplo n.º 15
0
    public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
    {
        var settingsHolder = configuration.GetSettings();

        queueBindings = settingsHolder.Get <QueueBindings>();

        var transportConfig = configuration.UseTransport <MsmqTransport>();

        transportConfig.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
        transportConfig.DisableConnectionCachingForSends();
        settingsHolder.Set("NServiceBus.Transport.Msmq.MessageEnumeratorTimeout", TimeSpan.FromMilliseconds(10));

        var routingConfig = transportConfig.Routing();

        foreach (var publisher in publisherMetadata.Publishers)
        {
            foreach (var eventType in publisher.Events)
            {
                routingConfig.RegisterPublisher(eventType, publisher.PublisherName);
            }
        }

        return(Task.FromResult(0));
    }
Exemplo n.º 16
0
 public RunDescriptor(string key)
 {
     Key = key;
     Settings = new RunSettings();
 }
Exemplo n.º 17
0
 public RunDescriptor(RunDescriptor template)
 {
     Settings = new RunSettings();
     Settings.Merge(template.Settings);
     Key = template.Key;
 }
Exemplo n.º 18
0
        public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
        {
            queueBindings = configuration.GetSettings().Get <QueueBindings>();

            var transportConfig = configuration.UseTransport <SqlServerTransport>();

            transportConfig.ConnectionString(ConnectionString);

#if !NET452
            transportConfig.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
#endif

            return(Task.FromResult(0));
        }
Exemplo n.º 19
0
        public void InitializeSettingsProvidersShouldThrowOnNullSettings()
        {
            var runSettings = new RunSettings();

            Assert.ThrowsException <ArgumentNullException>(() => runSettings.InitializeSettingsProviders(null));
        }
Exemplo n.º 20
0
        public void GetSettingsShouldThrowIfSettingsNameIsEmpty()
        {
            var runSettings = new RunSettings();

            Assert.ThrowsException <ArgumentException>(() => runSettings.GetSettings("  "));
        }
Exemplo n.º 21
0
 public IEnumerable <TestResult> Run(RunSettings settings)
 {
     return(new CelerRunner(_logger, _reflectionProviderFactory, _channel).Run(settings));
 }
Exemplo n.º 22
0
		public IEnumerable<TestResult> Run(RunSettings settings)
		{
			var results = SimpleRunner.RunAllInAssembly(settings.Assembly.Assembly);

			return results.Select(
				x =>
				new TestResult(identifier, settings.Assembly.Assembly, x.SpecificationName, 0, x.FoundOnMemberInfo.Name, "",
				               x.Passed == true ? TestState.Passed : TestState.Failed, x.Message)).ToArray();

		}
Exemplo n.º 23
0
        public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
        {
            connectionStringBuilder = new DbConnectionStringBuilder {
                ConnectionString = ConnectionString
            };

            var transport = configuration.UseTransport <RabbitMQTransport>();

            transport.UseConventionalRoutingTopology();
            transport.ConnectionString(connectionStringBuilder.ConnectionString);

            queueBindings = configuration.GetSettings().Get <QueueBindings>();

            return(Task.FromResult(0));
        }
Exemplo n.º 24
0
 public IEnumerable <TestResult> Run(Plugin plugin, RunSettings settings)
 {
     return(plugin.New().Run(settings));
 }
Exemplo n.º 25
0
 public static void ClassInitialize(TestContext context)
 {
     RunSettings.Initialize(context);
     RunSettings.ValidateGameDataDir();
 }
Exemplo n.º 26
0
        public IEnumerable <TestResult> Run(RunSettings settings)
        {
            var runner = new XUnitRunner();

            return(runner.Run(settings, _channel));
        }
 public Task <GatewayDeduplicationConfiguration> ConfigureDeduplicationStorage(string endpointName, EndpointConfiguration configuration, RunSettings settings)
 {
     return(Task.FromResult <GatewayDeduplicationConfiguration>(new NonDurableDeduplicationConfiguration()));
 }
    public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
    {
        PreventInconclusiveTestsFromRunning(endpointName);

        configuration.UseSerialization <NewtonsoftSerializer>();

        var connectionString = TestUtility.DefaultConnectionString;
        var topology         = EnvironmentHelper.GetEnvironmentVariable("AzureServiceBusTransport.Topology");

        configuration.GetSettings().Set("AzureServiceBus.AcceptanceTests.UsedTopology", topology);

        var transportConfig = configuration.UseTransport <AzureServiceBusTransport>();

        transportConfig.ConnectionString(connectionString);

        if (topology == "ForwardingTopology")
        {
            transportConfig.UseForwardingTopology();
        }
        else
        {
            var endpointOrientedTopology = transportConfig.UseEndpointOrientedTopology();
            if (topology == "EndpointOrientedMigrationTopology")
            {
                endpointOrientedTopology.EnableMigrationToForwardingTopology();
            }

            foreach (var publisher in publisherMetadata.Publishers)
            {
                foreach (var eventType in publisher.Events)
                {
                    endpointOrientedTopology.RegisterPublisher(eventType, publisher.PublisherName);
                }
            }

            // ATTs that that require publishers to be explicitly registered for the EndpointOrientedTopology
            endpointOrientedTopology.RegisterPublisher(typeof(When_multi_subscribing_to_a_polymorphic_event.MyEvent1), TestConventions.EndpointNamingConvention(typeof(When_multi_subscribing_to_a_polymorphic_event.Publisher1)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_multi_subscribing_to_a_polymorphic_event.MyEvent2), TestConventions.EndpointNamingConvention(typeof(When_multi_subscribing_to_a_polymorphic_event.Publisher2)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_publishing_to_scaled_out_subscribers.MyEvent), TestConventions.EndpointNamingConvention(typeof(When_publishing_to_scaled_out_subscribers.Publisher)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_unsubscribing_from_event.Event), TestConventions.EndpointNamingConvention(typeof(When_unsubscribing_from_event.Publisher)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_unsubscribing.MyEvent), TestConventions.EndpointNamingConvention(typeof(When_unsubscribing.Endpoint)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_multiple_versions_of_a_message_is_published.V1Event), TestConventions.EndpointNamingConvention(typeof(When_multiple_versions_of_a_message_is_published.V2Publisher)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_multiple_versions_of_a_message_is_published.V2Event), TestConventions.EndpointNamingConvention(typeof(When_multiple_versions_of_a_message_is_published.V2Publisher)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_replying_to_saga_event.DidSomething), TestConventions.EndpointNamingConvention(typeof(When_replying_to_saga_event.SagaEndpoint)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_started_by_base_event_from_other_saga.BaseEvent), TestConventions.EndpointNamingConvention(typeof(When_started_by_base_event_from_other_saga.Publisher)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_started_by_event_from_another_saga.SomethingHappenedEvent), TestConventions.EndpointNamingConvention(typeof(When_started_by_event_from_another_saga.SagaThatPublishesAnEvent)));

            //When_two_sagas_subscribe_to_the_same_event
            endpointOrientedTopology.RegisterPublisher(typeof(When_two_sagas_subscribe_to_the_same_event.GroupPendingEvent), TestConventions.EndpointNamingConvention(typeof(When_two_sagas_subscribe_to_the_same_event.Publisher)));

            // TODO: investigate why these tests that are intended for the ForwradingTopology only fail w/o publisher registration on EndpointOrientedTopology execution on build server
            endpointOrientedTopology.RegisterPublisher(typeof(When_subscribing_to_base_and_derived_polymorphic_events_with_forwarding_topology.BaseEvent), TestConventions.EndpointNamingConvention(typeof(When_subscribing_to_base_and_derived_polymorphic_events_with_forwarding_topology.Publisher)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_subscribing_to_base_and_derived_polymorphic_events_with_forwarding_topology.DerivedEvent), TestConventions.EndpointNamingConvention(typeof(When_subscribing_to_base_and_derived_polymorphic_events_with_forwarding_topology.Publisher)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_unsubscribing_from_one_of_the_events_for_ForwardingTopology.MyEvent), TestConventions.EndpointNamingConvention(typeof(When_unsubscribing_from_one_of_the_events_for_ForwardingTopology.Endpoint)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_unsubscribing_from_one_of_the_events_for_ForwardingTopology.MyOtherEvent), TestConventions.EndpointNamingConvention(typeof(When_unsubscribing_from_one_of_the_events_for_ForwardingTopology.Endpoint)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_publishing_from_sendonly.MyEvent), TestConventions.EndpointNamingConvention(typeof(When_publishing_from_sendonly.SendOnlyPublisher)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_subscribing_to_a_base_event.IBaseEvent), TestConventions.EndpointNamingConvention(typeof(When_subscribing_to_a_base_event.Publisher)));
            endpointOrientedTopology.RegisterPublisher(typeof(When_subscribing_to_a_derived_event.SpecificEvent), TestConventions.EndpointNamingConvention(typeof(When_subscribing_to_a_derived_event.Publisher)));

            endpointOrientedTopology.RegisterPublisher(typeof(When_publishing_with_overridden_local_address.MyEvent), TestConventions.EndpointNamingConvention(typeof(When_publishing_with_overridden_local_address.Publisher)));
            // Both publisher and subscriber are the same endpoint with overridden endpoint name. We can't detect both from the message type.
            endpointOrientedTopology.RegisterPublisher(typeof(When_publishing_and_subscribing_to_self_with_overridden_address.MyEvent), "myinputqueue");
        }

        transportConfig.Sanitization()
        .UseStrategy <ValidateAndHashIfNeeded>();

        configuration.RegisterComponents(c => { c.ConfigureComponent <TestIndependenceMutator>(DependencyLifecycle.SingleInstance); });

        configuration.Pipeline.Register("TestIndependenceBehavior", typeof(TestIndependenceSkipBehavior),
                                        "Skips messages not created during the current test.");

        // w/o retries ASB will move attempted messages to the error queue right away, which will cause false failure.
        // ScenarioRunner.PerformScenarios() verifies by default no messages are moved into error queue. If it finds any, it fails the test.
        configuration.Recoverability().Immediate(retriesSettings => retriesSettings.NumberOfRetries(3));

        return(Task.FromResult(0));
    }
Exemplo n.º 29
0
 public NUnitOptionsParser(RunSettings settings)
 {
     _runnerSettings = settings;
 }
Exemplo n.º 30
0
 public static void ClassInitialize(TestContext context)
 {
     RunSettings.Initialize(context);
 }
Exemplo n.º 31
0
		public IEnumerable<TestResult> Run(RunSettings settings)
		{
			return new StfuRunner(_logger, _reflectionProviderFactory, _channel).Run(settings);
			
		}
 public void TestInit()
 {
     currentActiveSetting = RunSettingsManager.Instance.ActiveRunSettings;
 }
Exemplo n.º 33
0
 public TestDiscoveryContext(ITestDiscoveryMonitor monitor, RunSettings runSettings = null)
 {
     _monitor    = monitor;
     RunSettings = runSettings ?? new RunSettings();
 }
        public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings)
        {
            var documentStore = ConfigureEndpointRavenDBPersistence.GetDocumentStore();

            databaseName = documentStore.Database;


            configuration.UsePersistence <RavenDBPersistence, StorageType.GatewayDeduplication>()
            .DoNotSetupDatabasePermissions()
            .SetDefaultDocumentStore(documentStore);

            return(Task.FromResult(0));
        }
Exemplo n.º 35
0
        public async Task Should_not_lose_any_events()
        {
            var subscriptionStorage = new TestingInMemorySubscriptionStorage();

            //Before migration begins
            var beforeMigration = await Scenario.Define <Context>()
                                  .WithEndpoint <Publisher>(b =>
            {
                b.CustomConfig(c =>
                {
                    c.UsePersistence <TestingInMemoryPersistence, StorageType.Subscriptions>().UseStorage(subscriptionStorage);
                    c.GetSettings().Set("SqlServer.DisableNativePubSub", true);
                });
                b.When(c => c.SubscribedMessageDriven, (session, ctx) => session.Publish(new MyEvent()));
            })

                                  .WithEndpoint <Subscriber>(b =>
            {
                b.CustomConfig(c =>
                {
                    c.GetSettings().Set("SqlServer.DisableNativePubSub", true);
                    c.GetSettings().GetOrCreate <Publishers>().AddOrReplacePublishers("LegacyConfig", new List <PublisherTableEntry>
                    {
                        new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(PublisherEndpoint))
                    });
                });
                b.When(async(session, ctx) =>
                {
                    await session.Subscribe <MyEvent>();
                });
            })
                                  .Done(c => c.GotTheEvent)
                                  .Run(TimeSpan.FromSeconds(30));

            Assert.True(beforeMigration.GotTheEvent);

            //Publisher migrated and in compatibility mode
            var publisherMigrated = await Scenario.Define <Context>()
                                    .WithEndpoint <Publisher>(b =>
            {
                b.CustomConfig(c =>
                {
                    c.UsePersistence <TestingInMemoryPersistence, StorageType.Subscriptions>().UseStorage(subscriptionStorage);
                    c.GetSettings().Set("NServiceBus.Subscriptions.EnableMigrationMode", true);
                });
                b.When(c => c.EndpointsStarted, (session, ctx) => session.Publish(new MyEvent()));
            })

                                    .WithEndpoint <Subscriber>(b =>
            {
                b.CustomConfig(c =>
                {
                    c.GetSettings().Set("SqlServer.DisableNativePubSub", true);
                    c.GetSettings().GetOrCreate <Publishers>().AddOrReplacePublishers("LegacyConfig", new List <PublisherTableEntry>
                    {
                        new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(PublisherEndpoint))
                    });
                });
                b.When(async(session, ctx) =>
                {
                    await session.Subscribe <MyEvent>();
                });
            })
                                    .Done(c => c.GotTheEvent)
                                    .Run(TimeSpan.FromSeconds(30));

            Assert.True(publisherMigrated.GotTheEvent);

            //Subscriber migrated and in compatibility mode
            var subscriberMigratedRunSettings = new RunSettings
            {
                TestExecutionTimeout = TimeSpan.FromSeconds(30)
            };

            subscriberMigratedRunSettings.Set("DoNotCleanNativeSubscriptions", true);
            var subscriberMigrated = await Scenario.Define <Context>()
                                     .WithEndpoint <Publisher>(b =>
            {
                b.CustomConfig(c =>
                {
                    c.UsePersistence <TestingInMemoryPersistence, StorageType.Subscriptions>().UseStorage(subscriptionStorage);
                    c.GetSettings().Set("NServiceBus.Subscriptions.EnableMigrationMode", true);
                });
                b.When(c => c.SubscribedMessageDriven && c.SubscribedNative, (session, ctx) => session.Publish(new MyEvent()));
            })

                                     .WithEndpoint <Subscriber>(b =>
            {
                b.CustomConfig(c =>
                {
                    c.GetSettings().Set("NServiceBus.Subscriptions.EnableMigrationMode", true);
                    var compatModeSettings = new SubscriptionMigrationModeSettings(c.GetSettings());
                    compatModeSettings.RegisterPublisher(typeof(MyEvent), PublisherEndpoint);
                });
                b.When(async(session, ctx) =>
                {
                    //Subscribes both using native feature and message-driven
                    await session.Subscribe <MyEvent>();
                    ctx.SubscribedNative = true;
                });
            })
                                     .Done(c => c.GotTheEvent)
                                     .Run(subscriberMigratedRunSettings);

            Assert.True(subscriberMigrated.GotTheEvent);

            //Compatibility mode disabled in both publisher and subscriber
            var compatModeDisabled = await Scenario.Define <Context>()
                                     .WithEndpoint <Publisher>(b =>
            {
                b.When(c => c.EndpointsStarted, (session, ctx) => session.Publish(new MyEvent()));
            })
                                     .WithEndpoint <Subscriber>()
                                     .Done(c => c.GotTheEvent)
                                     .Run(TimeSpan.FromSeconds(30));

            Assert.True(compatModeDisabled.GotTheEvent);
        }
        public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
        {
            PreventInconclusiveTestsFromRunning(endpointName);

            var transportConfig = configuration.UseTransport <SqsTransport>();

            transportConfig.ConfigureSqsTransport(SetupFixture.SqsQueueNamePrefix);

            var routingConfig = transportConfig.Routing();

            foreach (var publisher in publisherMetadata.Publishers)
            {
                foreach (var eventType in publisher.Events)
                {
                    routingConfig.RegisterPublisher(eventType, publisher.PublisherName);
                }
            }

            // TODO: remove when AWS SDK bug is resolved https://github.com/aws/aws-sdk-net/issues/796
            // The bug causes messages to be marked as in flight, but not delivered to the client.
            // Wait for tests longer than the invisibility time to make sure messages are received.
            settings.TestExecutionTimeout = TimeSpan.FromSeconds(40);

            return(Task.FromResult(0));
        }
Exemplo n.º 37
0
        public void LoadSettingsXmlShouldThrowOnEmptySettings()
        {
            var runSettings = new RunSettings();

            Assert.ThrowsException <ArgumentException>(() => runSettings.LoadSettingsXml("  "));
        }
 public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
 {
     configuration.UsePersistence <InMemoryPersistence>();
     return(Task.FromResult(0));
 }
        static async Task ConfigureTestExecution(TestDependencyType type, EndpointConfiguration config, RunSettings settings, string endpointName, PublisherMetadata publisherMetadata)
        {
            var dependencyTypeString = type.ToString();

            var dependencyType = settings.Get <Type>(dependencyTypeString);

            var typeName = "ConfigureEndpoint" + dependencyType.Name;

            var configurerType = Type.GetType(typeName, false);

            if (configurerType == null)
            {
                throw new InvalidOperationException($"Acceptance Test project must include a non-namespaced class named '{typeName}' implementing {typeof(IConfigureEndpointTestExecution).Name}. See {typeof(ConfigureEndpointMsmqTransport).FullName} for an example.");
            }

            var configurer = Activator.CreateInstance(configurerType) as IConfigureEndpointTestExecution;

            if (configurer == null)
            {
                throw new InvalidOperationException($"{typeName} does not implement {typeof(IConfigureEndpointTestExecution).Name}.");
            }

            await configurer.Configure(endpointName, config, settings, publisherMetadata).ConfigureAwait(false);

            ActiveTestExecutionConfigurer cleaners;
            var cleanerKey = "ConfigureTestExecution." + endpointName;

            if (!settings.TryGet(cleanerKey, out cleaners))
            {
                cleaners = new ActiveTestExecutionConfigurer();
                settings.Set(cleanerKey, cleaners);
            }
            cleaners.Add(configurer);
        }
Exemplo n.º 40
0
 public static Process Run([NotNull] string execName, [NotNull] RunSettings settings)
 {
     return(Run(execName, null, settings));
 }