コード例 #1
0
 public void TearDown()
 {
     environment.Apply();
     if (environment.IsActive())
     {
         var brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(NODE_NAME);
         brokerAdmin.StopNode();
     }
 }
コード例 #2
0
        public void Init()
        {
            environment.Apply();
            this.brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(NODE_NAME);
            var status = this.brokerAdmin.GetStatus();

            if (!status.IsRunning)
            {
                this.brokerAdmin.StartBrokerApplication();
            }
        }
コード例 #3
0
 public void SetUp()
 {
     try
     {
         if (environment.IsActive())
         {
             // Set up broker admin for non-root user
             this.brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(); // "rabbit@LOCALHOST", 5672);
             this.brokerAdmin.StartNode();
         }
     }
     catch (Exception ex)
     {
         Logger.Error("An error occurred during SetUp", ex);
         Assert.Fail("An error occurred during SetUp.");
     }
 }
コード例 #4
0
        public void RepeatLifecycle()
        {
            for (var i = 1; i <= 20; i++)
            {
                this.TestStopAndStartBroker();
                Thread.Sleep(200);

                // if (i % 5 == 0)
                // {
                Logger.Debug("i = " + i);

                // }
            }

            var brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(NODE_NAME);

            brokerAdmin.StopNode();
        }
コード例 #5
0
        public void TestStartNode()
        {
            // Set up broker admin for non-root user
            var brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(NODE_NAME);
            var status      = brokerAdmin.GetStatus();

            try
            {
                // Stop it if it is already running
                if (status.IsReady)
                {
                    brokerAdmin.StopBrokerApplication();
                    Thread.Sleep(1000);
                }
            }
            catch (OtpException e)
            {
                // Not useful for test.
            }

            status = brokerAdmin.GetStatus();
            if (!status.IsRunning)
            {
                brokerAdmin.StartBrokerApplication();
            }

            status = brokerAdmin.GetStatus();

            try
            {
                Assert.False(status.Nodes == null || status.Nodes.Count < 1, "Broker node did not start. Check logs for hints.");
                Assert.True(status.IsRunning, "Broker node not running.  Check logs for hints.");
                Assert.True(status.IsReady, "Broker application not running.  Check logs for hints.");

                Thread.Sleep(1000);
                brokerAdmin.StopBrokerApplication();
                Thread.Sleep(1000);
            }
            finally
            {
                brokerAdmin.StopNode();
            }
        }
コード例 #6
0
        public void TestStopAndStartBroker()
        {
            // Set up broker admin for non-root user
            var brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(NODE_NAME);
            var status      = brokerAdmin.GetStatus();

            status = brokerAdmin.GetStatus();
            if (!status.IsRunning)
            {
                brokerAdmin.StartBrokerApplication();
            }

            brokerAdmin.StopBrokerApplication();

            status = brokerAdmin.GetStatus();
            Assert.AreEqual(0, status.RunningNodes.Count);

            brokerAdmin.StartBrokerApplication();
            status = brokerAdmin.GetStatus();
            this.AssertBrokerAppRunning(status);
        }
コード例 #7
0
        public void IntegrationTestsUserCrudWithModuleAdapter()
        {
            try
            {
                var adapter = new Dictionary <string, string>();

                // Switch two functions with identical inputs!
                adapter.Add("rabbit_auth_backend_internal%add_user", "rabbit_auth_backend_internal%change_password");
                adapter.Add("rabbit_auth_backend_internal%change_password", "rabbit_auth_backend_internal%add_user");
                this.brokerAdmin.ModuleAdapter = adapter;

                var users = this.brokerAdmin.ListUsers();
                if (users.Contains("joe"))
                {
                    this.brokerAdmin.DeleteUser("joe");
                }

                Thread.Sleep(1000);
                this.brokerAdmin.ChangeUserPassword("joe", "sales");
                Thread.Sleep(1000);
                this.brokerAdmin.AddUser("joe", "trader");
                Thread.Sleep(1000);
                users = this.brokerAdmin.ListUsers();
                if (users.Contains("joe"))
                {
                    Thread.Sleep(1000);
                    this.brokerAdmin.DeleteUser("joe");
                }
            }
            catch (Exception ex)
            {
                Logger.Error("An error occurred", ex);
                throw;
            }
            finally
            {
                // Need to ensure that we reset the module adapter that we swizzled with above, otherwise our other tests will be unreliable.
                this.brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin();
            }
        }
        public void FixtureSetUp()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
            try
            {
                if (Environment.IsActive())
                {
                    // Set up broker admin for non-root user
                    this.brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(); // "rabbit@LOCALHOST", 5672);
                    this.brokerAdmin.StartNode();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("An error occurred during SetUp", ex);
                Assert.Fail("An error occurred during SetUp.");
            }

            if (!this.brokerFederated.Apply())
            {
                Assert.Ignore("Rabbit broker is not running. Ignoring integration test fixture.");
            }
        }
コード例 #9
0
        public void End()
        {
            var brokerAdmin = BrokerTestUtils.GetRabbitBrokerAdmin(NODE_NAME);

            brokerAdmin.StopNode();
        }