scenario:
  id: d15ca4a9-ea8d-4f99-a27b-65df4b26597b
  context:
    auth:
      type: digest
    base_path: /v1beta2
    host: null
  description: ng_byoc_manual_backup_restore
  name: ng_byoc_manual_backup_restore
steps:
- operation_id: TidbService_CreateTidb
  request_type: http
  request: |-
    {
      "method": "POST",
      "path": "/tidbs",
      "headers": {},
      "query_params": {},
      "body": {
        "displayName": "sce-ng-byoc-manual-backup-restore",
        "regionId": "{regionId}",
        "minRcu": "5000",
        "maxRcu": "6000",
        "servicePlan": "BYOC",
        "cloudProvider": "{cloud_provider}",
        "resourcePoolId": "{resource_pool_id}"
      },
      "body_params": {
        "regionId": "region_id",
        "cloud_provider": "cloud_provider",
        "resource_pool_id": "resource_pool_id"
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": ""
    }
  save: |-
    {
      "placeholder": [
        {
          "key": "cluster_1",
          "eval": "body.tidbId"
        }
      ]
    }
  description: ''
  max_retries: 0
  delay_after: 0
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 0
- operation_id: PrivateEndpointConnectionService_GetPrivateLinkService
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}/privateLinkService",
      "headers": {},
      "query_params": {},
      "body": {},
      "path_params": {
        "tidbId": "cluster_1"
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "body.state == 'ACTIVE'"
    }
  save: |-
    {
      "placeholder": [
        {
          "key": "private_link_service_1",
          "eval": "body.serviceName"
        }
      ]
    }
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 0.5
- operation_id: TidbService_GetTidb
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_1"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "body.state == 'ACTIVE'"
    }
  save: null
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 1
- operation_id: TidbService_ResetRootPassword
  request_type: http
  request: |-
    {
      "method": "POST",
      "path": "/tidbs/{tidbId}:resetRootPassword",
      "headers": {},
      "query_params": {},
      "body": {
        "rootPassword": "pi31415926"
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_1"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": ""
    }
  save: null
  description: ''
  max_retries: 5
  delay_after: 60
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 1.5
- operation_id: PublicConnectionSettingService_UpdatePublicConnectionSetting
  request_type: http
  request: |-
    {
      "method": "PATCH",
      "path": "/tidbs/{tidbId}/publicConnectionSetting",
      "headers": {},
      "query_params": {},
      "body": {
        "enabled": true,
        "ipAccessList": [
          {
            "cidrNotation": "0.0.0.0/0",
            "description": "Allow all IPs"
          }
        ]
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "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: 2
- operation_id: ClusterService_GetCluster
  generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
  order: 3
  case_type: supplimental_positive
  request_type: http
  request: |-
    {
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "method": "GET",
      "path": "/tidbs/{tidbId}",
      "path_params": {
        "tidbId": "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: 40
  delay_after: 10
  step_type: defined
  name: force_wait_dns
  save: null
  continue_on_unexpected: true
  stage: prepare
  meta: '{}'
- operation_id: TidbService_GetTidb
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_1"
      }
    }
  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 != \"\""
    }
  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"
        }
      ]
    }
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 3.5
- operation_id: Mysqlsh_connection
  case_type: typical_positive
  request_type: cmd_mysqlsh
  request: |-
    {
      "name": "mysqlsh",
      "args": [
        "--sql",
        "mysql://root:pi31415926@{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: 4
- operation_id: Mysqlsh_connection
  case_type: typical_positive
  request_type: cmd_mysqlsh
  request: |-
    {
      "name": "mysqlsh",
      "args": [
        "--sql",
        "mysql://root:pi31415926@{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: 5
- operation_id: TidbService_CreateTidbBackup
  request_type: http
  request: |-
    {
      "method": "POST",
      "path": "/tidbs/{tidbId}/backups",
      "headers": {},
      "query_params": {},
      "body": {
        "name": "manual-backup-test"
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_1"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": ""
    }
  save: |-
    {
      "placeholder": [
        {
          "key": "backup_1",
          "eval": "body.backupId"
        }
      ]
    }
  description: Create a manual backup
  max_retries: 0
  delay_after: 0
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 6
- operation_id: TidbService_ListTidbBackups
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}/backups",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_1"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "has(body.backups) && size(body.backups) > 0 && body.backups[0].id != ''"
    }
  save: null
  description: Poll for backup completion
  max_retries: 30
  delay_after: 60
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 7
- operation_id: TidbService_RestoreTidb
  request_type: http
  request: |-
    {
      "method": "POST",
      "path": "/tidbs:restore",
      "headers": {},
      "query_params": {},
      "body": {
        "tidb": {
          "displayName": "ng-byoc-manual-restore-cluster",
          "regionId": "{regionId}",
          "minRcu": "5000",
          "maxRcu": "5500",
          "servicePlan": "BYOC",
          "resourcePoolId": "{resource_pool_id}"
        },
        "sourceTidbId": "{tidbId}",
        "restoreMode": "SNAPSHOT",
        "backupId": "{backupId}"
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "body_params": {
        "tidbId": "cluster_1",
        "backupId": "backup_1",
        "regionId": "region_id",
        "resource_pool_id": "resource_pool_id"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": ""
    }
  save: |-
    {
      "placeholder": [
        {
          "key": "cluster_2",
          "eval": "body.tidb.tidbId"
        }
      ]
    }
  description: ''
  max_retries: 0
  delay_after: 0
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 8
- operation_id: TidbService_RestoreStatus
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}:restoreStatus",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_2"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "body.state == 'SUCCEEDED'"
    }
  save: null
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 9
- operation_id: TidbService_GetTidb
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_2"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "body.state == 'ACTIVE' && body.minRcu == '5000' && body.maxRcu == '5500'"
    }
  save: null
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 10
- operation_id: PublicConnectionSettingService_UpdatePublicConnectionSetting
  request_type: http
  request: |-
    {
      "method": "PATCH",
      "path": "/tidbs/{tidbId}/publicConnectionSetting",
      "headers": {},
      "query_params": {},
      "body": {
        "enabled": true,
        "ipAccessList": [
          {
            "cidrNotation": "0.0.0.0/0",
            "description": "Allow all IPs"
          }
        ]
      },
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_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: 11
- operation_id: ClusterService_GetCluster
  generation_id: 09198df8-3eef-4d82-a5a4-31eb9b0db7de
  order: 12
  case_type: supplimental_positive
  request_type: http
  request: |-
    {
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "method": "GET",
      "path": "/tidbs/{tidbId}",
      "path_params": {
        "tidbId": "cluster_2"
      },
      "query_params": {},
      "headers": {},
      "body": {}
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "body.state == \"ABC\""
    }
  description: Poll the cluster state until it becomes ACTIVE.
  max_retries: 40
  delay_after: 10
  step_type: defined
  name: force_wait_dns
  save: null
  continue_on_unexpected: true
  stage: prepare
  meta: '{}'
- operation_id: TidbService_GetTidb
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/tidbs/{tidbId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_2"
      }
    }
  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 != \"\""
    }
  save: |-
    {
      "placeholder": [
        {
          "key": "public_endpoint_2",
          "eval": "body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].host"
        },
        {
          "key": "port_2",
          "eval": "body.endpoints.filter(e, e.connectionType == 'PUBLIC')[0].port"
        }
      ]
    }
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 13
- operation_id: Mysqlsh_connection
  case_type: typical_positive
  request_type: cmd_mysqlsh
  request: |-
    {
      "name": "mysqlsh",
      "args": [
        "--sql",
        "mysql://root:pi31415926@{public_endpoint}:{port}/test",
        "--result-format=json",
        "-e",
        "SELECT value FROM tt WHERE name = 'test1';",
        "--quiet-start=2"
      ],
      "args_params": {
        "public_endpoint": "public_endpoint_2",
        "port": "port_2"
      }
    }
  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: 14
- operation_id: TidbService_DeleteTidbBackup
  request_type: http
  request: |-
    {
      "method": "DELETE",
      "path": "/tidbs/{tidbId}/backups/{backupId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_1",
        "backupId": "backup_1"
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": ""
    }
  save: null
  description: Delete the manual backup
  max_retries: 0
  delay_after: 0
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 15
- operation_id: TidbService_DeleteTidb
  request_type: http
  request: |-
    {
      "method": "DELETE",
      "path": "/tidbs/{tidbId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "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: 16
- operation_id: BackupService_ListDeletedTidbs
  request_type: http
  request: |-
    {
      "method": "GET",
      "path": "/backups:listDeletedTidbs",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      }
    }
  expect: |-
    {
      "status_code": 200,
      "cel": "body.totalSize > 0"
    }
  save: null
  description: ''
  max_retries: 120
  delay_after: 30
  name: ''
  continue_on_unexpected: false
  stage: ''
  meta: '{}'
  generation_id: ''
  order: 17
- operation_id: TidbService_DeleteRestoreTidb
  request_type: http
  request: |-
    {
      "method": "DELETE",
      "path": "/tidbs/{tidbId}",
      "headers": {},
      "query_params": {},
      "body": {},
      "auth": {
        "auth_type": "digest",
        "content": {
          "private_key": "placeholder",
          "public_key": "placeholder"
        }
      },
      "path_params": {
        "tidbId": "cluster_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: 18
