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

Updating integration tests to test both API versions - v1beta1 and 3 #5587

Merged
merged 1 commit into from
Mar 18, 2015

Conversation

nikhiljindal
Copy link
Contributor

@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

@bgrant0607
Copy link
Member

--- FAIL: TestExampleObjectSchemas (0.23s)
    examples_test.go:159: ../cmd/integration/v1beta1-controller.json does not have a test case defined
    examples_test.go:159: ../cmd/integration/v1beta3-controller.json does not have a test case defined
    examples_test.go:175: Expected 1 examples, Got 0
FAIL
coverage: 0.0% of statements
FAIL    github.com/GoogleCloudPlatform/kubernetes/examples  0.380s

@nikhiljindal
Copy link
Contributor Author

Thats a cool test that I didnt know existed!
Fixed.

if err != nil {
glog.Fatalf("Failed listing service with supplied self link '%v': %v", svc.SelfLink, err)
}

var svcList api.ServiceList
err = c.Get().NamespaceIfScoped(namespace, len(namespace) > 0).Resource("services").Do().Into(&svcList)
svcList, err := services.List(labels.Everything())
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove the namespacing?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind.

Copy link
Member

Choose a reason for hiding this comment

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

It looks like its still there, but services is now ServiceNamespacer that has already been scoped to the namespace in question.

@nikhiljindal
Copy link
Contributor Author

Replied to all comments. PTAL.

@@ -65,7 +65,6 @@ import (

// Config is a structure used to configure a Master.
type Config struct {
Client *client.Client
Copy link
Member

Choose a reason for hiding this comment

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

Again, why this change?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind. I see your answer above now.

@bgrant0607
Copy link
Member

LGTM. Waiting for tests.

@bgrant0607 bgrant0607 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 18, 2015
@nikhiljindal
Copy link
Contributor Author

Shippable passed :)

bgrant0607 added a commit that referenced this pull request Mar 18, 2015
Updating integration tests to test both API versions - v1beta1 and 3
@bgrant0607 bgrant0607 merged commit 11f9733 into kubernetes:master Mar 18, 2015
@@ -77,7 +77,13 @@ func (c *services) Get(name string) (result *api.Service, err error) {
// Create creates a new service.
func (c *services) Create(svc *api.Service) (result *api.Service, err error) {
result = &api.Service{}
err = c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result)
// v1beta3 does not allow POST without a namespace.
needNamespace := !api.PreV1Beta3(c.r.APIVersion())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed? I think this is a bug in higher level code, and doesn't look right here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If not here, then we will need such conditions everywhere at higher level code.

If (apiVersion = v1beta3 && ns == "") {
  ns = api.NamespaceDefault
}
servicesInterface = client.services(ns)

Is that better?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm saying that anyone who has an empty string either got it from client input (in which case the server will catch it) or it will be caught lower in the code base. No one should be passing an empty namespace, ever. I don't think we need to test in the client (I have a pull incoming which normalizes all our clients now that the server is normalized).

----- Original Message -----

@@ -77,7 +77,13 @@ func (c *services) Get(name string) (result
*api.Service, err error) {
// Create creates a new service.
func (c *services) Create(svc *api.Service) (result *api.Service, err
error) {
result = &api.Service{}

  • err =
    c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result)
  • // v1beta3 does not allow POST without a namespace.
  • needNamespace := !api.PreV1Beta3(c.r.APIVersion())

If not here, then we will need such conditions everywhere at higher level
code.

If (apiVersion = v1beta3 && ns == "") {
  ns = api.NamespaceDefault
}
servicesInterface = client.services(ns)

Is that better?


Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5587/files#r26879365

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. What do you mean by "normalizing the server and the client"?

Copy link
Contributor

Choose a reason for hiding this comment

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

The RESTStorage objects and the api_installer now properly check a lot of the conditions. If there is client code that is allowing Namespace to be wrong when it passes to the Services code, we should either fix the client code or reject it on the server (the standard api/rest.go code should do that now).

Opened #5738 to clean some of this up.

----- Original Message -----

@@ -77,7 +77,13 @@ func (c *services) Get(name string) (result
*api.Service, err error) {
// Create creates a new service.
func (c *services) Create(svc *api.Service) (result *api.Service, err
error) {
result = &api.Service{}

  • err =
    c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result)
  • // v1beta3 does not allow POST without a namespace.
  • needNamespace := !api.PreV1Beta3(c.r.APIVersion())

ok. What do you mean by "normalizing the server and the client"?


Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5587/files#r26881133

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. Thanks for the explanation!
I looked at the PR and it looks good.
Thanks for working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants