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 unit tests for kopia repository server controller(PR #2) #1997

Merged
merged 99 commits into from
Jul 13, 2023

Conversation

kale-amruta
Copy link
Contributor

@kale-amruta kale-amruta commented Apr 7, 2023

Change Overview

This PR adds a suite for running unit tests for kopia repository server controller. This is in continuation with the
base suite PR #2100

In this PR we are checking following points
- Check if Server is created successfully and CR is in RepositoryServerReady after all the configurations are done correctly
- Check if Server goes into RepositoryServerStopped state when secrets are not provided in CR
- Immutability of certain fields in the CR - update of CR for certain fields should not be allowed
- Check if repository server pod and service are getting created after creating the CR
- Check Repository Connect failures if the secrets are configured incorrectly
- Check what cachesizesettings are passed to kopia when the CR is configured with cachesizesettings field
- Test fetching of repository server secrets in the controller

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

  • fixes #issue-number

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

Test Result:
https://gist.github.com/kale-amruta/a2e9f6402196027af398bded26c46247

@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2023

Thanks for submitting this pull request 🎉. The team will review it soon and get back to you.

If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document.

@infraq infraq added this to In Progress in Kanister Apr 7, 2023
@kale-amruta kale-amruta marked this pull request as draft April 7, 2023 09:57
@kale-amruta kale-amruta marked this pull request as ready for review May 8, 2023 09:42
@kale-amruta kale-amruta changed the title add unit tests for kopia repository server controller Add unit tests for kopia repository server controller May 8, 2023
Copy link
Contributor

@viveksinghggits viveksinghggits left a comment

Choose a reason for hiding this comment

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

Do we just want to test if the CR is getting into Created state as part of this test?

pkg/controllers/repositoryserver/suite_test.go Outdated Show resolved Hide resolved
pkg/controllers/repositoryserver/suite_test.go Outdated Show resolved Hide resolved
@kale-amruta kale-amruta changed the base branch from master to CreateCRDs May 18, 2023 07:44
Kanister automation moved this from In Progress to Reviewer approved Jul 12, 2023
if podName and serviceName are not set even after the polling time
exceeds
@kale-amruta
Copy link
Contributor Author

@PrasadG193 @viveksinghggits can we merge this manually? This PR has been blocked for automatic merge.

@viveksinghggits viveksinghggits merged commit 6b1ceaa into master Jul 13, 2023
12 of 13 checks passed
Kanister automation moved this from Reviewer approved to Done Jul 13, 2023
@viveksinghggits viveksinghggits deleted the AddUnitTests branch July 13, 2023 08:18
PrasadG193 added a commit that referenced this pull request Jul 14, 2023
PrasadG193 added a commit that referenced this pull request Jul 14, 2023
kale-amruta added a commit that referenced this pull request Jul 17, 2023
PrasadG193 pushed a commit that referenced this pull request Jul 19, 2023
…(PR #2)"" (#2180)

* Revert "Revert "Add unit tests for kopia repository server controller(PR #2) (#1997)" (#2178)"

This reverts commit 5d16f29.

* skip immuatability test for k8s version < 1.25

* check error is not nil for discovery client

* fix minor and major version variable names
mellon-collie pushed a commit that referenced this pull request Jul 20, 2023
* add unit tests for repository server controller

* test

* add prerequisites for tests

* add server ready test

* remove unwanted changes

* fix lint issues

* automate creation of repo server CRD

* address review comments

* add symbolic link

* address comments

* remove custom resource

* renaming cli to kubecli

* add more tests

* fix lint issue

* Add tests for Immutability

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>

* Fix naming conventions

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>

* Update variables

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>

* add tests related to secrets

* add secrets configuration for testutils

* add base suite for repository server controller

* use constants for location secret keys

* add unit tests

* make the constants local to the package

* add licence headers

* change package name

* fix build errors

* fix licence headers

* fix lint issues

* remove secret manager changes

* remove unused functions and move to next PR

* add utility functions

* add tests for secrets and cache settings

* fix build issues

* move secret creation utils under test suite

* resolve conflicts

* add base suite for repository server controller

* use constants for location secret keys

* make the constants local to the package

* add licence headers

* fix licence headers

* fix lint issues

* remove unused functions and move to next PR

* fix build issues

* move secret creation utils under test suite

* address review comments

* add tests which got deleted during rebase

* address review comments

* updating tests to use the latest changed values for repository server progress field in status

* move test utilities to pkg/testutil/testutil.go

* rename kopia repository path constant name

* improve tests and comments for better readability

* refactor repository_test.go and secrets_manager_test.go for better readability

* fix tests

* test

* fix tests

* remove unnecessary whitespaces

* rename conflicting env variables with s3compliant prefix

* uncomment tests

* move the env variable related comment at the right place

* check error message for immuatability test

* address comments related to better readability

* change waitForRepoServerInfoUpdateInCR function to return error
if podName and serviceName are not set even after the polling time
exceeds

---------

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Co-authored-by: Rajat Gupta <37516416+r4rajat@users.noreply.github.com>
Co-authored-by: Rajat Gupta <rajat.gupta@veeam.com>
mabhi pushed a commit that referenced this pull request Jul 24, 2023
…(PR #2)"" (#2180)

* Revert "Revert "Add unit tests for kopia repository server controller(PR #2) (#1997)" (#2178)"

This reverts commit 5d16f29.

* skip immuatability test for k8s version < 1.25

* check error is not nil for discovery client

* fix minor and major version variable names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants