scenario:
  id: 376ad526-529d-4026-81d7-ecc60e8c89a1
  context:
    auth:
      type: bearer
    base_path: null
    host: us-west-2.env.shared.aws.tidbcloud.com
  description: tiproxy bff without create and delete cluster
  name: tiproxy_bff_partly_scenario
steps:
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: ClusterService_CreateCluster
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "POST",
        "path": "/api/v2023/dedicated/v1beta1/clusters",
        "path_params": {},
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "headers": {},
        "body": {
          "displayName": "sce-bff-tiproxy",
          "labels": {
            "tidb.cloud/project": "{projectId}"
          },
          "port": 4000,
          "regionId": "{regionId}",
          "rootPassword": "31415926",
          "tidbNodeSetting": {
            "nodeSpecKey": "8C16G",
            "tidbNodeGroups": [
              {
                "nodeCount": 2,
                "tiproxySetting": {
                  "nodeCount": 2,
                  "nodeSpecKey": "2C4G"
                }
              }
            ]
          },
          "tikvNodeSetting": {
            "nodeCount": 3,
            "nodeSpecKey": "8C32G",
            "storageSizeGi": 200,
            "storageType": "Standard"
          }
        },
        "body_params": {
          "regionId": "region_id",
          "projectId": "project_id",
          "orgId": "org_id"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"CREATING\""
      }
    description: Create a 8C cluster to test tiproxy
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: create_cluster
    save: |-
      {
        "placeholder": [
          { "key": "cluster_1", "eval": "body.clusterId" }
        ]
      }
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 0
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.state == 'ACTIVE'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 1
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeCount == 2 && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeSpecDisplayName == 'Small'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 2
  - operation_id: ClusterService_AdvancedModifyDedicatedCluster
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}:dedicatedAdvancedModify",
        "headers": {},
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {
          "displayName": "sys-test",
          "tidbNodeSetting": {
            "createTidbNodeGroups": [
              {
                "displayName": "new-tidb-nodegroup",
                "nodeCount": 2,
                "tiproxySetting": {
                  "nodeSpecKey": "2C4G",
                  "nodeCount": 3
                }
              }
            ]
          }
        },
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 3
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[1].state == 'ACTIVE' && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[1].tiproxySetting.nodeCount == 3 && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeSpecDisplayName == 'Small'"
      }
    save: |-
      {
        "placeholder": [
          { "key": "nodegroup_2", "eval": "body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[1].tidbNodeGroupId"},
          { "key": "nodegroup_1", "eval": "body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tidbNodeGroupId" }
        ]
      }
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 4
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.state == 'ACTIVE'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 5
  - operation_id: ClusterService_AdvancedModifyDedicatedCluster
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}:dedicatedAdvancedModify",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {
          "displayName": "sys-test",
          "tidbNodeSetting": {
            "deleteTidbNodeGroupIds": [
              "{nodegroupId}"
            ]
          }
        },
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1",
          "orgId": "org_id"
        },
        "body_params": {
          "nodegroupId": "nodegroup_2"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 6
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.state == 'ACTIVE'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 7
  - operation_id: ClusterService_AdvancedModifyDedicatedCluster
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}:dedicatedAdvancedModify",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {
          "displayName": "sys-test",
          "tidbNodeSetting": {
            "updateTidbNodeGroups": [
              {
                "tidbNodeGroupId": "{nodegroupId}",
                "nodeCount": 2,
                "tiproxySetting": {
                  "nodeCount": 0,
                  "nodeSpecKey": "2C4G"
                }
              }
            ]
          }
        },
        "auth": {
          "auth_type": "bearer_token"
        },
        "body_params": {
          "nodegroupId": "nodegroup_1"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 8
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.state == 'ACTIVE'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 9
  - operation_id: ClusterService_AdvancedModifyDedicatedCluster
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}:dedicatedAdvancedModify",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {
          "displayName": "sys-test",
          "tidbNodeSetting": {
            "updateTidbNodeGroups": [
              {
                "tidbNodeGroupId": "{nodegroupId}",
                "nodeCount": 2,
                "tiproxySetting": {
                  "nodeCount": 3,
                  "nodeSpecKey": "8C16G"
                }
              }
            ]
          }
        },
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        },
        "body_params": {
          "nodegroupId": "nodegroup_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 10
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.state == 'ACTIVE' && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeCount == 3 && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeSpecDisplayName == 'Large'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 11
  - operation_id: ClusterService_AdvancedModifyDedicatedCluster
    request_type: http
    request: |-
      {
        "method": "POST",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}:dedicatedAdvancedModify",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {
          "displayName": "sys-test",
          "tidbNodeSetting": {
            "updateTidbNodeGroups": [
              {
                "tidbNodeGroupId": "{nodegroupId}",
                "nodeCount": 2,
                "tiproxySetting": {
                  "nodeCount": 2,
                  "nodeSpecKey": "8C16G"
                }
              }
            ]
          }
        },
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1",
          "orgId": "org_id",
          "project_id": "project_id"
        },
        "body_params": {
          "nodegroupId": "nodegroup_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    save: null
    description: ""
    max_retries: 0
    delay_after: 0
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 12
  - operation_id: ClusterService_GetCluster
    request_type: http
    request: |-
      {
        "method": "GET",
        "path": "/api/v2023/clusterManagement/v1beta1/clusters/{clusterId}",
        "headers": {},
        "query_params": {         
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "body": {},
        "auth": {
          "auth_type": "bearer_token"
        },
        "path_params": {
          "clusterId": "cluster_1"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.dedicatedCluster.state == 'ACTIVE' && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeCount == 2 && body.dedicatedCluster.tidbNodeSetting.tidbNodeGroups[0].tiproxySetting.nodeSpecDisplayName == 'Large'"
      }
    save: null
    description: ""
    max_retries: 120
    delay_after: 30
    name: ""
    continue_on_unexpected: false
    stage: ""
    meta: "{}"
    generation_id: ""
    order: 13
  - case_id: cleanup_cluster_1
    operation_id: ClusterService_DeleteCluster
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "bearer_token"
        },
        "method": "DELETE",
        "path": "/api/v2023/dedicated/v1beta1/clusters/{clusterId}",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {          
          "projectId": "project_id",
          "orgId": "org_id"
        },
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": ""
      }
    description: Cleanup step for TiDB Cloud cluster with no parent dependency.
    max_retries: 0
    delay_after: 0
    step_type: generated
    name: Delete TiDB Cloud Cluster
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 14