Пример #1
0
class ElasticHostsTestCase(ElasticStackTestCase, unittest.TestCase):

    def setUp(self):
        ElasticHosts.connectionCls.conn_classes = (None,
                                                   ElasticStackMockHttp)

        self.driver = ElasticHosts('foo', 'bar')
        images = self.driver.list_images()
        self.image = [i for i in images if
                      i.id == '38df0986-4d85-4b76-b502-3878ffc80161'][0]
        super(ElasticHostsTestCase, self).setUp()

    def test_multiple_drivers_with_different_regions(self):
        driver1 = ElasticHosts('foo', 'bar', region='lon-p')
        driver2 = ElasticHosts('foo', 'bar', region='sat-p')

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))

        driver1.list_nodes()
        driver2.list_nodes()
        driver1.list_nodes()

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))

    def test_invalid_region(self):
        expected_msg = r'Invalid region.+'
        self.assertRaisesRegexp(ValueError, expected_msg, ElasticHosts,
                                'foo', 'bar', region='invalid')
Пример #2
0
class ElasticHostsTestCase(ElasticStackTestCase, unittest.TestCase):
    def setUp(self):
        ElasticHosts.connectionCls.conn_class = ElasticStackMockHttp

        self.driver = ElasticHosts('foo', 'bar')
        images = self.driver.list_images()
        self.image = [
            i for i in images if i.id == '38df0986-4d85-4b76-b502-3878ffc80161'
        ][0]
        super(ElasticHostsTestCase, self).setUp()

    def test_multiple_drivers_with_different_regions(self):
        driver1 = ElasticHosts('foo', 'bar', region='lon-p')
        driver2 = ElasticHosts('foo', 'bar', region='sat-p')

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))

        driver1.list_nodes()
        driver2.list_nodes()
        driver1.list_nodes()

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))

    def test_invalid_region(self):
        expected_msg = r'Invalid region.+'
        assertRaisesRegex(self,
                          ValueError,
                          expected_msg,
                          ElasticHosts,
                          'foo',
                          'bar',
                          region='invalid')
Пример #3
0
    def setUp(self):
        ElasticHosts.connectionCls.conn_class = ElasticStackMockHttp

        self.driver = ElasticHosts('foo', 'bar')
        images = self.driver.list_images()
        self.image = [i for i in images if
                      i.id == '38df0986-4d85-4b76-b502-3878ffc80161'][0]
        super(ElasticHostsTestCase, self).setUp()
Пример #4
0
    def test_multiple_drivers_with_different_regions(self):
        driver1 = ElasticHosts('foo', 'bar', region='lon-p')
        driver2 = ElasticHosts('foo', 'bar', region='sat-p')

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))

        driver1.list_nodes()
        driver2.list_nodes()
        driver1.list_nodes()

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))
Пример #5
0
    def test_multiple_drivers_with_different_regions(self):
        driver1 = ElasticHosts('foo', 'bar', region='lon-p')
        driver2 = ElasticHosts('foo', 'bar', region='sat-p')

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))

        driver1.list_nodes()
        driver2.list_nodes()
        driver1.list_nodes()

        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))
Пример #6
0
    def test_multiple_drivers_with_different_regions(self):
        driver1 = ElasticHosts("foo", "bar", region="lon-p")
        driver2 = ElasticHosts("foo", "bar", region="sat-p")

        self.assertTrue(driver1.connection.host.startswith("api-lon-p"))
        self.assertTrue(driver2.connection.host.startswith("api-sat-p"))

        driver1.list_nodes()
        driver2.list_nodes()
        driver1.list_nodes()

        self.assertTrue(driver1.connection.host.startswith("api-lon-p"))
        self.assertTrue(driver2.connection.host.startswith("api-sat-p"))