scenario:
  id: abcf522f5754a26096985d8962f63abc
  context:
    auth:
      type: digest
    base_path: /v1beta1
    host: null
  description: "Auto-generated scenario for Pause/Resume Plus type"
  name: pause_resume_plus
steps:
  - case_id: c37f522f5754a26096985d8962f63afe
    operation_id: ClusterService_CreateCluster
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "POST",
        "path": "/clusters",
        "path_params": {},
        "query_params": {},
        "headers": {},
        "body": {
          "displayName": "sce-pause-resume",
          "labels": {
            "tidb.cloud/project": "{projectId}"
          },
          "port": 4000,
          "regionId": "{regionId}",
          "rootPassword": "31415926",
          "tidbNodeSetting": {
            "nodeSpecKey": "8C16G",
            "tidbNodeGroups": [
              {
                "nodeCount": 1
              }
            ]
          },
          "tikvNodeSetting": {
            "nodeCount": 3,
            "nodeSpecKey": "8C64G",
            "storageSizeGi": 200,
            "storageType": "Plus"
          }
        },
        "body_params": {
          "regionId": "region_id",
          "projectId": "project_id"
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"CREATING\""
      }
    description: Create a 1 TiDB 3 TiKV dedicated cluster to fulfill the dependency for scaling out TiDB nodes.
    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: 1
  - case_id: c37f522f5754a26096985d8962f63aab
    operation_id: ClusterService_GetCluster
    case_type: supplimental_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/clusters/{clusterId}",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ACTIVE\" && body.tikvNodeSetting.storageType == \"Plus\""
      }
    description: Poll the cluster state until it becomes ACTIVE.
    max_retries: 60
    delay_after: 60
    step_type: defined
    name: wait_for_cluster_active
    save: |-
      {
        "placeholder": [
          {"key": "tidbnodegroup_1", "eval": "body.tidbNodeSetting.tidbNodeGroups[0].tidbNodeGroupId"}
        ]
      }
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2
  - case_id: wait_for_tidb_nodegroup_active
    operation_id: TidbNodeGroupService_GetTidbNodeGroup
    case_type: http
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/clusters/{clusterId}/tidbNodeGroups/{tidbNodeGroupId}",
        "path_params": {
          "clusterId": "cluster_1",
          "tidbNodeGroupId": "tidbnodegroup_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ACTIVE\" && size(body.endpoints.filter(e, e.connectionType == 'PUBLIC')) > 0 && body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].host != \"\""
      }
    description: Poll the TiDB Node Group until it becomes ACTIVE.
    max_retries: 120
    delay_after: 30
    step_type: generated
    name: wait_for_tidb_node_group_active
    save: |-
      {
        "placeholder": [
          {"key": "public_endpoint", "eval": "body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].host"},
          {"key": "port", "eval": "body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].port"}
        ]
      }
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2.1
  - case_id: set_public_endpoint
    operation_id: TidbNodeGroupService_UpdatePublicEndpointSetting
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "PATCH",
        "path": "/clusters/{clusterId}/tidbNodeGroups/{tidbNodeGroupId}/publicEndpointSetting",
        "path_params": {
          "clusterId": "cluster_1",
          "tidbNodeGroupId": "tidbnodegroup_1"
        },
        "query_params": {},
        "headers": {},
        "body": {
          "enabled": true,
          "ipAccessList": [
            {
              "cidrNotation": "0.0.0.0/0",
              "description": "all"
            }
          ]
        }
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.enabled == true"
      }
    description: Update the cluster to set the public endpoint.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: set_public_endpoint
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2.2
  - case_id: force_wait_dns
    operation_id: ClusterService_GetCluster
    case_type: supplimental_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/clusters/{clusterId}",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ABC\""
      }
    description: Poll the cluster state until it becomes ACTIVE.
    max_retries: 30
    delay_after: 10
    step_type: defined
    name: force_wait_dns
    save: null
    continue_on_unexpected: true
    stage: prepare
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2.3
  - case_id: connect_to_db_to_add_table
    operation_id: Mysqlsh_connection
    case_type: typical_positive
    request_type: cmd_mysqlsh
    request: |-
      {
        "name": "mysqlsh",
        "args": [
          "--sql",
          "mysql://root:31415926@{public_endpoint}:{port}/test",
          "--result-format=json",
          "-e",
          "CREATE TABLE IF NOT EXISTS tt (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), value INT); INSERT INTO tt (name, value) VALUES ('test1', 100), ('test2', 200);",
          "--quiet-start=2"
        ],
        "args_params": {
          "public_endpoint": "public_endpoint",
          "port": "port"
        }
      }
    expect: |-
      {
        "exit_code": 0,
        "cel": ""
      }
    description: Check the connection status of the cluster.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: check_password
    continue_on_unexpected: false
    save: null
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2.4
  - case_id: connect_to_db_to_check_data
    operation_id: Mysqlsh_connection
    case_type: typical_positive
    request_type: cmd_mysqlsh
    request: |-
      {
        "name": "mysqlsh",
        "args": [
          "--sql",
          "mysql://root:31415926@{public_endpoint}:{port}/test",
          "--result-format=json",
          "-e",
          "SELECT value FROM tt WHERE name = 'test1';",
          "--quiet-start=2"
        ],
        "args_params": {
          "public_endpoint": "public_endpoint",
          "port": "port"
        }
      }
    expect: |-
      {
        "exit_code": 0,
        "cel": "output.value == 100"
      }
    description: Check the connection status of the cluster.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: check_password
    continue_on_unexpected: false
    save: null
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 2.5
  - case_id: ClusterService_PauseCluster_Pause_a_cluster
    operation_id: ClusterService_PauseCluster
    case_type: user_defined
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "POST",
        "path": "/clusters/{clusterId}:pauseCluster",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.cluster.state == 'PAUSING'"
      }
    description: Pause a cluster using the ClusterService_PauseCluster operation.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: Pause a cluster
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 3
  - case_id: wait_for_cluster_paused_polling
    operation_id: ClusterService_GetCluster
    case_type: generated
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/clusters/{clusterId}",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"PAUSED\""
      }
    description: Polling to wait for the cluster to reach the PAUSED state.
    max_retries: 30
    delay_after: 60
    step_type: defined
    name: wait_for_cluster_paused
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 4
  - case_id: ClusterService_ResumeCluster_ResumeThisCluster
    operation_id: ClusterService_ResumeCluster
    case_type: user_defined
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "POST",
        "path": "/clusters/{clusterId}:resumeCluster",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.cluster.state == 'RESUMING'"
      }
    description: Resume a specified dedicated cluster by id.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: Resume Cluster
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 5
  - case_id: c37f522f5754a26096985d8962f63aab
    operation_id: ClusterService_GetCluster
    case_type: supplimental_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "GET",
        "path": "/clusters/{clusterId}",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "headers": {},
        "body": {}
      }
    expect: |-
      {
        "status_code": 200,
        "cel": "body.state == \"ACTIVE\""
      }
    description: Poll the cluster state until it becomes ACTIVE to proceed with the update operation.
    max_retries: 30
    delay_after: 60
    step_type: defined
    name: wait_for_cluster_active
    save: null
    continue_on_unexpected: false
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 6
  - case_id: connect_to_db_to_check_data
    operation_id: Mysqlsh_connection
    case_type: typical_positive
    request_type: cmd_mysqlsh
    request: |-
      {
        "name": "mysqlsh",
        "args": [
          "--sql",
          "mysql://root:31415926@{public_endpoint}:{port}/test",
          "--result-format=json",
          "-e",
          "SELECT value FROM tt WHERE name = 'test2';",
          "--quiet-start=2"
        ],
        "args_params": {
          "public_endpoint": "public_endpoint",
          "port": "port"
        }
      }
    expect: |-
      {
        "exit_code": 0,
        "cel": "output.value == 200"
      }
    description: Check the connection status of the cluster.
    max_retries: 0
    delay_after: 0
    step_type: defined
    name: check_password
    continue_on_unexpected: false
    save: null
    stage: execute
    meta: "{}"
    generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
    order: 6.5
  - case_id: cleanup_cluster_1
    operation_id: ClusterService_DeleteCluster
    case_type: typical_positive
    request_type: http
    request: |-
      {
        "auth": {
          "auth_type": "digest",
          "content": {"private_key": "placeholder","public_key": "placeholder"}
        },
        "method": "DELETE",
        "path": "/clusters/{clusterId}",
        "path_params": {
          "clusterId": "cluster_1"
        },
        "query_params": {},
        "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: 7
