@@ -2042,6 +2042,25 @@ func testScheduler(t *testing.T) {
20422042 })
20432043 testTableCompletionTimes (t , t1uuid , v1uuid )
20442044 })
2045+ t .Run ("cancel migrations by context" , func (t * testing.T ) {
2046+ // Submit two migrations with the same explicit context, both postponed so they stay running.
2047+ t1uuid = testOnlineDDLStatement (t , & testOnlineDDLStatementParams {ddlStatement : trivialAlterT1Statement , ddlStrategy : ddlStrategy + " --allow-concurrent --postpone-completion" , executeStrategy : "vtctl" , migrationContext : "ctx-cancel-by-context" , skipWait : true })
2048+ t2uuid = testOnlineDDLStatement (t , & testOnlineDDLStatementParams {ddlStatement : trivialAlterT2Statement , ddlStrategy : ddlStrategy + " --allow-concurrent --postpone-completion" , executeStrategy : "vtctl" , migrationContext : "ctx-cancel-by-context" , skipWait : true })
2049+ onlineddl .WaitForMigrationStatus (t , & vtParams , shards , t1uuid , normalWaitTime , schema .OnlineDDLStatusRunning )
2050+ onlineddl .WaitForMigrationStatus (t , & vtParams , shards , t2uuid , normalWaitTime , schema .OnlineDDLStatusRunning )
2051+
2052+ // A non-matching context cancels nothing.
2053+ onlineddl .CheckCancelContextMigrations (t , & vtParams , "ctx-cancel-by-context-other" , 0 )
2054+ onlineddl .CheckMigrationStatus (t , & vtParams , shards , t1uuid , schema .OnlineDDLStatusRunning )
2055+ onlineddl .CheckMigrationStatus (t , & vtParams , shards , t2uuid , schema .OnlineDDLStatusRunning )
2056+
2057+ // Cancel by context: both migrations must be cancelled.
2058+ onlineddl .CheckCancelContextMigrations (t , & vtParams , "ctx-cancel-by-context" , 2 )
2059+ onlineddl .WaitForMigrationStatus (t , & vtParams , shards , t1uuid , normalWaitTime , schema .OnlineDDLStatusCancelled , schema .OnlineDDLStatusFailed )
2060+ onlineddl .WaitForMigrationStatus (t , & vtParams , shards , t2uuid , normalWaitTime , schema .OnlineDDLStatusCancelled , schema .OnlineDDLStatusFailed )
2061+ onlineddl .CheckMigrationStatus (t , & vtParams , shards , t1uuid , schema .OnlineDDLStatusCancelled )
2062+ onlineddl .CheckMigrationStatus (t , & vtParams , shards , t2uuid , schema .OnlineDDLStatusCancelled )
2063+ })
20452064}
20462065
20472066func testSingleton (t * testing.T ) {
0 commit comments