f91df3be3d
- Idempotency: verify RequestedBy matches caller to prevent cross-user key reuse - Crash recovery: persist ExecutionJob (launching) before AWX Launch, update to running after - Terminal state: finish ExecutionJob on success/cancel/failure; failTask accepts canceling - Reservation TTL: filter expired reservations in quota aggregation - Ansible heredoc: use <<'EOF' to prevent shell expansion of secrets; escape single quotes - Validation: align Go resource ranges with playbook (mem 1024-4096, storage 10-100) - Version whitelist: only allow 8.0, pass mysql_version to AWX extra_vars; playbook selects package via map Relates-to: #97
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package service
|
|
|
|
import "testing"
|
|
|
|
func TestValidateDeliveryInput(t *testing.T) {
|
|
valid := MySQLDeliveryInput{BusinessLineID: 1, TargetID: 1, Namespace: "team-a", InstanceName: "mysql-01", CPUMilli: 500, MemoryMi: 1024, StorageGi: 10}
|
|
if err := validateDeliveryInput(valid); err != nil {
|
|
t.Fatalf("valid input rejected: %v", err)
|
|
}
|
|
withVersion := valid
|
|
withVersion.MySQLVersion = "8.0"
|
|
if err := validateDeliveryInput(withVersion); err != nil {
|
|
t.Fatalf("valid input with version 8.0 rejected: %v", err)
|
|
}
|
|
for name, input := range map[string]MySQLDeliveryInput{
|
|
"uppercase namespace": valid,
|
|
"bad instance": valid,
|
|
"too little memory": valid,
|
|
"too much memory": valid,
|
|
"too little storage": valid,
|
|
"too much storage": valid,
|
|
"unsupported version": valid,
|
|
} {
|
|
switch name {
|
|
case "uppercase namespace":
|
|
input.Namespace = "Team-A"
|
|
case "bad instance":
|
|
input.InstanceName = "mysql_01"
|
|
case "too little memory":
|
|
input.MemoryMi = 512
|
|
case "too much memory":
|
|
input.MemoryMi = 8192
|
|
case "too little storage":
|
|
input.StorageGi = 5
|
|
case "too much storage":
|
|
input.StorageGi = 200
|
|
case "unsupported version":
|
|
input.MySQLVersion = "5.7"
|
|
}
|
|
if err := validateDeliveryInput(input); err == nil {
|
|
t.Errorf("%s was accepted", name)
|
|
}
|
|
}
|
|
}
|