| 1440 | } |
| 1441 | |
| 1442 | func (t *alreadyDetachedTest) Validate(ctx context.Context) (*validation.ValidationCluster, error) { |
| 1443 | t.mutex.Lock() |
| 1444 | defer t.mutex.Unlock() |
| 1445 | |
| 1446 | t.numValidations++ |
| 1447 | switch t.numValidations { |
| 1448 | case 1, 2, 3: |
| 1449 | assert.Equal(t.t, t.numValidations, len(t.detached), "numnber of detached instances") |
| 1450 | case 4: |
| 1451 | t.mutex.Unlock() |
| 1452 | time.Sleep(postTerminationValidationDelay) |
| 1453 | t.mutex.Lock() |
| 1454 | assert.Equal(t.t, 1, t.terminationRequestsLeft, "terminations left") |
| 1455 | case 5: |
| 1456 | assert.Equal(t.t, 0, t.terminationRequestsLeft, "terminations left") |
| 1457 | case 6: |
| 1458 | t.t.Error("unexpected sixth call to Validate") |
| 1459 | } |
| 1460 | |
| 1461 | return &validation.ValidationCluster{}, nil |
| 1462 | } |
| 1463 | |
| 1464 | func (t *alreadyDetachedTest) TerminateInstances(ctx context.Context, input *ec2.TerminateInstancesInput, optFns ...func(*ec2.Options)) (*ec2.TerminateInstancesOutput, error) { |
| 1465 | if input.DryRun != nil && *input.DryRun { |