Ejemplo n.º 1
0
class TestMysqlClusterSuite(object):

    def setup_class(self):
        self.middleware = Middleware()
        self.newapp = Newapplication()
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
        self.mysql_cluster_name = "e2e-mysql-clu"

    def teardown_class(self):
        self.newapp.delete_newapp(self.namespace, self.mysql_cluster_name)
        self.newapp.check_exists(self.newapp.get_newapp_common_url(self.namespace, self.mysql_cluster_name), 404)

    @pytest.mark.middleware_mysql_cluster
    def test_mysql_cluster(self):
        result = {"flag": True}
        template_id = self.middleware.get_template_id("mysql-cluster")
        version_id = self.middleware.get_version_id(template_id)

        create_result = self.middleware.create_application('./test_data/middleware/mysql-cluster.json',
                                                           {"$name": self.mysql_cluster_name,
                                                            "$template_id": template_id, "$version_id": version_id})
        assert create_result.status_code == 201, "中间件创建应用mysql-cluster失败 {}".format(create_result.text)
        logger.info("中间件创建mysql-cluster应用成功")

        app_status = self.middleware.get_application_status(self.namespace, self.mysql_cluster_name, "Running")
        assert app_status, "mysql-cluster应用的状态不在运行中"
        logger.info("mysql-cluster应用在运行中")

        delete_result = self.newapp.delete_newapp(self.namespace, self.mysql_cluster_name)
        assert delete_result.status_code == 204, "删除mysql-cluster应用失败 {}".format(delete_result.text)
        self.newapp.check_exists(self.newapp.get_newapp_common_url(self.namespace, self.mysql_cluster_name), 404)
        logger.info("删除mysql-cluster应用成功")

        assert result['flag'], True
Ejemplo n.º 2
0
class TestRedisSuite(object):

    def setup_class(self):
        self.newapp = Newapplication()
        self.middleware = Middleware()
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
        self.redis_name = "e2e-redis-pub"

    def teardown_class(self):
        logger.info("清除redis应用资源")
        self.newapp.delete_newapp(self.namespace, self.redis_name)
        self.newapp.check_exists(self.newapp.get_newapp_common_url(self.namespace, self.redis_name), 404)
        logger.info("清除完毕")

    @pytest.mark.middleware_redis
    def test_redis(self):
        result = {"flag": True}
        redis_template_id = self.middleware.get_template_id("redis")
        version_id = self.middleware.get_version_id(redis_template_id)
        create_result = self.middleware.create_application('./test_data/middleware/redis.json',
                                                           {"$name": self.redis_name, "$template_id": redis_template_id,
                                                            "$version_id": version_id})
        assert create_result.status_code == 201, "中间件创建redis应用失败 {}".format(create_result.text)
        logger.info("创建redis应用成功")

        app_status = self.middleware.get_application_status(self.namespace, self.redis_name, "Running")
        assert app_status, "创建应用后,验证应用状态出错,app:{} is not Running".format(self.redis_name)
        logger.info("redis应用为运行中")

        delete_result = self.newapp.delete_newapp(self.namespace, self.redis_name)
        assert delete_result.status_code == 204, "删除redis应用失败 {}".format(delete_result)
        self.newapp.check_exists(self.newapp.get_newapp_common_url(self.namespace, self.redis_name), 404)
        logger.info("删除redis应用成功")

        assert result["flag"], True
