Exemplo n.º 1
0
    def test_source_slave_failover(self, config, instance_data, expected_data):
        instance = instance_data["modify_cluster_instance"]

        expected_object = baseCheckPoint(
            expected_data[instance["cacheInstanceClass"]],
            instance["instance_password"])
        client, _, instanceId = create_validate_instance(
            config, instance, expected_object)

        shard_num = instance["target_shardNumber"]
        resp = reset_class(config, instanceId,
                           instance["target_cacheInstanceClass"], client,
                           shard_num)
        assertRespNotNone(resp)

        expected_object = baseCheckPoint(
            expected_data[instance["target_cacheInstanceClass"]],
            instance["instance_password"])
        expected_object.side = 1
        expected_object.current_rs_type = "b"
        expected_object.next_rs_type = "a"

        # 等待resize开始
        for i in range(0, 600):
            resp_get_job = get_job(instanceId, config, str(resp.request_id))
            if resp_get_job["code"] == 0:
                break
            sleep(1)

        # 触发slave failover
        current_rs_type = get_current_rs_type(instanceId, config)
        redisNum = get_redis_num(instanceId, config, current_rs_type)
        redisId = get_shard_id(redisNum, 1)[0]
        replicasetName = instanceId + "-slave-" + current_rs_type
        dockerName = replicasetName + "-" + str(redisId)
        oldRunTime = get_docker_running_time(config, instanceId,
                                             replicasetName, dockerName)
        status = trigger_docker_failover("redis",
                                         config,
                                         instanceId,
                                         config["region"],
                                         docker_name=dockerName)
        assert status == 200

        assert wait_docker_run_time_change(config, instanceId, oldRunTime,
                                           replicasetName, dockerName)

        # 手动调用任务恢复接口
        print(
            "please run recover task interface.For example:curl http://127.0.0.1:1818/reloadTask -d '{\"taskId\":"
            ",\"isRollback\":false}'")

        sleep(10)
        for i in range(0, 3600):
            if get_space_status(instanceId, config) == "Running":
                break
            sleep(1)

        assert check_admin_proxy_redis_configmap(instanceId, config,
                                                 expected_object, shard_num)
Exemplo n.º 2
0
    def test_normal_resize(self, config, instance_data, expected_data):
        instance = instance_data["modify_cluster_instance"]

        expected_object = baseCheckPoint(
            expected_data[instance["cacheInstanceClass"]],
            instance["instance_password"])
        client, _, instanceId = create_validate_instance(
            config, instance, expected_object)

        shard_num = instance["target_shardNumber"]
        resp = reset_class(config, instanceId,
                           instance["target_cacheInstanceClass"], client,
                           shard_num)
        assertRespNotNone(resp)

        expected_object = baseCheckPoint(
            expected_data[instance["target_cacheInstanceClass"]],
            instance["instance_password"])
        expected_object.side = 1
        expected_object.current_rs_type = "b"
        expected_object.next_rs_type = "a"
        sleep(60)

        # 等待resize开始
        for i in range(0, 600):
            resp_get_job = get_job(instanceId, config, str(resp.request_id))
            if resp_get_job["code"] == 0:
                break
            sleep(1)

        sleep(10)
        for i in range(0, 3600):
            if get_space_status(instanceId, config) == "Running":
                break
            sleep(1)

        assert check_admin_proxy_redis_configmap(instanceId, config,
                                                 expected_object, shard_num)