Merge pull request #472 from mattmoyer/deflake-getpinnipedcategory-test
Make TestGetPinnipedCategory and TestKubeClientOwnerRef tests more resilient.
This commit is contained in:
commit
aa826a1579
@ -7,6 +7,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
@ -20,13 +21,21 @@ func TestGetPinnipedCategory(t *testing.T) {
|
|||||||
t.Run("category, no special params", func(t *testing.T) {
|
t.Run("category, no special params", func(t *testing.T) {
|
||||||
var stdOut, stdErr bytes.Buffer
|
var stdOut, stdErr bytes.Buffer
|
||||||
|
|
||||||
cmd := exec.Command("kubectl", "get", "pinniped", "-A")
|
var err error
|
||||||
cmd.Stdout = &stdOut
|
require.Eventuallyf(t, func() bool {
|
||||||
cmd.Stderr = &stdErr
|
cmd := exec.Command("kubectl", "get", "pinniped", "-A")
|
||||||
err := cmd.Run()
|
cmd.Stdout = &stdOut
|
||||||
require.NoError(t, err, stdErr.String(), stdOut.String())
|
cmd.Stderr = &stdErr
|
||||||
|
err = cmd.Run()
|
||||||
|
return err == nil
|
||||||
|
},
|
||||||
|
60*time.Second,
|
||||||
|
1*time.Second,
|
||||||
|
"never ran 'kubectl get pinniped -A' successfully:\n%s\n\n%s",
|
||||||
|
stdErr.String(),
|
||||||
|
stdOut.String(),
|
||||||
|
)
|
||||||
require.Empty(t, stdErr.String())
|
require.Empty(t, stdErr.String())
|
||||||
|
|
||||||
require.NotContains(t, stdOut.String(), "MethodNotAllowed")
|
require.NotContains(t, stdOut.String(), "MethodNotAllowed")
|
||||||
require.Contains(t, stdOut.String(), dotSuffix)
|
require.Contains(t, stdOut.String(), dotSuffix)
|
||||||
})
|
})
|
||||||
|
@ -5,6 +5,7 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -75,15 +76,18 @@ func TestKubeClientOwnerRef(t *testing.T) {
|
|||||||
UID: parentSecret.UID,
|
UID: parentSecret.UID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snorlaxAPIGroup := fmt.Sprintf("%s.snorlax.dev", library.RandHex(t, 8))
|
||||||
parentAPIService, err := regularAggregationClient.ApiregistrationV1().APIServices().Create(
|
parentAPIService, err := regularAggregationClient.ApiregistrationV1().APIServices().Create(
|
||||||
ctx,
|
ctx,
|
||||||
&apiregistrationv1.APIService{
|
&apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "v1.snorlax.dev",
|
Name: "v1." + snorlaxAPIGroup,
|
||||||
|
Labels: map[string]string{"pinniped.dev/test": ""},
|
||||||
|
Annotations: map[string]string{"pinniped.dev/testName": t.Name()},
|
||||||
},
|
},
|
||||||
Spec: apiregistrationv1.APIServiceSpec{
|
Spec: apiregistrationv1.APIServiceSpec{
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
Group: "snorlax.dev",
|
Group: snorlaxAPIGroup,
|
||||||
GroupPriorityMinimum: 10_000,
|
GroupPriorityMinimum: 10_000,
|
||||||
VersionPriority: 500,
|
VersionPriority: 500,
|
||||||
},
|
},
|
||||||
@ -183,16 +187,19 @@ func TestKubeClientOwnerRef(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// cluster scoped API service should be owned by the other one we created above
|
// cluster scoped API service should be owned by the other one we created above
|
||||||
|
pandasAPIGroup := fmt.Sprintf("%s.pandas.dev", library.RandHex(t, 8))
|
||||||
apiService, err := ownerRefClient.Aggregation.ApiregistrationV1().APIServices().Create(
|
apiService, err := ownerRefClient.Aggregation.ApiregistrationV1().APIServices().Create(
|
||||||
ctx,
|
ctx,
|
||||||
&apiregistrationv1.APIService{
|
&apiregistrationv1.APIService{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "v1.pandas.dev",
|
Name: "v1." + pandasAPIGroup,
|
||||||
OwnerReferences: nil, // no owner refs set
|
OwnerReferences: nil, // no owner refs set
|
||||||
|
Labels: map[string]string{"pinniped.dev/test": ""},
|
||||||
|
Annotations: map[string]string{"pinniped.dev/testName": t.Name()},
|
||||||
},
|
},
|
||||||
Spec: apiregistrationv1.APIServiceSpec{
|
Spec: apiregistrationv1.APIServiceSpec{
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
Group: "pandas.dev",
|
Group: pandasAPIGroup,
|
||||||
GroupPriorityMinimum: 10_000,
|
GroupPriorityMinimum: 10_000,
|
||||||
VersionPriority: 500,
|
VersionPriority: 500,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user