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

tests: e2e test for trusted-ca-bundle #1346

Closed

Conversation

Sara4994
Copy link
Contributor

@Sara4994 Sara4994 commented Nov 5, 2024

Description

This PR is intended to include e2e tests for the trusted CA bundle feature.

JIRA issue: https://issues.redhat.com/browse/RHOAIENG-3924

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link

openshift-ci bot commented Nov 5, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from sara4994. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@Sara4994
Copy link
Contributor Author

Sara4994 commented Nov 5, 2024

/cc @VaishnaviHire

@openshift-ci openshift-ci bot requested a review from VaishnaviHire November 5, 2024 19:33
@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch from 52a655a to 7897693 Compare November 5, 2024 19:37
@@ -129,45 +129,45 @@ func setupDSCInstance(name string) *dscv1.DataScienceCluster {
},
ModelMeshServing: modelmeshserving.ModelMeshServing{
Component: components.Component{
ManagementState: operatorv1.Managed,
ManagementState: operatorv1.Removed,
Copy link
Member

Choose a reason for hiding this comment

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

The ManagementState changes need to be reverted

Copy link
Contributor Author

@Sara4994 Sara4994 Nov 5, 2024

Choose a reason for hiding this comment

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

oops.. yea my bad. just reverted them

@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch 2 times, most recently from a439e36 to 37d0b92 Compare November 5, 2024 20:02
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (incubation@8fb9bd7). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@
##             incubation    #1346   +/-   ##
=============================================
  Coverage              ?   18.91%           
=============================================
  Files                 ?       30           
  Lines                 ?     3399           
  Branches              ?        0           
=============================================
  Hits                  ?      643           
  Misses                ?     2687           
  Partials              ?       69           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zdtsw zdtsw added the odh-2.21 label Nov 6, 2024
@VaishnaviHire
Copy link
Member

@Sara4994 As part of #1339 @zdtsw introduced changes, that can be validated as part of this PR. The test cases are included in PR description.

@zdtsw
Copy link
Member

zdtsw commented Nov 7, 2024

@Sara4994 As part of #1339 @zdtsw introduced changes, that can be validated as part of this PR. The test cases are included in PR description.

i dont think it need to be too complicated in test case to cover all 3 senaiors from that "fix" PR.
the real one we need is to check if the foundConfigMap.Data[CADataFieldName] has an ending newline, then it is fine.

@@ -444,6 +451,48 @@ func (tc *testContext) testDefaultCertsAvailable() error {
return nil
}

func (tc *testContext) testTrustedCABundle() error {
Copy link
Member

Choose a reason for hiding this comment

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

not sure i understand the logic here:
if we are making e2e test (not unit-test) , what we should test is:

  1. set managementStateChangeTrustedCA := true
  • check if Configmap is created in tc.testDSCI.Spec.ApplicationsNamespace
  • check content of CADataFieldName == tc.testDSCI.Spec.TrustedCABundle.CustomCABundle
  • check content of CADataFieldName has newline as ending (this is new from current code base)
  1. set managementStateChangeTrustedCA := false
  • check no Configmap in tc.testDSCI.Spec.ApplicationsNamespace

Copy link
Member

Choose a reason for hiding this comment

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

ok, seems confusion for the above comments:
set managementStateChangeTrustedCA := true
is not meant to be set in the testcase, this is only to illustrate the case when set to Managed VS Removed
what need to be done is tc.testDSCI.Spec.TrustedCABundle.ManagementState: Managed

@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch from 37d0b92 to 96ec2c2 Compare November 13, 2024 19:35
@zdtsw zdtsw removed the odh-2.21 label Nov 14, 2024
@Sara4994
Copy link
Contributor Author

/test opendatahub-operator-e2e

@grdryn
Copy link
Member

grdryn commented Nov 27, 2024

@Sara4994 what's the status of this PR? It looks like it hasn't seen any update in a couple of weeks, and the last time the e2e test job ran it failed on the newly added test.

@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch 3 times, most recently from cf7fea7 to 5449a4c Compare December 1, 2024 17:18
return fmt.Errorf("odh-trusted-ca-bundle in config map does not match with DSCI's TrustedCABundle.CustomCABundle, needs update: %w", err)
}

err = trustedcabundle.AddCABundleCMInAllNamespaces(tc.ctx, tc.customClient, logr.Logger{}, tc.testDSCI)
Copy link
Member

Choose a reason for hiding this comment

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

Why are we explicitly adding and removing the configmap from all namespaces? Shouldn't this be created by the controller?

@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch 5 times, most recently from 6d5d524 to 0516e50 Compare December 5, 2024 10:34
@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch 3 times, most recently from b639713 to f72a8a2 Compare December 5, 2024 13:36

if k8serr.IsNotFound(err) {
fmt.Printf("Config map not found in the namespace")
}
Copy link
Member

Choose a reason for hiding this comment

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

We should return other errors 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.

@VaishnaviHire this is done

MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQEL
...
IrrVQJLuM7IjWcmOvFjai57QGfIvWcaMY1q6n6MLsLOaXLoRuBLpDLvPbmyAhykU
------END ------` + "\n",
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure we need to add \n here, since that was the change - to introduce newline if its not in input
cc: @zdtsw correct me if I missed something here

Copy link
Contributor Author

@Sara4994 Sara4994 Dec 5, 2024

Choose a reason for hiding this comment

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

@VaishnaviHire I thought the same but if i dont add newline it there, the check here

if foundConfigMap.Data[CADataFieldName] != tc.testDSCI.Spec.TrustedCABundle.CustomCABundle {
fails, I mean it says string in foundConfigMap.Data[CADataFieldName] and tc.testDSCI.Spec.TrustedCABundle.CustomCABundle are different

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure we need to add \n here, since that was the change - to introduce newline if its not in input

correct, user input data in DSCI should not need to explicility add newline ending

@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch 3 times, most recently from 2ddc6ad to bede6ac Compare December 5, 2024 17:38
@Sara4994
Copy link
Contributor Author

Sara4994 commented Dec 6, 2024

/test opendatahub-operator-e2e

@zdtsw zdtsw requested a review from grdryn December 6, 2024 08:59
@zdtsw
Copy link
Member

zdtsw commented Dec 6, 2024

LGTM, @grdryn you wanna give another review?

tests/e2e/creation_test.go Outdated Show resolved Hide resolved
Comment on lines +470 to +472
if checkNewline == false {
fmt.Print("Newline not found at the end of configmap")
}
Copy link
Member

@grdryn grdryn Dec 6, 2024

Choose a reason for hiding this comment

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

Are both cases acceptable here (newline or not), or should this assert one of the cases?

Also, the check looks like it will pass if a newline character is found anywhere in the string, not just at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grdryn yea true, i have modified the check here

@Sara4994 Sara4994 force-pushed the trustedcabundle-e2e-tests branch from bede6ac to fcc2720 Compare December 6, 2024 15:28
@zdtsw
Copy link
Member

zdtsw commented Dec 9, 2024

target branch should be "main"

@Sara4994 Sara4994 changed the base branch from incubation to main December 9, 2024 07:48
@Sara4994 Sara4994 changed the base branch from main to incubation December 9, 2024 07:49
@Sara4994
Copy link
Contributor Author

Sara4994 commented Dec 9, 2024

@zdtsw @grdryn while switching the target branch, there were so many conflicts from lot many commits. So I have created a new PR to avoid mess. I will close this one if new PR looks fine

@grdryn
Copy link
Member

grdryn commented Dec 9, 2024

@Sara4994 sounds good. I think it's fine to close this one already now. Feel free to re-open if you disagree.

@grdryn grdryn closed this Dec 9, 2024
MarianMacik pushed a commit to MarianMacik/opendatahub-operator that referenced this pull request Jan 22, 2025
…flux/component-updates/odh-model-controller-v2-17

chore(deps): update odh-model-controller-v2-17 to 3d61985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants