Exemplo n.º 1
0
    def setUp(self):
        super(GridTestCase, self).setUp()
        self.ctx = context.get_admin_context()

        self.test_grid_config = grid.GridConfiguration(self.ctx)
        self.test_grid_config.gm_connector = mock.Mock()
        self.test_grid_config.grid_id = 100
        self.test_grid_config.grid_name = "Test Grid 1"
        self.test_grid_config.grid_master_host = '192.168.1.7'
        self.test_grid_config.grid_master_name = 'nios-7.2.0-master.com'
        self.test_grid_config.admin_username = '******'
        self.test_grid_config.admin_password = '******'
        self.test_grid_config.wapi_version = '2.2'
Exemplo n.º 2
0
    def test_sync_grid(self):
        member_mgr = member.GridMemberManager(self.test_grid_config)
        member_mgr.sync_grid()

        grids = dbi.get_grids(self.ctx.session)
        self.assertEqual(1, len(grids))
        self.assertEqual(self.test_grid_config.grid_id, grids[0]['grid_id'])
        self.assertEqual(self.test_grid_config.grid_name,
                         grids[0]['grid_name'])
        expected_grid_connection = {
            "wapi_version": self.test_grid_config.wapi_version,
            "ssl_verify": self.test_grid_config.ssl_verify,
            "http_pool_connections":
            self.test_grid_config.http_pool_connections,
            "http_pool_maxsize": self.test_grid_config.http_pool_maxsize,
            "http_request_timeout": self.test_grid_config.http_request_timeout,
            "admin_user": {
                "name": self.test_grid_config.admin_user_name,
                "password": self.test_grid_config.admin_password
            }
        }
        actual_grid_connection = jsonutils.loads(grids[0]['grid_connection'])
        self.assertEqual(expected_grid_connection, actual_grid_connection)
        self.assertEqual('ON', grids[0]['grid_status'])

        # change active grid to "Test Grid 2"
        new_active_grid_config = grid.GridConfiguration(self.ctx)
        new_active_grid_config.gm_connector = mock.Mock()
        new_active_grid_config.grid_id = 200
        new_active_grid_config.grid_name = "Test Grid 2"
        new_active_grid_config.grid_master_host = '192.168.1.8'
        new_active_grid_config.admin_user_name = 'admin'
        new_active_grid_config.admin_password = '******'
        new_active_grid_config.wapi_version = '1.4.2'
        member_mgr = member.GridMemberManager(new_active_grid_config)
        member_mgr.sync_grid()

        grids = dbi.get_grids(self.ctx.session)
        self.assertEqual(2, len(grids))
        self.assertEqual(self.test_grid_config.grid_id, grids[0]['grid_id'])
        self.assertEqual('OFF', grids[0]['grid_status'])

        self.assertEqual(new_active_grid_config.grid_id, grids[1]['grid_id'])
        self.assertEqual(new_active_grid_config.grid_name,
                         grids[1]['grid_name'])
        expected_grid_connection = {
            "wapi_version": new_active_grid_config.wapi_version,
            "ssl_verify": new_active_grid_config.ssl_verify,
            "http_pool_connections":
            new_active_grid_config.http_pool_connections,
            "http_pool_maxsize": new_active_grid_config.http_pool_maxsize,
            "http_request_timeout":
            new_active_grid_config.http_request_timeout,
            "admin_user": {
                "name": new_active_grid_config.admin_user_name,
                "password": new_active_grid_config.admin_password
            }
        }
        actual_grid_connection = jsonutils.loads(grids[1]['grid_connection'])
        self.assertEqual(expected_grid_connection, actual_grid_connection)
        self.assertEqual('ON', grids[1]['grid_status'])