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

Runtime 15 e2e #1043

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Conversation

ranakan19
Copy link
Contributor

@ranakan19 ranakan19 commented Aug 28, 2024

Changes this PR includes:

  • Updates k8s dependencies to 0.27 and controller-runtime to v0.15.
  • With the update to controller-runtime v0.15 (changes in release detailed here), this PR has following changes to combat the breaking changes:
    - With the changes to rest mapper that provided client for discovery information to do REST mappings, breaks the use case of checking available APIs via k8s.io/apimachinery/pkg/api/errors.IsNotFound and k8s.io/apimachinery/pkg/api/meta.IsNoMatchError. This means can not directly check for those errors, but should expect server error. This only affected proxy tests and the tests now check for error contains. Can find more details in this issue
  • Poll is deprecated, so using the suggested replacement PollUntillContextTimeout instead
    - Tried to propogate the context from PollUntillContextTimeout to the api calls within the condition function but it fails withwould exceed context deadlineas the last error instead of the expected context deadline exceeded error. Please refer this comment for more details. And other PR which use the same solution of intentionally pass a separate context to api calls in the consition function.
    - PollUntillContextTimeout will no longer return ErrWaitTimeout - So replaces errTimeout checks with context deadline checks. [refer this PR for more information if needed]

Copy link

openshift-ci bot commented Aug 28, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link

openshift-ci bot commented Aug 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ranakan19

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -440,9 +440,10 @@ func (a *Awaitility) CreateNamespace(t *testing.T, name string) {
func (a *Awaitility) WaitForDeploymentToGetReady(t *testing.T, name string, replicas int, criteria ...DeploymentCriteria) *appsv1.Deployment {
t.Logf("waiting until deployment '%s' in namespace '%s' is ready", name, a.Namespace)
deployment := &appsv1.Deployment{}
err := wait.Poll(a.RetryInterval, 6*a.Timeout, func() (done bool, err error) {
err := wait.PollUntilContextTimeout(context.TODO(), a.RetryInterval, 6*a.Timeout, true, func(ctx context.Context) (done bool, err 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.

Poll is deprecated

@@ -590,7 +590,7 @@ func (s *userManagementTestSuite) TestUserBanning() {
t.Logf("user signup '%s' created", userSignup.Name)

// Check the UserSignup is created
userSignup, err = hostAwait.WaitForUserSignup(t, userSignup.Name)
userSignup, err = hostAwait.WaitForUserSignup(t, userSignup.Name, wait.UntilUserSignupHasStateLabel(toolchainv1alpha1.UserSignupStateLabelValueBanned))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait for Label to avoid flakiness
Since in the following lines, the test checks that usersignup now has label.
PR failure - https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/codeready-toolchain_toolchain-e2e/1043/pull-ci-codeready-toolchain-toolchain-e2e-master-e2e/1841349548585259008 - but was unable to produce locally, so added a wait for label.

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense, however we don't need lines 597-599 anymore.

@@ -365,11 +364,12 @@ func TestProxyFlow(t *testing.T) {
require.NoError(t, err)
err = proxyCl.Create(context.TODO(), appToCreate)

// then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment block is removed as it is no longer valid. Maintaining history here might be confusing

Copy link

sonarcloud bot commented Oct 4, 2024

Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

Looks good. I left a few minor comments though.

@@ -513,7 +519,8 @@ func TestProxyFlow(t *testing.T) {
// note: the actual error message is "invalid workspace request: access to workspace '%s' is forbidden" but clients make api discovery calls
// that fail because in this case the api discovery calls go through the proxyWorkspaceURL which is invalid. If using oc or kubectl and you
// enable verbose logging you would see Response Body: invalid workspace request: access to workspace 'proxymember2' is forbidden
require.EqualError(t, err, `no matches for kind "Application" in version "appstudio.redhat.com/v1alpha1"`)

require.ErrorContains(t, err, "invalid workspace request: access to workspace 'proxymember2' is forbidden")
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete the comment above as irrelevant now.

@@ -1064,22 +1071,22 @@ func TestSpaceLister(t *testing.T) {
err := proxyClDefault.Get(context.TODO(), workspaceNamespacedName, &toolchainv1alpha1.Workspace{})

require.Error(t, err)
require.True(t, k8serr.IsForbidden(err), "expected Forbidden error, got %v", err)
require.ErrorContains(t, err, "user access is forbidden")
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the error type is ForbiddenError anymore?

testCases := map[string]bool{
"user is not banned": false,
"user is banned": true,
testCases := []TestCase{
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the following format instead:

	tests := map[string]struct {
		Banned         bool
		ExpectedError          string
	}{
		"user is not banned": {
			Banned: false,
			ExpectedError: "invalid workspace request",
		},
	}

@@ -255,7 +267,7 @@ func TestProxyPublicViewer(t *testing.T) {
cms := corev1.ConfigMapList{}

err = communityUserProxyClient.List(context.TODO(), &cms, client.InNamespace(sp.Status.ProvisionedNamespaces[0].Name))
require.True(t, meta.IsNoMatchError(err), "expected List ConfigMap as community user to return a NoMatch error, actual: %v", err)
require.ErrorContains(t, err, testCase.expectedError)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use require.ErrorEquals() instead?

@@ -590,7 +590,7 @@ func (s *userManagementTestSuite) TestUserBanning() {
t.Logf("user signup '%s' created", userSignup.Name)

// Check the UserSignup is created
userSignup, err = hostAwait.WaitForUserSignup(t, userSignup.Name)
userSignup, err = hostAwait.WaitForUserSignup(t, userSignup.Name, wait.UntilUserSignupHasStateLabel(toolchainv1alpha1.UserSignupStateLabelValueBanned))
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense, however we don't need lines 597-599 anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants