-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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 integration tests for kube-apiextensions-server #45721
Add integration tests for kube-apiextensions-server #45721
Conversation
Hi @nikhita. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@k8s-bot ok to test |
@@ -186,3 +188,204 @@ func TestSimpleCRUD(t *testing.T) { | |||
t.Errorf("missing watch event") | |||
} | |||
} | |||
|
|||
func TestNonNamespaced(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there is quite some overlap with TestSimpleCRUD. Can you try to factor out the equal pieces?
} | ||
} | ||
|
||
func NewNoxuClusterCustomResourceDefinition() *apiextensionsv1alpha1.CustomResource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here I would merge these two funcs and add scope
parameter to NewNoxuCustomResourceDefinition
.
07c0f9e
to
3a99b21
Compare
|
||
noxuInstanceToCreate := testserver.NewNoxuInstance(ns, "foo") | ||
createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate) | ||
createdNoxuInstance, err := noxuResourceClient.Create(noxuInstanceToCreate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A check is missing below whether ObjectMeta.Namespace is set correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also check that resources with the wrong scope are rejected.
And check that creating another resource with another namespace, but same name works or fails (depending on scope).
|
||
s := []string{"shortnoxu", "shortnoxu2"} | ||
if !reflect.DeepEqual(r.ShortNames, s) { | ||
t.Fatalf("Expected exactly the shortnames \"shortnoxu\", \"shortnoxu2\" in group version %v/%v via discovery, got: %v", group, version, r.ShortNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
`foo bar "abc" def`
is a bit more elegant than quoting.
@@ -186,3 +198,49 @@ func TestSimpleCRUD(t *testing.T) { | |||
t.Errorf("missing watch event") | |||
} | |||
} | |||
func TestDiscovery(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line
3a99b21
to
9e7fc4f
Compare
func TestSameNameDiffNamespace(t *testing.T) { | ||
scope := apiextensionsv1alpha1.NamespaceScoped | ||
ns1 := "namespace-1" | ||
testSimpleCRUD(t, scope, ns1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each of these creates its own server, doesn't it? We have to share it though for this test.
} | ||
|
||
createdNoxuInstance, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, "foo"), noxuResourceClient, noxuDefinition) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which error do we expect?
9e7fc4f
to
6f9133a
Compare
} | ||
|
||
// Second namespace | ||
ns2 := "namespace-2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this much different from namespace-1? Can we merge these two into a (local) func?
* test namespace scoped resources * test cluster scoped resources * test discovery * test no namespace rejects * test same name different namespace
6f9133a
to
62421cd
Compare
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
/lgtm |
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
Automatic merge from submit-queue (batch tested with PRs 45771, 45721) |
@nikhita: The following test(s) failed:
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What this PR does / why we need it: Add the following integration tests for
kube-apiextensions-server
:Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): for #45511Special notes for your reviewer:
Release note:
@sttts @deads2k