Ejemplo n.º 3
0
    def setup_class(self):
        self.newapp = Newapplication()
        self.middleware = Middleware()
        self.scs = Scs()

        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
        self.zookeeper_name = "e2e-zookeeper-pub"
        self.kafka_name = "e2e-kafka-pub"

        scs_list_result = self.scs.list_scs()
        assert len(scs_list_result.json()) > 0, "没有存储类,不能创建zookeeper,创建zookeeper用例失败"
        self.scs_name = scs_list_result.json()[0]["kubernetes"]["metadata"]["name"]
        logger.info("查出来的第一个scs {}".format(self.scs_name))

        # 创建zookeeper
        zookeeper_template_id = self.middleware.get_template_id("zookeeper")
        version_id = self.middleware.get_version_id(zookeeper_template_id)
        create_result = self.middleware.create_application('./test_data/middleware/zookeeper.json',
                                                           {"$name": self.zookeeper_name,
                                                            "$template_id": zookeeper_template_id,
                                                            "$version_id": version_id, "$scs_name": self.scs_name})
        assert create_result.status_code == 201, "测试kafka前提条件创建zookeeper应用失败 {}".format(create_result.text)
        logger.info("测试kafka前提条件创建zookeeper应用成功")

        app_status = self.middleware.get_application_status(self.namespace, self.zookeeper_name, "Running")
        assert app_status, "测试kafka前提条件创建zookeeper应用后,验证应用状态出错,app:{} is not Running".format(self.zookeeper_name)
        logger.info("测试kafka前提条件zookeeper应用为运行中")
Ejemplo n.º 4
0
class TestMongodbSuite(object):
    def setup_class(self):
        self.middleware = Middleware()
        self.catalog = Catalog()
        self.newapp = Newapplication()
        self.name = "e2e-mongodb-pub"
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]

    def teardown_class(self):
        self.newapp.delete_newapp(self.namespace, self.name)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace, self.name), 404)

    @pytest.mark.middleware_mongodb
    def test_mongodb(self):
        # 中间件获取mongodb的模板id-获取mongodb可用的version id-创建mongodb应用-获取应用状态-删除应用
        result = {'flag': True}

        mongodb_template_id = self.middleware.get_template_id("mongodb")
        logger.info("中间件mongodb模板id:{}".format(mongodb_template_id))

        version_id = self.middleware.get_version_id(mongodb_template_id)
        logger.info("中间件mongodb的可使用的version id:{}".format(version_id))

        create_result = self.middleware.create_application(
            './test_data/middleware/mongodb.json', {
                "$name": self.name,
                "$template_id": mongodb_template_id,
                "$version_id": version_id
            })
        assert create_result.status_code == 201, "创建mongodb失败 {}".format(
            create_result.text)
        logger.info("创建mongodb成功,name是:{}".format(self.name))

        app_status = self.middleware.get_application_status(
            self.namespace, self.name, "Running")
        assert app_status, "创建应用后,验证应用状态出错:app: {} is not running".format(
            self.name)
        logger.info("mongodb的应用状态为:Running")

        # pods_result = self.middleware.get_pods(self.namespace, self.name)
        # logger.info("拿到了pod请求的返回值")
        # hostIP = pods_result.json()[0]["kubernetes"]["status"]["hostIP"]
        # logger.info("获取mongodb容器Ip为:{}".format(hostIP))
        # podIP = pods_result.json()[0]["kubernetes"]["status"]["podIP"]
        # logger.info("获取mongodb所在podIp为:{}".format(podIP))
        delete_result = self.newapp.delete_newapp(self.namespace, self.name)
        assert delete_result.status_code == 204, "删除中间件创建的mongodb应用失败 {}".format(
            delete_result.text)
        logger.info("删除中间件创建的mongodb应用成功")
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace, self.name), 404)
        assert result["flag"], True
Ejemplo n.º 5
0
    def setup_class(self):

        self.catalog = Catalog()
        self.middleware = Middleware()
        self.newapp = Newapplication()

        self.app_name = "e2e-mongodb-pri"
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]

        self.git_name = "alauda-git-repository"
        self.update_git_displayname = "update-git-repository"
        self.svn_name = "alauda-svn-repository"
        self.upadte_svn_displayname = "update-svn-repository"
Ejemplo n.º 6
0
    def setup_class(self):
        self.newapp = Newapplication()
        self.middleware = Middleware()
        self.scs = Scs()

        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
        self.zookeeper_name = "e2e-zookeeper-pub"
        self.kafka_name = "e2e-kafka-pub"

        scs_list_result = self.scs.list_scs()
        assert len(
            scs_list_result.json()) > 0, "没有存储类,不能创建zookeeper,创建zookeeper用例失败"
        self.scs_name = scs_list_result.json(
        )[0]["kubernetes"]["metadata"]["name"]
        logger.info("查出来的第一个scs {}".format(self.scs_name))
Ejemplo n.º 7
0
class TestRabbitmq(object):
    def setup_class(self):
        self.middleware = Middleware()
        self.newapp = Newapplication()
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
        self.name = "e2e-rabbitmq-ha"

    def teardown_class(self):
        self.newapp.delete_newapp(self.namespace, self.name)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace, self.name), 404)

    @pytest.mark.middleware_rabbitmq_ha
    def test_rabbitmq_ha(self):
        result = {"flag": True}
        template_id = self.middleware.get_template_id("rabbitmq-ha")
        version_id = self.middleware.get_version_id(template_id)
        create_result = self.middleware.create_application(
            './test_data/middleware/rabbitmq-ha.json', {
                "$name": self.name,
                "$template_id": template_id,
                "$version_id": version_id
            })

        assert create_result.status_code == 201, "中间件创建rabbitmq-ha应用失败 {}".format(
            create_result.text)

        logger.info("中间件创建rabbitmq-ha应用成功")

        app_status = self.middleware.get_application_status(
            self.namespace, self.name, "Running")
        assert app_status, "rabbitmq-ha应用状态不是运行中"
        logger.info("rabbitmq-ha应用状态是运行中")

        delete_result = self.newapp.delete_newapp(self.namespace, self.name)
        assert delete_result.status_code == 204, "删除rabbitnq-ha应用失败 {}".format(
            delete_result.text)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace, self.name), 404)
        logger.info("删除rabbitmq-ha应用成功")

        assert result["flag"], True
Ejemplo n.º 8
0
class TestMysqlSuite(object):

    def setup_class(self):
        self.middleware = Middleware()
        self.newapp = Newapplication()
        self.mysql_name = "e2e-mysql-pub"
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]

    def teardown_class(self):
        logger.info("清除mysql应用资源")
        self.newapp.delete_newapp(self.namespace, self.mysql_name)
        self.newapp.check_exists(self.newapp.get_newapp_common_url(self.namespace, self.mysql_name), 404)
        logger.info("清除完毕")

    @pytest.mark.middleware_mysql
    def test_mysql(self):
        result = {"flag": True}
        mysql_template_id = self.middleware.get_template_id("mysql")
        version_id = self.middleware.get_version_id(mysql_template_id)

        create_result = self.middleware.create_application('./test_data/middleware/mysql.json',
                                                           {"$name": self.mysql_name, "$template_id": mysql_template_id,
                                                            "$version_id": version_id})
        assert create_result.status_code == 201, "中间件创建mysql应用失败 {}".format(create_result.text)
        logger.info("中间间创建mysql应用成功,name:{}".format(self.mysql_name))

        app_status = self.middleware.get_application_status(self.namespace, self.mysql_name, "Running")
        assert app_status, "创建应用后,验证应用状态出错,app:{} is not Running".format(self.mysql_name)
        logger.info("mysql应用状态在运行中")

        delete_result = self.newapp.delete_newapp(self.namespace, self.mysql_name)
        assert delete_result.status_code == 204, "删除中间件创建出的mysql应用失败{}".format(delete_result)
        logger.info("删除mysql应用成功")
        self.newapp.check_exists(self.newapp.get_newapp_common_url(self.namespace, self.mysql_name), 404)

        assert result["flag"], True
Ejemplo n.º 9
0
class TestCatalogSuite(object):
    def setup_class(self):

        self.catalog = Catalog()
        self.middleware = Middleware()
        self.newapp = Newapplication()

        self.app_name = "e2e-mongodb-pri"
        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]

        self.git_name = "alauda-git-repository"
        self.update_git_displayname = "update-git-repository"
        self.svn_name = "alauda-svn-repository"
        self.upadte_svn_displayname = "update-svn-repository"

    def teardown_class(self):

        logger.info("开始清除应用目录数据")
        self.newapp.delete_newapp(self.namespace, self.app_name)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace, self.app_name),
            404)
        if len(self.catalog.get_repository_list().json()) > 0:
            self.catalog.delete_repository(
                self.catalog.get_uuid_accord_name(
                    self.catalog.get_repository_list().json()["results"],
                    {"name": self.git_name}, "uuid"))
        if len(self.catalog.get_repository_list().json()) > 0:
            self.catalog.delete_repository(
                self.catalog.get_uuid_accord_name(
                    self.catalog.get_repository_list().json()["results"],
                    {"name": self.svn_name}, "uuid"))
        logger.info("清除完毕")

    @pytest.mark.repository_git
    def test_repository_git(self):
        '''
        添加应用目录模板仓库
        :return:
        '''

        result = {"flag": True}

        create_result = self.catalog.create_repository(
            './test_data/catalog/repository_git.json',
            {'$repository_name': self.git_name})
        assert create_result.status_code == 201, "添加应用目录git模板仓库失败 {}".format(
            create_result.text)
        self.git_id = self.catalog.get_value(create_result.json(), 'uuid')
        logger.info("git模板仓库创建成功")
        '''
        获取模板仓库列表,列表中包含新建模板仓库
        '''
        repository_list = self.catalog.get_repository_list()
        result = self.catalog.update_result(result,
                                            repository_list.status_code == 200,
                                            "获取应用目录模板仓库列表失败")
        result = self.catalog.update_result(
            result, self.git_name in repository_list.text,
            "获取应用目录模板仓库列表失败:新建git模板仓库不在列表中")
        logger.info("列表中包含新建git模板仓库")
        '''
        获取模板仓库详细信息
        '''
        repository_status = self.catalog.get_repository_status(
            self.git_id, "SUCCESS")
        assert repository_status, "创建应用目录git模板仓库后,状态不是SUCCESS"
        logger.info("获取git模板仓库详情信息成功")
        '''
        更新模板仓库
        '''
        update_result = self.catalog.update_repository(
            self.git_id, './test_data/catalog/update_repository_git.json',
            {'$display_name': self.update_git_displayname})
        assert update_result.status_code == 200, "更新应用目录git模板仓库失败 {}".format(
            update_result.text)
        result = self.catalog.update_result(
            result, self.update_git_displayname in update_result.text,
            "更新应用目录模板仓库失败:修改的显示名称与设置不一致")
        repository_status = self.catalog.get_repository_status(
            self.git_id, "SUCCESS")
        assert repository_status, "更新应用目录git模板仓库后,状态不是SUCCESS"
        logger.info("更新应用目录git模板仓库成功")
        '''
        同步模板仓库
        '''
        refresh_result = self.catalog.refresh_repository(self.git_id)
        assert refresh_result.status_code == 204, "应用目录同步模板仓库失败 {}".format(
            refresh_result.text)
        repository_status = self.catalog.get_repository_status(
            self.git_id, "SUCCESS")
        assert repository_status, "同步应用目录git模板仓库后,状态不是SUCCESS"
        logger.info("同步git模板仓库成功")
        assert result['flag'], result

    @pytest.mark.repository_svn
    def test_repository_svn(self):
        '''
        添加应用目录模板仓库
        :return:
        '''

        result = {"flag": True}

        create_result = self.catalog.create_repository(
            './test_data/catalog/repository_svn.json',
            {'$repository_name': self.svn_name})
        assert create_result.status_code == 201, "添加应用目录svn模板仓库失败 {}".format(
            create_result.text)
        self.svn_id = self.catalog.get_value(create_result.json(), 'uuid')
        logger.info("模板仓库创建成功")
        '''
        获取模板仓库列表,列表中包含新建模板仓库
        '''
        repository_list = self.catalog.get_repository_list()
        result = self.catalog.update_result(result,
                                            repository_list.status_code == 200,
                                            "获取应用目录svn模板仓库列表失败")
        result = self.catalog.update_result(
            result, self.svn_name in repository_list.text,
            "获取应用目录svn模板仓库列表失败:新建模板仓库不在列表中")
        logger.info("列表中包含新建模板仓库")
        '''
        获取模板仓库详细信息
        '''
        repository_status = self.catalog.get_repository_status(
            self.svn_id, "SUCCESS")
        assert repository_status, "创建应用目录svn模板仓库后,状态不是SUCCESS"
        logger.info("获取详情信息成功")
        '''
        更新模板仓库
        '''
        update_result = self.catalog.update_repository(
            self.svn_id, './test_data/catalog/update_repository_svn.json',
            {'$display_name': self.upadte_svn_displayname})
        assert update_result.status_code == 200, "更新应用目录svn模板仓库失败 {}".format(
            update_result.text)
        result = self.catalog.update_result(
            result, self.upadte_svn_displayname in update_result.text,
            "更新应用目录svn模板仓库失败:修改的显示名称与设置不一致")
        repository_status = self.catalog.get_repository_status(
            self.svn_id, "SUCCESS")
        assert repository_status, "更新应用目录svn模板仓库后,状态不是SUCCESS"
        logger.info("更新模板仓库成功")
        '''
        同步模板仓库
        '''
        refresh_result = self.catalog.refresh_repository(self.svn_id)
        assert refresh_result.status_code == 204, "应用目录同步模板仓库失败 {}".format(
            refresh_result.text)
        repository_status = self.catalog.get_repository_status(
            self.svn_id, "SUCCESS")
        assert repository_status, "同步应用目录模板仓库后,状态不是SUCCESS"
        logger.info("同步模板仓库成功")
        '''
        删除模板仓库
        '''
        delete_result = self.catalog.delete_repository(self.svn_id)
        result = self.catalog.update_result(result,
                                            delete_result.status_code == 200,
                                            "删除应用目录svn模板仓库失败")
        assert result['flag'], result
        logger.info("删除应用目录svn模板仓库成功")

    @pytest.mark.catalog_mongodb
    def nottest_catalog_mongodb(self):
        '''
        使用应用目录模板中的模板创建mongodb应用
        :return:
        '''

        result = {"flag": True}
        assert len(self.catalog.get_repository_list().json()
                   ) > 0, "应用没有创建出git仓库,没法创建mongodb应用"
        if len(self.catalog.get_repository_list().json()) > 0:
            repository_id = self.catalog.get_uuid_accord_name(
                self.catalog.get_repository_list().json()["results"],
                {"name": self.git_name}, "uuid")

            templates_list = self.catalog.get_templates(repository_id)
            templates = self.catalog.get_value(templates_list.json(),
                                               'results')
            template_id = ""
            for template in templates:
                template_name = template.get("name", "")
                if "mongodb" == template_name:
                    template_id = template.get("uuid", "")
                    break
            logger.info("获取应用目录mongodb模板的id:{}".format(template_id))
            mongodb_info = self.middleware.get_template_info(template_id)
            version_id = self.catalog.get_value(mongodb_info.json(),
                                                "versions.0.uuid")
            logger.info("获取到的mongodb的version id:{}".format(version_id))

            create_result = self.middleware.create_application(
                './test_data/catalog/catalog_mongodb.json', {
                    "$catalog_app_name": self.app_name,
                    "$template_id": template_id,
                    "$version_id": version_id
                })
            assert create_result.status_code == 201, "创建mongodb失败 {}".format(
                create_result.text)
            logger.info("应用目录创建mongodb成功")

            app_id = self.catalog.get_value(create_result.json(),
                                            "kubernetes.metadata.uid")
            logger.info("创建mongodb成功,id是:{}".format(app_id))
            logger.info("创建mongodb成功,name是:{}".format(self.app_name))

            app_status = self.middleware.get_application_status(
                self.namespace, self.app_name, "Running")

            assert app_status, "创建应用后,验证应用状态出错:app: {} is not running".format(
                self.app_name)
            logger.info("mongodb的应用状态为:Running")

            # 删除应用
            delete_result = self.newapp.delete_newapp(self.namespace,
                                                      self.app_name)
            assert delete_result.status_code == 204, "删除应用目录创建出的mongodb应用失败 {}".format(
                delete_result.text)
            self.newapp.check_exists(
                self.newapp.get_newapp_common_url(self.namespace,
                                                  self.app_name), 404)
            assert result['flag'], True
Ejemplo n.º 10
0
 def setup_class(self):
     self.middleware = Middleware()
     self.catalog = Catalog()
     self.newapp = Newapplication()
     self.name = "e2e-mongodb-pub"
     self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
Ejemplo n.º 11
0
 def setup_class(self):
     self.middleware = Middleware()
     self.newapp = Newapplication()
     self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
     self.mysql_cluster_name = "e2e-mysql-clu"
Ejemplo n.º 12
0
class TestZookeeperSuite(object):
    def setup_class(self):
        self.newapp = Newapplication()
        self.middleware = Middleware()
        self.scs = Scs()

        self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
        self.zookeeper_name = "e2e-zookeeper-pub"
        self.kafka_name = "e2e-kafka-pub"

        scs_list_result = self.scs.list_scs()
        assert len(
            scs_list_result.json()) > 0, "没有存储类,不能创建zookeeper,创建zookeeper用例失败"
        self.scs_name = scs_list_result.json(
        )[0]["kubernetes"]["metadata"]["name"]
        logger.info("查出来的第一个scs {}".format(self.scs_name))

    def teardown_class(self):
        logger.info("清除zookeeper应用资源")
        self.newapp.delete_newapp(self.namespace, self.kafka_name)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace, self.kafka_name),
            404)
        self.newapp.delete_newapp(self.namespace, self.zookeeper_name)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace,
                                              self.zookeeper_name), 404)
        logger.info("清除完毕")

    @pytest.mark.middleware_zookeeper
    def test_zookeeper(self):
        result = {"flag": True}
        zookeeper_template_id = self.middleware.get_template_id("zookeeper")
        version_id = self.middleware.get_version_id(zookeeper_template_id)
        create_result = self.middleware.create_application(
            './test_data/middleware/zookeeper.json', {
                "$name": self.zookeeper_name,
                "$template_id": zookeeper_template_id,
                "$version_id": version_id,
                "$scs_name": self.scs_name
            })
        assert create_result.status_code == 201, "中间件创建zookeeper应用失败 {}".format(
            create_result.text)
        logger.info("中间件创建zookeeper应用成功")

        app_status = self.middleware.get_application_status(
            self.namespace, self.zookeeper_name, "Running")
        assert app_status, "创建应用后,验证应用状态出错,app:{} is not Running".format(
            self.zookeeper_name)
        logger.info("中间件zookeeper应用为运行中")

        delete_result = self.newapp.delete_newapp(self.namespace,
                                                  self.zookeeper_name)
        assert delete_result.status_code == 204, "删除zookeeper应用失败 {}".format(
            delete_result.text)
        self.newapp.check_exists(
            self.newapp.get_newapp_common_url(self.namespace,
                                              self.zookeeper_name), 404)
        logger.info("删除zookeeper应用成功")

        assert result["flag"], True
Ejemplo n.º 13
0
 def setup_class(self):
     self.newapp = Newapplication()
     self.middleware = Middleware()
     self.namespace = self.middleware.global_info["$K8S_NAMESPACE"]
     self.redis_name = "e2e-redis-pub"