Пример #1
0
        public async Task InitializeAsync()
        {
            if (Configuration.TestAgainstContainers)
            {
                dockerEngineOsPlatform = await dockerProxy.GetDockerEngineOsAsync();

                dockerNetworkName = dockerEngineOsPlatform == OSPlatform.Windows ? null : "bridgeWhaleNet";
                await DisposeAsync().ConfigureAwait(false);
                await CreateNetworkAsync().ConfigureAwait(false);

                var rabbitMQDockerImage = await PullImageAsync().ConfigureAwait(false);

                var containerId = await RunContainerAsync(rabbitMQDockerImage).ConfigureAwait(false);

                if (dockerEngineOsPlatform == OSPlatform.Windows)
                {
                    RabbitHostForManagement = await dockerProxy.GetContainerIpAsync(containerId).ConfigureAwait(false);
                }
            }
            await WaitForRabbitMqReadyAsync();
        }
        public async Task InitializeAsync()
        {
            using var timeoutCts   = new CancellationTokenSource(InitializationTimeout);
            dockerEngineOsPlatform = await dockerProxy.GetDockerEngineOsAsync(timeoutCts.Token).ConfigureAwait(false);

            dockerNetworkName = dockerEngineOsPlatform == OSPlatform.Windows ? null : "bridgeWhaleNet";
            await DisposeAsync(timeoutCts.Token).ConfigureAwait(false);
            await CreateNetworkAsync(timeoutCts.Token).ConfigureAwait(false);

            var rabbitMQDockerImage = await PullImageAsync(timeoutCts.Token).ConfigureAwait(false);

            var containerId = await RunContainerAsync(rabbitMQDockerImage, timeoutCts.Token).ConfigureAwait(false);

            if (dockerEngineOsPlatform == OSPlatform.Windows)
            {
                RabbitHostForManagement = await dockerProxy.GetContainerIpAsync(containerId, timeoutCts.Token)
                                          .ConfigureAwait(false);
            }

            await WaitForRabbitMqReadyAsync(timeoutCts.Token);
        }
        public async Task InitializeAsync()
        {
            dockerEngineOsPlatform = await dockerProxy.GetDockerEngineOsAsync();

            dockerNetworkName = dockerEngineOsPlatform == OSPlatform.Windows ? null : "bridgeWhaleNet";
            var rabbitMQDockerImage = Configuration.RabbitMQDockerImage(dockerEngineOsPlatform);

            await DisposeAsync().ConfigureAwait(false);

            if (dockerEngineOsPlatform == OSPlatform.Linux || dockerEngineOsPlatform == OSPlatform.OSX)
            {
                await dockerProxy.CreateNetworkAsync(dockerNetworkName).ConfigureAwait(false);
            }

            await dockerProxy.PullImageAsync(rabbitMQDockerImage, RabbitImageTag).ConfigureAwait(false);

            var portMappings = new Dictionary <string, ISet <string> >
            {
                { "4369", new HashSet <string>()
                  {
                      "4369"
                  } },
                { "5671", new HashSet <string>()
                  {
                      "5671"
                  } },
                { "5672", new HashSet <string>()
                  {
                      "5672"
                  } },
                { "15671", new HashSet <string>()
                  {
                      "15671"
                  } },
                { "15672", new HashSet <string>()
                  {
                      "15672"
                  } },
                { "25672", new HashSet <string>()
                  {
                      "25672"
                  } }
            };
            var envVars = new List <string> {
                $"RABBITMQ_DEFAULT_VHOST={Configuration.RabbitMqVirtualHostName}"
            };
            var containerId = await dockerProxy
                              .CreateContainerAsync(rabbitMQDockerImage, RabbitContainerAndHostName, portMappings, dockerNetworkName, envVars)
                              .ConfigureAwait(false);

            await dockerProxy.StartContainerAsync(containerId).ConfigureAwait(false);

            RabbitContainerHostForManagement = "localhost";
            if (dockerEngineOsPlatform == OSPlatform.Windows)
            {
                RabbitContainerHostForManagement = await dockerProxy.GetContainerIpAsync(containerId).ConfigureAwait(false);
            }
            var timeoutCts = new CancellationTokenSource(TimeSpan.FromSeconds(DefaultTimeoutSeconds));

            await WaitForRabbitMqReady(timeoutCts.Token).ConfigureAwait(false);
        }