mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-03 14:54:53 -04:00
operator: cleanup resources between tests (#1049)
This commit is contained in:
parent
bb6f35fbf4
commit
effe797d81
2 changed files with 34 additions and 1 deletions
|
@ -86,7 +86,7 @@ func NewNodeVersionReconciler(nodeReplacer nodeReplacer, etcdRemover etcdRemover
|
||||||
//+kubebuilder:rbac:groups="",resources=nodes/status,verbs=get
|
//+kubebuilder:rbac:groups="",resources=nodes/status,verbs=get
|
||||||
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get
|
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=list;get
|
||||||
|
|
||||||
// Reconcile replaces outdated nodes (using an old image) with new nodes (using a new image) as specified in the NodeVersion spec.
|
// Reconcile replaces outdated nodes with new nodes as specified in the NodeVersion spec.
|
||||||
func (r *NodeVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
func (r *NodeVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||||
logr := log.FromContext(ctx)
|
logr := log.FromContext(ctx)
|
||||||
logr.Info("Reconciling NodeVersion")
|
logr.Info("Reconciling NodeVersion")
|
||||||
|
|
|
@ -26,6 +26,39 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("NodeVersion controller", func() {
|
var _ = Describe("NodeVersion controller", func() {
|
||||||
|
AfterEach(func() {
|
||||||
|
// cleanup all nodes
|
||||||
|
nodeList := &corev1.NodeList{}
|
||||||
|
Expect(k8sClient.List(context.Background(), nodeList)).To(Succeed())
|
||||||
|
for _, node := range nodeList.Items {
|
||||||
|
Expect(k8sClient.Delete(context.Background(), &node)).To(Succeed())
|
||||||
|
}
|
||||||
|
// cleanup all node versions
|
||||||
|
nodeVersionList := &updatev1alpha1.NodeVersionList{}
|
||||||
|
Expect(k8sClient.List(context.Background(), nodeVersionList)).To(Succeed())
|
||||||
|
for _, nodeVersion := range nodeVersionList.Items {
|
||||||
|
Expect(k8sClient.Delete(context.Background(), &nodeVersion)).To(Succeed())
|
||||||
|
}
|
||||||
|
// cleanup all scaling groups
|
||||||
|
scalingGroupList := &updatev1alpha1.ScalingGroupList{}
|
||||||
|
Expect(k8sClient.List(context.Background(), scalingGroupList)).To(Succeed())
|
||||||
|
for _, scalingGroup := range scalingGroupList.Items {
|
||||||
|
Expect(k8sClient.Delete(context.Background(), &scalingGroup)).To(Succeed())
|
||||||
|
}
|
||||||
|
// cleanup all pending nodes
|
||||||
|
pendingNodeList := &updatev1alpha1.PendingNodeList{}
|
||||||
|
Expect(k8sClient.List(context.Background(), pendingNodeList)).To(Succeed())
|
||||||
|
for _, pendingNode := range pendingNodeList.Items {
|
||||||
|
Expect(k8sClient.Delete(context.Background(), &pendingNode)).To(Succeed())
|
||||||
|
}
|
||||||
|
// cleanup all joining nodes
|
||||||
|
joiningNodeList := &updatev1alpha1.JoiningNodeList{}
|
||||||
|
Expect(k8sClient.List(context.Background(), joiningNodeList)).To(Succeed())
|
||||||
|
for _, joiningNode := range joiningNodeList.Items {
|
||||||
|
Expect(k8sClient.Delete(context.Background(), &joiningNode)).To(Succeed())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Define utility constants for object names and testing timeouts/durations and intervals.
|
// Define utility constants for object names and testing timeouts/durations and intervals.
|
||||||
const (
|
const (
|
||||||
nodeVersionResourceName = "nodeversion"
|
nodeVersionResourceName = "nodeversion"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue