Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add runtime objects per step in e2e #782

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/create-cluster-with-npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
armcontainerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
"github.com/microsoft/retina/test/e2e/framework/types"
)

var (
Expand Down Expand Up @@ -37,15 +38,15 @@ type CreateNPMCluster struct {
ServiceCidr string
}

func (c *CreateNPMCluster) Prevalidate() error {
func (c *CreateNPMCluster) PreRun() error {
return nil
}

func (c *CreateNPMCluster) Stop() error {
return nil
}

func (c *CreateNPMCluster) Run() error {
func (c *CreateNPMCluster) Run(_ *types.RuntimeObjects) error {
// Start with default cluster template
npmCluster := GetStarterClusterTemplate(c.Location)

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/create-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
armcontainerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
"github.com/microsoft/retina/test/e2e/framework/types"
)

const (
Expand All @@ -25,7 +26,7 @@ type CreateCluster struct {
ClusterName string
}

func (c *CreateCluster) Run() error {
func (c *CreateCluster) Run(ro *types.RuntimeObjects) error {
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
return fmt.Errorf("failed to obtain a credential: %w", err)
Expand Down Expand Up @@ -106,7 +107,7 @@ func GetStarterClusterTemplate(location string) armcontainerservice.ManagedClust
}
}

func (c *CreateCluster) Prevalidate() error {
func (c *CreateCluster) PreRun() error {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/create-rg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/microsoft/retina/test/e2e/framework/types"
)

type CreateResourceGroup struct {
Expand All @@ -16,7 +17,7 @@ type CreateResourceGroup struct {
Location string
}

func (c *CreateResourceGroup) Run() error {
func (c *CreateResourceGroup) Run(_ *types.RuntimeObjects) error {
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
return fmt.Errorf("failed to obtain a credential: %w", err)
Expand All @@ -39,7 +40,7 @@ func (c *CreateResourceGroup) Run() error {
return nil
}

func (c *CreateResourceGroup) Prevalidate() error {
func (c *CreateResourceGroup) PreRun() error {
return nil
}

Expand Down
9 changes: 5 additions & 4 deletions test/e2e/framework/azure/create-vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v5"
"github.com/microsoft/retina/test/e2e/framework/types"
)

const FlowTimeoutInMinutes = 10
Expand All @@ -20,7 +21,7 @@ type CreateVNet struct {
VnetAddressSpace string
}

func (c *CreateVNet) Run() error {
func (c *CreateVNet) Run(_ *types.RuntimeObjects) error {
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
return fmt.Errorf("failed to obtain a credential: %w", err)
Expand Down Expand Up @@ -55,7 +56,7 @@ func (c *CreateVNet) Run() error {
return nil
}

func (c *CreateVNet) Prevalidate() error {
func (c *CreateVNet) PreRun() error {
return nil
}

Expand All @@ -72,7 +73,7 @@ type CreateSubnet struct {
SubnetAddressSpace string
}

func (c *CreateSubnet) Run() error {
func (c *CreateSubnet) Run(_ *types.RuntimeObjects) error {
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
return fmt.Errorf("failed to obtain a credential: %w", err)
Expand Down Expand Up @@ -101,7 +102,7 @@ func (c *CreateSubnet) Run() error {
return nil
}

func (c *CreateSubnet) Prevalidate() error {
func (c *CreateSubnet) PreRun() error {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/delete-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
armcontainerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
"github.com/microsoft/retina/test/e2e/framework/types"
)

type DeleteCluster struct {
Expand All @@ -16,7 +17,7 @@ type DeleteCluster struct {
Location string
}

func (d *DeleteCluster) Run() error {
func (d *DeleteCluster) Run(_ *types.RuntimeObjects) error {
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
return fmt.Errorf("failed to obtain a credential: %w", err)
Expand All @@ -39,7 +40,7 @@ func (d *DeleteCluster) Run() error {
return nil
}

func (d *DeleteCluster) Prevalidate() error {
func (d *DeleteCluster) PreRun() error {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/delete-rg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/microsoft/retina/test/e2e/framework/types"
)

type DeleteResourceGroup struct {
Expand All @@ -16,7 +17,7 @@ type DeleteResourceGroup struct {
Location string
}

func (d *DeleteResourceGroup) Run() error {
func (d *DeleteResourceGroup) Run(_ *types.RuntimeObjects) error {
log.Printf("deleting resource group \"%s\"...", d.ResourceGroupName)
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
Expand All @@ -37,7 +38,7 @@ func (d *DeleteResourceGroup) Run() error {
return nil
}

func (d *DeleteResourceGroup) Prevalidate() error {
func (d *DeleteResourceGroup) PreRun() error {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/enable-ama.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
armcontainerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
"github.com/microsoft/retina/test/e2e/framework/types"
)

const fileperms = 0o600
Expand All @@ -23,7 +24,7 @@ type CreateAzureMonitor struct {
ClusterName string
}

func (c *CreateAzureMonitor) Run() error {
func (c *CreateAzureMonitor) Run(_ *types.RuntimeObjects) error {
log.Printf(`this will deploy azure monitor workspace and grafana, but as of 1/9/2024, the api docs don't show how to do
az aks update --enable-azure-monitor-metrics \
-n $NAME \
Expand Down Expand Up @@ -108,7 +109,7 @@ az aks update --enable-azure-monitor-metrics \
return nil
}

func (c *CreateAzureMonitor) Prevalidate() error {
func (c *CreateAzureMonitor) PreRun() error {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/azure/get-kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
armcontainerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
"github.com/microsoft/retina/test/e2e/framework/types"
)

const KubeConfigPerms = 0o600
Expand All @@ -20,7 +21,7 @@ type GetAKSKubeConfig struct {
KubeConfigFilePath string
}

func (c *GetAKSKubeConfig) Run() error {
func (c *GetAKSKubeConfig) Run(_ *types.RuntimeObjects) error {
cred, err := azidentity.NewAzureCLICredential(nil)
if err != nil {
return fmt.Errorf("failed to obtain a credential: %w", err)
Expand All @@ -44,7 +45,7 @@ func (c *GetAKSKubeConfig) Run() error {
return nil
}

func (c *GetAKSKubeConfig) Prevalidate() error {
func (c *GetAKSKubeConfig) PreRun() error {
return nil
}

Expand Down
6 changes: 4 additions & 2 deletions test/e2e/framework/generic/load-tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"log"
"os"

"github.com/microsoft/retina/test/e2e/framework/types"
)

const (
Expand All @@ -31,15 +33,15 @@ type LoadFlags struct {
ImageRegistryEnv string
}

func (s *LoadFlags) Run() error {
func (s *LoadFlags) Run(_ *types.RuntimeObjects) error {
tag := os.Getenv(s.TagEnv)
imageNamespace := os.Getenv(s.ImageNamespaceEnv)
imageRegistry := os.Getenv(s.ImageRegistryEnv)
log.Printf("using image %s/%s:%s", imageRegistry, imageNamespace, tag)
return nil
}

func (s *LoadFlags) Prevalidate() error {
func (s *LoadFlags) PreRun() error {
if err := s.validateEnvAndFlag(s.TagEnv, imageTagArg, *imageTag, ErrTagNotSet); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/kubernetes/create-agnhost-statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"time"

"github.com/microsoft/retina/test/e2e/framework/types"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -27,7 +28,7 @@ type CreateAgnhostStatefulSet struct {
KubeConfigFilePath string
}

func (c *CreateAgnhostStatefulSet) Run() error {
func (c *CreateAgnhostStatefulSet) Run(_ *types.RuntimeObjects) error {
config, err := clientcmd.BuildConfigFromFlags("", c.KubeConfigFilePath)
if err != nil {
return fmt.Errorf("error building kubeconfig: %w", err)
Expand Down Expand Up @@ -62,7 +63,7 @@ func (c *CreateAgnhostStatefulSet) Run() error {
return nil
}

func (c *CreateAgnhostStatefulSet) Prevalidate() error {
func (c *CreateAgnhostStatefulSet) PreRun() error {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/kubernetes/create-kapinger-deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strconv"

"github.com/microsoft/retina/test/e2e/framework/types"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
Expand All @@ -29,7 +30,7 @@ type CreateKapingerDeployment struct {
KubeConfigFilePath string
}

func (c *CreateKapingerDeployment) Run() error {
func (c *CreateKapingerDeployment) Run(_ *types.RuntimeObjects) error {
_, err := strconv.Atoi(c.KapingerReplicas)
if err != nil {
return fmt.Errorf("error converting replicas to int for Kapinger replicas: %w", err)
Expand Down Expand Up @@ -66,7 +67,7 @@ func (c *CreateKapingerDeployment) Run() error {
return nil
}

func (c *CreateKapingerDeployment) Prevalidate() error {
func (c *CreateKapingerDeployment) PreRun() error {
return nil
}

Expand Down
9 changes: 5 additions & 4 deletions test/e2e/framework/kubernetes/create-network-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strings"

"github.com/microsoft/retina/test/e2e/framework/types"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand All @@ -22,7 +23,7 @@ type CreateDenyAllNetworkPolicy struct {
DenyAllLabelSelector string
}

func (c *CreateDenyAllNetworkPolicy) Run() error {
func (c *CreateDenyAllNetworkPolicy) Run(_ *types.RuntimeObjects) error {
config, err := clientcmd.BuildConfigFromFlags("", c.KubeConfigFilePath)
if err != nil {
return fmt.Errorf("error building kubeconfig: %w", err)
Expand Down Expand Up @@ -68,7 +69,7 @@ func getNetworkPolicy(namespace, labelSelector string) *networkingv1.NetworkPoli
}
}

func (c *CreateDenyAllNetworkPolicy) Prevalidate() error {
func (c *CreateDenyAllNetworkPolicy) PreRun() error {
return nil
}

Expand All @@ -82,7 +83,7 @@ type DeleteDenyAllNetworkPolicy struct {
DenyAllLabelSelector string
}

func (d *DeleteDenyAllNetworkPolicy) Run() error {
func (d *DeleteDenyAllNetworkPolicy) Run(_ *types.RuntimeObjects) error {
config, err := clientcmd.BuildConfigFromFlags("", d.KubeConfigFilePath)
if err != nil {
return fmt.Errorf("error building kubeconfig: %w", err)
Expand All @@ -105,6 +106,6 @@ func (d *DeleteDenyAllNetworkPolicy) Run() error {
return nil
}

func (d *DeleteDenyAllNetworkPolicy) Prevalidate() error {
func (d *DeleteDenyAllNetworkPolicy) PreRun() error {
return nil
}
5 changes: 3 additions & 2 deletions test/e2e/framework/kubernetes/delete-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"time"

"github.com/microsoft/retina/test/e2e/framework/types"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
Expand Down Expand Up @@ -68,7 +69,7 @@ type DeleteKubernetesResource struct {
KubeConfigFilePath string
}

func (d *DeleteKubernetesResource) Run() error {
func (d *DeleteKubernetesResource) Run(_ *types.RuntimeObjects) error {
config, err := clientcmd.BuildConfigFromFlags("", d.KubeConfigFilePath)
if err != nil {
return fmt.Errorf("error building kubeconfig: %w", err)
Expand Down Expand Up @@ -187,7 +188,7 @@ func (d *DeleteKubernetesResource) Stop() error {
return nil
}

func (d *DeleteKubernetesResource) Prevalidate() error {
func (d *DeleteKubernetesResource) PreRun() error {
restype := ResourceType(d.ResourceType)
if restype == Unknown {
return ErrUnknownResourceType
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/kubernetes/exec-pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"strings"

"github.com/microsoft/retina/test/e2e/framework/types"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
Expand All @@ -23,7 +24,7 @@ type ExecInPod struct {
Command string
}

func (e *ExecInPod) Run() error {
func (e *ExecInPod) Run(_ *types.RuntimeObjects) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand All @@ -35,7 +36,7 @@ func (e *ExecInPod) Run() error {
return nil
}

func (e *ExecInPod) Prevalidate() error {
func (e *ExecInPod) PreRun() error {
return nil
}

Expand Down
Loading
Loading