mirror of https://github.com/kubernetes/kops.git
Merge pull request #16292 from justinsb/aws_tests_refactor
refactor: Introduce runTests helper method into aws tests
This commit is contained in:
commit
ffbcc5217a
|
|
@ -94,18 +94,7 @@ func TestSharedEgressOnlyInternetGatewayDoesNotRename(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
eigw1 := allTasks["eigw1"].(*EgressOnlyInternetGateway)
|
eigw1 := allTasks["eigw1"].(*EgressOnlyInternetGateway)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(eigw1.ID) == "" {
|
if fi.ValueOf(eigw1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
@ -144,3 +133,21 @@ func TestSharedEgressOnlyInternetGatewayDoesNotRename(t *testing.T) {
|
||||||
checkNoChanges(t, ctx, cloud, allTasks)
|
checkNoChanges(t, ctx, cloud, allTasks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runTasks(t *testing.T, cloud awsup.AWSCloud, allTasks map[string]fi.CloudupTask) {
|
||||||
|
t.Helper()
|
||||||
|
ctx := context.TODO()
|
||||||
|
|
||||||
|
target := &awsup.AWSAPITarget{
|
||||||
|
Cloud: cloud,
|
||||||
|
}
|
||||||
|
|
||||||
|
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error building context: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
||||||
|
t.Fatalf("unexpected error during Run: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,18 +78,7 @@ func TestElasticIPCreate(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
eip1 := allTasks["eip1"].(*ElasticIP)
|
eip1 := allTasks["eip1"].(*ElasticIP)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(eip1.ID) == "" {
|
if fi.ValueOf(eip1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
|
||||||
|
|
@ -110,18 +110,7 @@ func TestSharedInternetGatewayDoesNotRename(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
igw1 := allTasks["igw1"].(*InternetGateway)
|
igw1 := allTasks["igw1"].(*InternetGateway)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(igw1.ID) == "" {
|
if fi.ValueOf(igw1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
|
||||||
|
|
@ -137,18 +137,7 @@ func TestSecurityGroupCreate(t *testing.T) {
|
||||||
sg1 := allTasks["sg1"].(*SecurityGroup)
|
sg1 := allTasks["sg1"].(*SecurityGroup)
|
||||||
vpc1 := allTasks["vpc1"].(*VPC)
|
vpc1 := allTasks["vpc1"].(*VPC)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(sg1.ID) == "" {
|
if fi.ValueOf(sg1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
|
||||||
|
|
@ -98,18 +98,7 @@ func TestSubnetCreate(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
subnet1 := allTasks["subnet1"].(*Subnet)
|
subnet1 := allTasks["subnet1"].(*Subnet)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(subnet1.ID) == "" {
|
if fi.ValueOf(subnet1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
@ -190,18 +179,7 @@ func TestSubnetCreateIPv6(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
subnet1 := allTasks["subnet1"].(*Subnet)
|
subnet1 := allTasks["subnet1"].(*Subnet)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(subnet1.ID) == "" {
|
if fi.ValueOf(subnet1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
@ -290,18 +268,7 @@ func TestSubnetCreateIPv6NetNum(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
subnet1 := allTasks["subnet1"].(*Subnet)
|
subnet1 := allTasks["subnet1"].(*Subnet)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(subnet1.ID) == "" {
|
if fi.ValueOf(subnet1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
@ -424,18 +391,7 @@ func TestSharedSubnetCreateDoesNotCreateNew(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
subnet1 := allTasks["subnet1"].(*Subnet)
|
subnet1 := allTasks["subnet1"].(*Subnet)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(subnet1.ID) == "" {
|
if fi.ValueOf(subnet1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
|
||||||
|
|
@ -52,18 +52,7 @@ func TestVPCCreate(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
vpc1 := allTasks["vpc1"].(*VPC)
|
vpc1 := allTasks["vpc1"].(*VPC)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(vpc1.ID) == "" {
|
if fi.ValueOf(vpc1.ID) == "" {
|
||||||
t.Fatalf("ID not set after create")
|
t.Fatalf("ID not set after create")
|
||||||
|
|
@ -134,8 +123,6 @@ func Test4758(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSharedVPCAdditionalCIDR(t *testing.T) {
|
func TestSharedVPCAdditionalCIDR(t *testing.T) {
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
cloud := awsup.BuildMockAWSCloud("us-east-1", "abc")
|
cloud := awsup.BuildMockAWSCloud("us-east-1", "abc")
|
||||||
c := &mockec2.MockEC2{}
|
c := &mockec2.MockEC2{}
|
||||||
c.CreateVpcWithId(&ec2.CreateVpcInput{
|
c.CreateVpcWithId(&ec2.CreateVpcInput{
|
||||||
|
|
@ -177,18 +164,7 @@ func TestSharedVPCAdditionalCIDR(t *testing.T) {
|
||||||
allTasks := buildTasks()
|
allTasks := buildTasks()
|
||||||
vpc1 := allTasks["vpc-1"].(*VPC)
|
vpc1 := allTasks["vpc-1"].(*VPC)
|
||||||
|
|
||||||
target := &awsup.AWSAPITarget{
|
runTasks(t, cloud, allTasks)
|
||||||
Cloud: cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
context, err := fi.NewCloudupContext(ctx, target, nil, cloud, nil, nil, nil, allTasks)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error building context: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := context.RunTasks(testRunTasksOptions); err != nil {
|
|
||||||
t.Fatalf("unexpected error during Run: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fi.ValueOf(vpc1.ID) == "" {
|
if fi.ValueOf(vpc1.ID) == "" {
|
||||||
t.Fatalf("ID not set")
|
t.Fatalf("ID not set")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue