コード例 #1
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
    def test_get_schemas(self):
        # Create new stacks
        conn = rancher.Rancher()
        conn.create_mysql_stack(KERMIT_SCIPER, unit_id=self.idevelop_id)
        conn.create_mysql_stack(KERMIT_SCIPER, unit_id=self.idevelop_id)

        # Return schemas by sciper
        schemas = conn.get_schemas_by_user(KERMIT_SCIPER)

        # Check the number of stacks
        self.assertEqual(len(schemas), 2)

        # Return schemas by unit and user
        schemas = conn.get_schemas_by_unit_and_user(KERMIT_UNIT, KERMIT_SCIPER)

        # Check the number of stacks
        self.assertEqual(len(schemas), 2)

        # Return schemas by unit and user
        schemas = conn.get_schemas_by_unit(KERMIT_UNIT)

        # Check the number of stacks
        self.assertEqual(len(schemas), 2)

        # Return stacks by sciper
        conn.get_stacks_by_user(KERMIT_SCIPER)

        # Clean stacks
        conn.clean_stacks(KERMIT_SCIPER)
コード例 #2
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
    def test_get_template(self):
        conn = rancher.Rancher()

        template = "idevelop:mysql"

        data = conn.get_template(template)

        self.assertTrue(data["id"].startswith(template))
コード例 #3
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
    def test_get_schema(self):

        conn = rancher.Rancher()
        data = conn.create_mysql_stack(KERMIT_SCIPER, unit_id=self.idevelop_id)

        schema = conn.get_schema(data["schema_id"])
        self.assertEqual(KERMIT_UNIT, schema["unit_id"])

        conn.delete_schema(data["schema_id"])
コード例 #4
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
    def test_create_mysql_stack(self):
        conn = rancher.Rancher()
        data = conn.create_mysql_stack(KERMIT_SCIPER, unit_id=self.idevelop_id)

        self.assertTrue(data["connection_string"].startswith("mysql://"))
        self.assertTrue(data["mysql_cmd"].startswith("mysql "))

        # Return stacks by sciper
        conn.get_stacks_by_user(KERMIT_SCIPER)

        # Clean stacks
        conn.clean_stacks(KERMIT_SCIPER)
コード例 #5
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
    def test_delete_schema(self):

        # Create and delete schema
        conn = rancher.Rancher()
        data = conn.create_mysql_stack(KERMIT_SCIPER, unit_id=self.idevelop_id)
        conn.delete_schema(data["schema_id"])

        sleep(15)

        # Return schemas by sciper
        schemas = conn.get_schemas_by_user(KERMIT_SCIPER)

        self.assertEqual(len(schemas), 0)
コード例 #6
0
ファイル: test_views.py プロジェクト: dabelenda/amm
    def test_get_schemas(self):
        """ Test the GET method of schemas"""

        # create an API key
        response = self.client.post(reverse('apikey-list'),
                                    data={
                                        "username":
                                        get_config('TEST_USERNAME'),
                                        "password":
                                        get_config('TEST_CORRECT_PWD')
                                    },
                                    format='json')

        content = json.loads(response.content.decode('utf-8'))

        self.client.post(reverse('schema-list'),
                         data={
                             "access_key": content["access_key"],
                             "secret_key": content["secret_key"]
                         },
                         format='json')

        response = self.client.get(reverse('schema-list'),
                                   data={
                                       "access_key": content["access_key"],
                                       "secret_key": content["secret_key"]
                                   },
                                   format='json')

        content = json.loads(response.content.decode('utf-8'))

        # we get a list of dicts with 1 element
        self.assertEqual(len(content), 1)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['content-type'], 'application/json')

        # Clean stacks
        conn = rancher.Rancher()
        conn.clean_stacks(KERMIT_SCIPER)
コード例 #7
0
ファイル: test_views.py プロジェクト: dabelenda/amm
    def test_post_schemas(self):
        """ Test the POST method of Schemas """

        # create API Keys
        response = self.client.post(reverse('apikey-list'),
                                    data={
                                        "username":
                                        get_config('TEST_USERNAME'),
                                        "password":
                                        get_config('TEST_CORRECT_PWD')
                                    },
                                    format='json')

        content = json.loads(response.content.decode('utf-8'))
        access_key = content["access_key"]
        secret_key = content["secret_key"]

        # create schemas
        response = self.client.post(reverse('schema-list'),
                                    data={
                                        "access_key": access_key,
                                        "secret_key": secret_key
                                    },
                                    format='json')

        content = json.loads(response.content.decode('utf-8'))

        "mysql://*****:*****@mysql-78bc59f0.db.rsaas.epfl.ch:12068/98c321cb"
        self.assertIsNotNone(
            re.match('^mysql://\w+:[-\+\w]+@[-\.\w]+:\d+/.+$',
                     content['connection_string']))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['content-type'], 'application/json')

        # Get schema
        response = self.client.get(reverse(
            viewname='schema-detail',
            args={content["schema_id"]},
        ),
                                   data={
                                       "access_key": access_key,
                                       "secret_key": secret_key
                                   },
                                   format='json')

        content = json.loads(response.content.decode('utf-8'))

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['content-type'], 'application/json')
        self.assertIsNotNone(
            re.match('^mysql://\w+@[-\.\w]+:\d+/.+$',
                     content['connection_string']))

        sleep(10)

        # Patch schema
        response = self.client.patch(reverse(
            viewname='schema-detail',
            args={content["schema_id"]},
        ),
                                     data={
                                         "access_key": access_key,
                                         "secret_key": secret_key,
                                         "unit_id": "13029"
                                     },
                                     format='json')
        content = json.loads(response.content.decode('utf-8'))

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['content-type'], 'application/json')
        self.assertEqual(content["unit_id"], "13029")

        # Clean stacks
        # Clean stacks
        conn = rancher.Rancher()
        conn.clean_stacks(KERMIT_SCIPER)
コード例 #8
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
 def test_get_available_port(self):
     conn = rancher.Rancher()
     conn.get_available_port()
コード例 #9
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
 def test_get_ports_used(self):
     conn = rancher.Rancher()
     ports_used = conn.get_ports_used()
     self.assertTrue(ports_used, list)
コード例 #10
0
ファイル: test_rancher.py プロジェクト: epfl-si/amm
    def test_get(self):
        conn = rancher.Rancher()

        r = conn.get("/v1-catalog/templates/idevelop:mysql")

        self.assertEqual(200, r.status_code)