mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Merge pull request #95101 from a1k24/patch-92402-staticcheck
fixes test/integration/ttlcontroller staticcheck
This commit is contained in:
commit
777e84e184
@ -7,7 +7,6 @@ test/integration/examples
|
|||||||
test/integration/framework
|
test/integration/framework
|
||||||
test/integration/garbagecollector
|
test/integration/garbagecollector
|
||||||
test/integration/scheduler_perf
|
test/integration/scheduler_perf
|
||||||
test/integration/ttlcontroller
|
|
||||||
vendor/k8s.io/apimachinery/pkg/api/apitesting/roundtrip
|
vendor/k8s.io/apimachinery/pkg/api/apitesting/roundtrip
|
||||||
vendor/k8s.io/apimachinery/pkg/api/meta
|
vendor/k8s.io/apimachinery/pkg/api/meta
|
||||||
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation
|
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation
|
||||||
|
@ -51,6 +51,7 @@ func createClientAndInformers(t *testing.T, server *httptest.Server) (*clientset
|
|||||||
|
|
||||||
func createNodes(t *testing.T, client *clientset.Clientset, startIndex, endIndex int) {
|
func createNodes(t *testing.T, client *clientset.Clientset, startIndex, endIndex int) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
errs := make(chan error, endIndex-startIndex)
|
||||||
for i := startIndex; i < endIndex; i++ {
|
for i := startIndex; i < endIndex; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(idx int) {
|
go func(idx int) {
|
||||||
@ -60,27 +61,50 @@ func createNodes(t *testing.T, client *clientset.Clientset, startIndex, endIndex
|
|||||||
Name: fmt.Sprintf("node-%d", idx),
|
Name: fmt.Sprintf("node-%d", idx),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if _, err := client.CoreV1().Nodes().Create(context.TODO(), node, metav1.CreateOptions{}); err != nil {
|
_, err := client.CoreV1().Nodes().Create(context.TODO(), node, metav1.CreateOptions{})
|
||||||
t.Fatalf("Failed to create node: %v", err)
|
if err != nil {
|
||||||
|
errs <- err
|
||||||
}
|
}
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
|
go func() { // wait in another go-routine to close channel
|
||||||
|
wg.Wait()
|
||||||
|
close(errs)
|
||||||
|
}()
|
||||||
|
|
||||||
|
for err := range errs {
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create node: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteNodes(t *testing.T, client *clientset.Clientset, startIndex, endIndex int) {
|
func deleteNodes(t *testing.T, client *clientset.Clientset, startIndex, endIndex int) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
errs := make(chan error, endIndex-startIndex)
|
||||||
for i := startIndex; i < endIndex; i++ {
|
for i := startIndex; i < endIndex; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(idx int) {
|
go func(idx int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
name := fmt.Sprintf("node-%d", idx)
|
name := fmt.Sprintf("node-%d", idx)
|
||||||
if err := client.CoreV1().Nodes().Delete(context.TODO(), name, metav1.DeleteOptions{}); err != nil {
|
err := client.CoreV1().Nodes().Delete(context.TODO(), name, metav1.DeleteOptions{})
|
||||||
t.Fatalf("Failed to delete node: %v", err)
|
if err != nil {
|
||||||
|
errs <- err
|
||||||
}
|
}
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
|
go func() { // wait in another go-routine to close channel
|
||||||
|
wg.Wait()
|
||||||
|
close(errs)
|
||||||
|
}()
|
||||||
|
|
||||||
|
for err := range errs {
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to delete node: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForNodesWithTTLAnnotation(t *testing.T, nodeLister listers.NodeLister, numNodes, ttlSeconds int) {
|
func waitForNodesWithTTLAnnotation(t *testing.T, nodeLister listers.NodeLister, numNodes, ttlSeconds int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user