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

Remove AllowAll IDP dependency for extended and integration tests #11269

Closed
wants to merge 1 commit into from

Conversation

enj
Copy link
Contributor

@enj enj commented Oct 7, 2016

Fixes #11255

@enj
Copy link
Contributor Author

enj commented Oct 7, 2016

cc @brenton

@@ -64,52 +65,59 @@ func GetClusterAdminClientConfig(adminKubeConfigFile string) (*restclient.Config
}

func GetClientForUser(clientConfig restclient.Config, username string) (*client.Client, *kclient.Client, *restclient.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a first param of adminClient *client.Client instead of assuming the clientConfig is both the admin config and the template for the user config

if _, _, _, err := GetClientForUser(clientConfig, username); err != nil {
return nil, nil, nil, err
func getOrCreateUser(adminClient *client.Client, username string) (*userapi.User, error) {
user, err := adminClient.Users().Create(&userapi.User{ObjectMeta: kapi.ObjectMeta{Name: username}})
Copy link
Contributor

Choose a reason for hiding this comment

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

user, err := ... create
if err == nil {
  return user, nil
}
if kerrs.IsAlreadyExists(err) {
  return adminClient.Users().Get(username)
}
return nil, err

return nil, nil, nil, err

var err error
token, err = adminClient.OAuthAccessTokens().Create(token)
Copy link
Contributor

Choose a reason for hiding this comment

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

return adminClient.OAuthAccessTokens().Create(token)

return token, nil
}

func getScopedClientForConfig(clientConfig *restclient.Config, token string) (*client.Client, *kclient.Client, *restclient.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

better name, this doesn't have anything to do with scopes

@brenton
Copy link
Contributor

brenton commented Oct 7, 2016

Thanks for looking at this @enj!

Would it be possible to have the tests remove the users when the tests terminate as part of this PR?

@enj
Copy link
Contributor Author

enj commented Oct 7, 2016

[test]

@enj
Copy link
Contributor Author

enj commented Oct 7, 2016

While I think it is worthwhile to remove the dependency on the AllowAll IDP, I do not think it is valid to suggest that users actually run our test suite on a real cluster. The tests essentially use the cluster as an ephemeral scratchpad. I am not even sure if we cleanup the test namespaces.

Conformance tests are useful in some running clusters however admin can't always want to disable authentication

Useful how? The tests validate our code, not our customer's cluster's health.

Would it be possible to have the tests remove the users when the tests terminate as part of this PR?

This could delete valid users just as easily as it would delete the test users.

@enj
Copy link
Contributor Author

enj commented Oct 11, 2016

re[test] flake #11094 #10162

@enj
Copy link
Contributor Author

enj commented Oct 11, 2016

@liggitt minus the flakes this seems to working. I may have been overzealous with the refactor though...

@brenton
Copy link
Contributor

brenton commented Oct 11, 2016

@enj , To clean up projects and users we could probably improve our logging to make it easy for admins to run a cleanup job afterwards.

While the conformance tests are primarily concerned with validating OpenShift/Kube code itself. They do exercise a fair amount of the environment. Many admins have expressed the need to be able to produce large numbers of builds and deployments to validate their infrastructure changes. Eg, post upgrade they like to know if something is broken rather than waiting for their users to report it.

@enj
Copy link
Contributor Author

enj commented Oct 11, 2016

The problem with using these tests is that any developer at any point could add a test that does oc delete all --all (for example, if someone asked them to implement cleanup logic after the tests). IMO some other form of test is needed to validate cluster health (and ideally it would be something that either ran in some type of --dry-run mode or some other isolated manner).

@brenton
Copy link
Contributor

brenton commented Oct 11, 2016

@enj, Ahh, I see your concern. For what it's worth, we certainly are going to review the subset of tests that customers would be allowed to run. There would be another wrapper script to explicitly run certain tests. QE would even validate this wrapper script doesn't break a running environment before we would ever ship them in the product.

@enj
Copy link
Contributor Author

enj commented Oct 11, 2016

@brenton IMO this is the wrong approach, especially with the amount of work that is being proposed via QE validation. I believe a better way to go about it would be to make an entirely separate repository (something like openshift/stress-test). This repo would house the tooling needed specifically for this use case, and could provide a nice CLI interface to the cluster admin. Anyone committing to repo would understand the need for caution in all changes. Some important features of such tooling could be:

  1. Keeping track of all resources created in a fault tolerant way
  2. Allowing the admin to constrain how resources are created (name prefixes, resource kind, rate of creation, etc)
  3. Extremely cautious clean up code

@liggitt thoughts?

@brenton
Copy link
Contributor

brenton commented Oct 11, 2016

If someone had time to do that I don't deny it would be ideal. My understanding is that our own performance team is also using the Conformance tests to generate load today. They are another team that has requested being able to run these tests on an environment that has authentication configured (though they were not concerned with the upgrade scenario, only fresh installs of OCP).

@brenton
Copy link
Contributor

brenton commented Oct 11, 2016

I don't entirely see the need for an entirely new repository though. Perhaps a new directory in Origin with a README. Otherwise there's a little more overhear maintaining it along with new PRs that come in.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 15, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 28, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 17, 2016
@@ -1191,7 +1191,7 @@ func TestOldLocalSubjectAccessReviewEndpoint(t *testing.T) {
},
}
actualResponse := &authorizationapi.SubjectAccessReviewResponse{}
err := haroldClient.Post().Namespace(namespace).Resource("subjectAccessReviews").Body(sar).Do().Into(actualResponse)
err := haroldClient.(*client.Client).Post().Namespace(namespace).Resource("subjectAccessReviews").Body(sar).Do().Into(actualResponse)
Copy link
Contributor

Choose a reason for hiding this comment

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

why are these casts needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I changed the functions to return the client interface instead of the raw client. I should be able to get rid of the casts by implementing anything missing.

token := &oauthapi.OAuthAccessToken{
ObjectMeta: kapi.ObjectMeta{Name: fmt.Sprintf("%s-token-plus-some-padding-here-to-make-the-limit-%d", username, rand.Int())},
ObjectMeta: kapi.ObjectMeta{Name: fmt.Sprintf("%s-token-plus-some-padding-here-to-make-the-limit-%d", user.Name, rand.Int())},
Copy link
Contributor

Choose a reason for hiding this comment

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

auto-creating a token named like this is just one of the many reasons this should never be run on a production cluster

@liggitt
Copy link
Contributor

liggitt commented Jan 14, 2017

most of this seems fine, though I wouldn't merge it until we could get rid of the type casts...

@brenton, the assumptions that random usernames are available to run tests as, the destruction of random namespaces, and the generation of insecure tokens are all reasons these tests shouldn't run against a production server

@brenton
Copy link
Contributor

brenton commented Jan 16, 2017

@liggitt, that definitely makes sense given the current state of things. I still hear a lot of people wishing they had a suite of tests to run on production environments and they are going to have many of the same bootstrapping challenges as the e2e tests. Does it seem reasonable to reserve certain resources as test only? Take the example.com domain. They built that in to the dns spec for the purposes of testing.

@enj enj force-pushed the enj/i/et_explicit_user_token/11255 branch from 6754be3 to c07d082 Compare January 19, 2017 19:38
@enj enj removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2017
if err != nil {
return nil, err
}
rawClient, ok := adminClient.(*client.Client)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liggitt This is the only type cast I was not able to remove without adding a bunch of code.

}

// do not use this func unless you need to do raw REST or other low level operations
func GetClusterAdminClientRaw(adminKubeConfigFile string) (*client.Client, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liggitt This allowed me to get around the other type casts in the places where we needed the raw client.

@enj
Copy link
Contributor Author

enj commented Jan 19, 2017

@liggitt This is ready assuming the tests pass.

Signed-off-by: Monis Khan <mkhan@redhat.com>
@enj enj force-pushed the enj/i/et_explicit_user_token/11255 branch from 29076b2 to c6dd940 Compare January 20, 2017 15:36
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to c6dd940

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/13092/) (Base Commit: 9a006a8)

@enj
Copy link
Contributor Author

enj commented Jan 20, 2017

Flake on #12558

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 26, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 8, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 28, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 6, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 23, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 6, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 14, 2017
@openshift-bot
Copy link
Contributor

Origin Action Required: Pull request cannot be automatically merged, please rebase your branch from latest HEAD and push again

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 16, 2017
@enj
Copy link
Contributor Author

enj commented Jun 20, 2017

@soltysh did you ever end up doing anything with this?

@soltysh
Copy link
Contributor

soltysh commented Jun 20, 2017

@enj nope I didn't do anything with it, this is the first time I hear about it.

@enj
Copy link
Contributor Author

enj commented Jun 21, 2017

@soltysh I just remember you wanting to switch tests to use the client interface, which I had started to do here.

@soltysh
Copy link
Contributor

soltysh commented Jun 21, 2017

Oh that, hmm... that is still on my todo list ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants