sigs.k8s.io/cluster-api-provider-aws@v1.5.5/test/e2e/suites/managed/machine_pool_helpers.go (about)

     1  //go:build e2e
     2  // +build e2e
     3  
     4  /*
     5  Copyright 2020 The Kubernetes Authors.
     6  
     7  Licensed under the Apache License, Version 2.0 (the "License");
     8  you may not use this file except in compliance with the License.
     9  You may obtain a copy of the License at
    10  
    11  	http://www.apache.org/licenses/LICENSE-2.0
    12  
    13  Unless required by applicable law or agreed to in writing, software
    14  distributed under the License is distributed on an "AS IS" BASIS,
    15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16  See the License for the specific language governing permissions and
    17  limitations under the License.
    18  */
    19  
    20  package managed
    21  
    22  import (
    23  	"context"
    24  
    25  	. "github.com/onsi/gomega"
    26  	apierrors "k8s.io/apimachinery/pkg/api/errors"
    27  	"sigs.k8s.io/controller-runtime/pkg/client"
    28  
    29  	"sigs.k8s.io/cluster-api-provider-aws/test/e2e/shared"
    30  	expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
    31  	"sigs.k8s.io/cluster-api/test/framework"
    32  )
    33  
    34  type deleteMachinePoolInput struct {
    35  	MachinePool *expclusterv1.MachinePool
    36  	Deleter     framework.Deleter
    37  }
    38  
    39  func deleteMachinePool(ctx context.Context, input deleteMachinePoolInput) {
    40  	shared.Byf("Deleting machine pool %s", input.MachinePool.Name)
    41  	Expect(input.Deleter.Delete(ctx, input.MachinePool)).To(Succeed())
    42  }
    43  
    44  type waitForMachinePoolDeletedInput struct {
    45  	MachinePool *expclusterv1.MachinePool
    46  	Getter      framework.Getter
    47  }
    48  
    49  func waitForMachinePoolDeleted(ctx context.Context, input waitForMachinePoolDeletedInput, intervals ...interface{}) {
    50  	shared.Byf("Waiting for machine pool %s to be deleted", input.MachinePool.GetName())
    51  	Eventually(func() bool {
    52  		mp := &expclusterv1.MachinePool{}
    53  		key := client.ObjectKey{
    54  			Namespace: input.MachinePool.GetNamespace(),
    55  			Name:      input.MachinePool.GetName(),
    56  		}
    57  		err := input.Getter.Get(ctx, key, mp)
    58  		notFound := apierrors.IsNotFound(err)
    59  		return notFound
    60  	}, intervals...).Should(BeTrue())
    61  }