add_test(NAME icd-drop-table-1 COMMAND ddbshtest -c "drop table if exists icd1")
add_test(NAME icd-drop-table-2 COMMAND ddbshtest -c "drop table if exists icd2")
add_test(NAME icd-drop-table-3 COMMAND ddbshtest -c "drop table if exists icd3")
add_test(NAME icd-drop-table-4 COMMAND ddbshtest -c "drop table if exists icd4")
add_test(NAME icd-drop-table-5 COMMAND ddbshtest -c "drop table if exists icd5")
add_test(NAME icd-drop-table-6 COMMAND ddbshtest -c "drop table if exists icd6")
add_test(NAME icd-drop-table-7 COMMAND ddbshtest -c "drop table if exists icd7")
add_test(NAME icd-drop-table-8 COMMAND ddbshtest -c "drop table if exists icd8")
add_test(NAME icd-drop-table-9 COMMAND ddbshtest -c "drop table if exists icdthroughput")
add_test(NAME icd-drop-table-10 COMMAND ddbshtest -c "drop table if exists icdwarmthroughput0")
add_test(NAME icd-drop-table-11 COMMAND ddbshtest -c "drop table if exists icdwarmthroughput1")

add_test(NAME icd-create-table-1
         COMMAND ddbshtest -c "create table icd1 ( pk number ) primary key ( pk hash ) billing mode on demand")
add_test(NAME icd-create-table-2
         COMMAND ddbshtest -c "create table icd2 ( pk number, rk number ) primary key ( pk hash, rk range ) billing mode on demand")

add_test( NAME icd-create-table-3
          COMMAND ddbshtest -c "create table icd3 ( pk number, rk number, k1 number, k2 number ) \
                             primary key (pk hash, rk range) \
                             billing mode on demand \
                             gsi ( gsi1 on ( k1 hash, k2 range ) \
                             projecting include (k3) \
                             billing mode on demand )")

add_test( NAME icd-create-table-4
          COMMAND ddbshtest -c "create table icd4 ( pk number, rk number, k1 number, k2 number, k3 number ) \
                             primary key (pk hash, rk range) \
                             billing mode on demand \
                             gsi ( gsi1 on ( k1 hash, k2 range ) \
                             projecting include (k3) \
                             billing mode on demand, \
                             gsi2 on (k3 hash) projecting keys only \
                             billing mode on demand)")

add_test( NAME icd-create-table-5
          COMMAND ddbshtest -c "create table icddpe ( pk number ) \
                             primary key (pk hash ) \
                             billing mode on demand deletion protection enabled")

add_test( NAME icd-create-table-6
          COMMAND ddbshtest -c "alter table icddpe set deletion protection disabled")

add_test( NAME icd-create-table-7
          COMMAND ddbshtest -c "drop table icddpe")

add_test( NAME icd-create-table-8
          COMMAND ddbshtest -c "create table icddpd ( pk number ) \
                             primary key (pk hash) \
                             billing mode on demand deletion protection disabled")

add_test( NAME icd-create-table-9
          COMMAND ddbshtest -c "drop table icddpd")

# create table will, by default, wait and use on-demand
add_test( NAME icd-create-table-10
          COMMAND ddbshtest -c "create table icdthroughput ( pk number, a number ) primary key (pk hash) \
          gsi (gsipka on ( a hash ) projecting all)" )

add_test( NAME icd-create-table-11
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-11 PROPERTY FAIL_REGULAR_EXPRESSION "On Demand Throughput:")

# The alters below mutate the table's billing mode / on-demand throughput and
# GSI throughput. DynamoDB applies these asynchronously, so each mutation is
# followed by a bounded poll (ddbsh-wait table-settled) that waits until the
# table and all its GSIs are ACTIVE again before the next describe/alter. This
# replaces the original fixed `sleep`s, which were racy against real DynamoDB
# (the non-deterministic Bucket A flake). See discussion 2026-08-22-P2-01 (D8).

add_test( NAME icd-create-table-12
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput ( 10 rcu, 20 wcu )")

add_test( NAME icd-create-table-12a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-13
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-13 PROPERTY PASS_REGULAR_EXPRESSION "On Demand Throughput\: [(]10 RCU, 20 WCU[)]")

add_test( NAME icd-create-table-14
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput ( 10 rcu, 200 wcu )" )

add_test( NAME icd-create-table-14a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-15
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-15 PROPERTY PASS_REGULAR_EXPRESSION "On Demand Throughput\: [(]10 RCU, 200 WCU[)]")

add_test( NAME icd-create-table-16
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput ( 10 wcu, 200 rcu )" )

add_test( NAME icd-create-table-16a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-17
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-17 PROPERTY PASS_REGULAR_EXPRESSION "On Demand Throughput\: [(]200 RCU, 10 WCU[)]")

add_test( NAME icd-create-table-18
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput (-1 rcu, -1 wcu)")

# for a small period of time, DynamoDB still reports On Demand Throughput -1,-1
# during the transition; poll until the table has settled (was: sleep 5).
add_test( NAME icd-create-table-18a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-19
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-19 PROPERTY FAIL_REGULAR_EXPRESSION "On Demand Throughput")

add_test( NAME icd-create-table-20
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput ( 10 wcu, 200 rcu )" )

add_test( NAME icd-create-table-20a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-21
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-21 PROPERTY PASS_REGULAR_EXPRESSION "On Demand Throughput\: [(]200 RCU, 10 WCU[)]")

add_test( NAME icd-create-table-22
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput unlimited")

# for a small period of time, DynamoDB still reports On Demand Throughput -1,-1
# during the transition; poll until the table has settled (was: sleep 5).
add_test( NAME icd-create-table-22a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-23
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-23 PROPERTY FAIL_REGULAR_EXPRESSION "On Demand Throughput")

add_test( NAME icd-create-table-24
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput ( 10 rcu, -1 wcu )" )

add_test( NAME icd-create-table-24a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-25
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-25 PROPERTY PASS_REGULAR_EXPRESSION "On Demand Throughput\: [(]10 RCU, -1 WCU[)]")

add_test( NAME icd-create-table-26
          COMMAND ddbshtest -c "alter table icdthroughput set billing mode on demand throughput ( 10 wcu, -1 rcu )" )

add_test( NAME icd-create-table-26a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-27
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-27 PROPERTY PASS_REGULAR_EXPRESSION "On Demand Throughput\: [(]-1 RCU, 10 WCU[)]")

# gsi throughput tests

add_test( NAME icd-create-table-28
          COMMAND ddbshtest -c "alter table icdthroughput update gsi (gsipka set billing mode on demand throughput unlimited )")

# wait for the GSI update to finish before issuing the next GSI update, else
# DynamoDB rejects it with ResourceInUseException (index still updating).
add_test( NAME icd-create-table-28a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-29
          COMMAND ddbshtest -c "alter table icdthroughput update gsi (gsipka set billing mode on demand throughput (200 rcu, 300 wcu))")

add_test( NAME icd-create-table-29a COMMAND ${GOLDEN_DIR}/ddbsh-wait table-settled icdthroughput)

add_test( NAME icd-create-table-30
          COMMAND ddbshtest -c "describe icdthroughput" )
set_property(TEST icd-create-table-30 PROPERTY PASS_REGULAR_EXPRESSION "On Demand [(]mirrors table[)], Throughput [(]200 RCU, 300 WCU[)],")

add_test( NAME icd-create-table-31
          COMMAND ddbshtest -c "create table icdwarmthroughput0 ( a number ) \
                               primary key (a hash) \
                               billing mode on demand warm throughput ( 13000 rcu, 4000 wcu )" )

add_test( NAME icd-create-table-32
          COMMAND ddbshtest -c "describe icdwarmthroughput0" )
set_property(TEST icd-create-table-32 PROPERTY PASS_REGULAR_EXPRESSION "13000 RCU, 4000 WCU, Status ACTIVE")

add_test( NAME icd-create-table-33
          COMMAND ddbshtest -c "alter table icdwarmthroughput0 set warm throughput (4000 wcu, 14000 rcu)")

# A warm-throughput update can finish within a second, so right after the ALTER
# the table's Warm Throughput line shows either the old values with
# Status UPDATING or the new values with Status ACTIVE (the original expected
# UPDATING only). 34 accepts either state on the table's line (the leading
# newline excludes the GSI lines, which carry ", Warm Throughput: (" mid-line);
# 34a waits until the update has finished, so 35 does not alter a table whose
# update is still running; 34b proves the ALTER took effect. 36 still covers
# how Status UPDATING renders. No .exp file changes. Human-approved: D-P10-19
# (discussion 2026-11-21-P10-01, Human Session 2026-11-22T05:35Z).
add_test( NAME icd-create-table-34
          COMMAND ddbshtest -c "describe icdwarmthroughput0" )
set_property(TEST icd-create-table-34 PROPERTY PASS_REGULAR_EXPRESSION "\nWarm Throughput: [(][0-9]+ RCU, [0-9]+ WCU, Status (UPDATING|ACTIVE)[)]")

add_test( NAME icd-create-table-34a COMMAND ${GOLDEN_DIR}/ddbsh-wait warm-throughput-active icdwarmthroughput0)

add_test( NAME icd-create-table-34b
          COMMAND ddbshtest -c "describe icdwarmthroughput0" )
set_property(TEST icd-create-table-34b PROPERTY PASS_REGULAR_EXPRESSION "\nWarm Throughput: [(]14000 RCU, 4000 WCU, Status ACTIVE[)]")

add_test( NAME icd-create-table-35
          COMMAND ddbshtest -c "alter table icdwarmthroughput0 (a number) create gsi icdwt0gsi0 on (a hash) projecting all \
                  warm throughput (12000 rcu, 4000 wcu)")

add_test( NAME icd-create-table-36
          COMMAND ddbshtest -c "describe icdwarmthroughput0" )
set_property(TEST icd-create-table-36 PROPERTY PASS_REGULAR_EXPRESSION "12000 RCU, 4000 WCU, Status UPDATING")

add_test( NAME icd-create-table-38
          COMMAND ddbshtest -c "create table icdwarmthroughput1 ( a number, b number ) \
                               primary key (a hash) \
                               billing mode on demand warm throughput ( 13000 rcu, 4000 wcu ) \
                               GSI (firstgsi on (b hash) projecting all warm throughput (13001 rcu, 4001 wcu))" )

add_test( NAME icd-create-table-39
          COMMAND ddbshtest -c "describe icdwarmthroughput1" )
set_property(TEST icd-create-table-39 PROPERTY PASS_REGULAR_EXPRESSION "13000 RCU, 4000 WCU, Status ACTIVE")

add_test( NAME icd-create-table-40
          COMMAND ddbshtest -c "describe icdwarmthroughput1" )
set_property(TEST icd-create-table-39 PROPERTY PASS_REGULAR_EXPRESSION "13001 RCU, 4001 WCU, Status ACTIVE")


