-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): Add test for NFD addon (#389)
- Loading branch information
1 parent
56a6e95
commit 8bf4d45
Showing
5 changed files
with
228 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//go:build e2e | ||
|
||
// Copyright 2024 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
|
||
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
"sigs.k8s.io/cluster-api/test/framework" | ||
|
||
"github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1" | ||
) | ||
|
||
type WaitForAddonsToBeReadyInWorkloadClusterInput struct { | ||
AddonsConfig v1alpha1.Addons | ||
WorkloadCluster *capiv1.Cluster | ||
ClusterProxy framework.ClusterProxy | ||
DeploymentIntervals []interface{} | ||
DaemonSetIntervals []interface{} | ||
HelmReleaseIntervals []interface{} | ||
ClusterResourceSetIntervals []interface{} | ||
} | ||
|
||
func WaitForAddonsToBeReadyInWorkloadCluster( | ||
ctx context.Context, | ||
input WaitForAddonsToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests. | ||
) { | ||
WaitForCNIToBeReadyInWorkloadCluster( | ||
ctx, | ||
WaitForCNIToBeReadyInWorkloadClusterInput{ | ||
CNI: input.AddonsConfig.CNI, | ||
WorkloadCluster: input.WorkloadCluster, | ||
ClusterProxy: input.ClusterProxy, | ||
DeploymentIntervals: input.DeploymentIntervals, | ||
DaemonSetIntervals: input.DaemonSetIntervals, | ||
HelmReleaseIntervals: input.HelmReleaseIntervals, | ||
ClusterResourceSetIntervals: input.ClusterResourceSetIntervals, | ||
}, | ||
) | ||
|
||
WaitForNFDToBeReadyInWorkloadCluster( | ||
ctx, | ||
WaitForNFDToBeReadyInWorkloadClusterInput{ | ||
NFD: input.AddonsConfig.NFD, | ||
WorkloadCluster: input.WorkloadCluster, | ||
ClusterProxy: input.ClusterProxy, | ||
DeploymentIntervals: input.DeploymentIntervals, | ||
DaemonSetIntervals: input.DaemonSetIntervals, | ||
HelmReleaseIntervals: input.HelmReleaseIntervals, | ||
ClusterResourceSetIntervals: input.ClusterResourceSetIntervals, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//go:build e2e | ||
|
||
// Copyright 2024 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
|
||
appsv1 "k8s.io/api/apps/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
"sigs.k8s.io/cluster-api/test/framework" | ||
|
||
"github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1" | ||
) | ||
|
||
type WaitForNFDToBeReadyInWorkloadClusterInput struct { | ||
NFD *v1alpha1.NFD | ||
WorkloadCluster *capiv1.Cluster | ||
ClusterProxy framework.ClusterProxy | ||
DeploymentIntervals []interface{} | ||
DaemonSetIntervals []interface{} | ||
HelmReleaseIntervals []interface{} | ||
ClusterResourceSetIntervals []interface{} | ||
} | ||
|
||
func WaitForNFDToBeReadyInWorkloadCluster( | ||
ctx context.Context, | ||
input WaitForNFDToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests. | ||
) { | ||
if input.NFD == nil { | ||
return | ||
} | ||
|
||
waitForClusterResourceSetToApplyResourcesInCluster( | ||
ctx, | ||
waitForClusterResourceSetToApplyResourcesInClusterInput{ | ||
name: "node-feature-discovery-" + input.WorkloadCluster.Name, | ||
clusterProxy: input.ClusterProxy, | ||
cluster: input.WorkloadCluster, | ||
intervals: input.ClusterResourceSetIntervals, | ||
}, | ||
) | ||
|
||
workloadClusterClient := input.ClusterProxy.GetWorkloadCluster( | ||
ctx, input.WorkloadCluster.Namespace, input.WorkloadCluster.Name, | ||
).GetClient() | ||
|
||
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: workloadClusterClient, | ||
Deployment: &appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "node-feature-discovery-gc", | ||
Namespace: "node-feature-discovery", | ||
}, | ||
}, | ||
}, input.DeploymentIntervals...) | ||
|
||
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: workloadClusterClient, | ||
Deployment: &appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "node-feature-discovery-master", | ||
Namespace: "node-feature-discovery", | ||
}, | ||
}, | ||
}, input.DeploymentIntervals...) | ||
|
||
WaitForDaemonSetsAvailable(ctx, WaitForDaemonSetsAvailableInput{ | ||
Getter: workloadClusterClient, | ||
DaemonSet: &appsv1.DaemonSet{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "node-feature-discovery-worker", | ||
Namespace: "node-feature-discovery", | ||
}, | ||
}, | ||
}, input.DaemonSetIntervals...) | ||
} |