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 integration tests for kube-apiextensions-server #45721

Merged
merged 1 commit into from
May 17, 2017

Conversation

nikhita
Copy link
Member

@nikhita nikhita commented May 12, 2017

What this PR does / why we need it: Add the following integration tests for kube-apiextensions-server:

  • test namespace scoped resources
  • test cluster scoped resources
  • test discovery
  • test no namespace rejects
  • test same name, different namespace

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): for #45511

Special notes for your reviewer:

Release note:

NONE

@sttts @deads2k

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 12, 2017
@k8s-ci-robot
Copy link
Contributor

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 @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 12, 2017
@sttts
Copy link
Contributor

sttts commented May 12, 2017

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 12, 2017
@@ -186,3 +188,204 @@ func TestSimpleCRUD(t *testing.T) {
t.Errorf("missing watch event")
}
}

func TestNonNamespaced(t *testing.T) {
Copy link
Contributor

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 {
Copy link
Contributor

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.

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels May 12, 2017

noxuInstanceToCreate := testserver.NewNoxuInstance(ns, "foo")
createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate)
createdNoxuInstance, err := noxuResourceClient.Create(noxuInstanceToCreate)
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2017
func TestSameNameDiffNamespace(t *testing.T) {
scope := apiextensionsv1alpha1.NamespaceScoped
ns1 := "namespace-1"
testSimpleCRUD(t, scope, ns1)
Copy link
Contributor

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 {
Copy link
Contributor

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?

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2017
}

// Second namespace
ns2 := "namespace-2"
Copy link
Contributor

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?

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 17, 2017
* test namespace scoped resources
* test cluster scoped resources
* test discovery
* test no namespace rejects
* test same name different namespace
@nikhita nikhita changed the title [WIP] Add integration tests for kube-apiextensions-server Add integration tests for kube-apiextensions-server May 17, 2017
@nikhita
Copy link
Member Author

nikhita commented May 17, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@sttts
Copy link
Contributor

sttts commented May 17, 2017

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nikhita, sttts

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 17, 2017
@nikhita
Copy link
Member Author

nikhita commented May 17, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45771, 45721)

@k8s-github-robot k8s-github-robot merged commit 63ec1b2 into kubernetes:master May 17, 2017
@nikhita nikhita deleted the kubeapiserver-int-test branch May 17, 2017 09:33
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 17, 2017

@nikhita: The following test(s) failed:

Test name Commit Details Rerun command
pull-kubernetes-federation-e2e-gce 62421cd link @k8s-bot pull-kubernetes-federation-e2e-gce test this

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants