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

add api DeletePodListByLabel #230

Merged
merged 1 commit into from
Aug 16, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/lint-golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
# ============= upload coverage report
- name: Upload to Codecov
if: ${{ steps.unitest.outcome != 'failure' }}
uses: codecov/codecov-action@v3.1.4
uses: codecov/codecov-action@v4
with:
directory: './'
files: 'coverage.out'
Expand Down
17 changes: 17 additions & 0 deletions framework/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,20 @@
}
}
}

func (f *Framework) DeletePodListByLabel(label map[string]string) error {
if label == nil {
return ErrWrongInput
}

podList, err := f.GetPodListByLabel(label)
if err != nil {
return err

Check warning on line 381 in framework/pod.go

View check run for this annotation

Codecov / codecov/patch

framework/pod.go#L381

Added line #L381 was not covered by tests
}

if len(podList.Items) == 0 {
return nil

Check warning on line 385 in framework/pod.go

View check run for this annotation

Codecov / codecov/patch

framework/pod.go#L385

Added line #L385 was not covered by tests
}

return f.DeletePodList(podList)
}
19 changes: 19 additions & 0 deletions framework/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,23 @@ var _ = Describe("test pod", Label("pod"), func() {
err11 := f.DeletePodUntilFinish(podName, "", ctx4, opts4)
Expect(err11).To(HaveOccurred())
})

Describe("DeletePodListByLabel", func() {

It("label is nil", func() {
err := f.DeletePodListByLabel(nil)
Expect(err).To(MatchError(e2e.ErrWrongInput))
})

It("succeed to delete PodList via label", func() {
pod := generateExamplePodYaml(podName, namespace, label, "Running")

// create pod
err := f.CreatePod(pod)
Expect(err).NotTo(HaveOccurred())

err = f.DeletePodListByLabel(label)
Expect(err).NotTo(HaveOccurred())
})
})
})
4 changes: 0 additions & 4 deletions scripts/scripts.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Copyright 2022 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0
package scripts

import (
_ "github.com/onsi/ginkgo/v2/ginkgo"
)
Loading