Skip to content

Commit

Permalink
Merge pull request #230 from ty-dc/add-deletepodbylabel
Browse files Browse the repository at this point in the history
add api DeletePodListByLabel
  • Loading branch information
weizhoublue authored Aug 16, 2024
2 parents 71bf7b1 + 03545a6 commit 9ba7f53
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
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) WaitAllPodUntilRunning(ctx context.Context) error {
}
}
}

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

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

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

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"
)

0 comments on commit 9ba7f53

Please sign in to comment.