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 RepositoryServer Datamover #2294

Merged
merged 19 commits into from
Sep 5, 2023

Conversation

r4rajat
Copy link
Contributor

@r4rajat r4rajat commented Aug 29, 2023

Change Overview

Add tests for RepositoryServer Datamover
Changelog:

  • Instead of running Kopia Repository Server in a pod to mimick RepositoryServer CR, we're running Kopia Repository Server Locally and Performing tasks like location pull, location push and location delete

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

Manual Test Steps

1) Run go test

$ cd pkg/datamover

$ go test

{"Command":"kopia --log-level=error --config-file=/tmp/kopia-repository --log-dir=/tmp/kopia-log --password=\u003c****\u003e repository create --no-check-for-updates --cache-directory=/tmp/kopia-cache --content-cache-size-mb=0 --metadata-cache-size-mb=500 --override-hostname=localhost --override-username=repositoryUser s3 --bucket=tests.kanister.io --endpoint=s3.amazonaws.com --prefix=kopia-repo-path-test/kopia-int/2023-08-29T08:48:52Z/29n4z/ --region=us-west-2","File":"pkg/kopia/command/common.go","Function":"github.com/kanisterio/kanister/pkg/kopia/command.stringSliceCommand","Line":38,"level":"info","msg":"Kopia Command","time":"2023-08-29T14:18:52.312648487+05:30"}
{"Command":"kopia --log-level=error --config-file=/tmp/kopia-repository --log-dir=/tmp/kopia-log server start --tls-generate-cert --address=https://0.0.0.0:54985 --tls-cert-file=/tmp/check-3731972233801028407/0/tls-fk9vv.cert --tls-key-file=/tmp/check-3731972233801028407/0/tls-fk9vv.key --server-username=user@localhost --server-password=\u003c****\u003e --server-control-username=user@localhost --server-control-password=\u003c****\u003e --no-grpc \u003e /dev/null 2\u003e\u00261 \u0026","File":"pkg/kopia/command/common.go","Function":"github.com/kanisterio/kanister/pkg/kopia/command.bashCommand","Line":33,"level":"info","msg":"Kopia Command","time":"2023-08-29T14:19:05.863662702+05:30"}
{"Command":"kopia --log-level=error --config-file=/tmp/kopia-repository --log-dir=/tmp/kopia-log --password=\u003c****\u003e server user add testuser@localhost --user-password=\u003c****\u003e","File":"pkg/kopia/command/common.go","Function":"github.com/kanisterio/kanister/pkg/kopia/command.stringSliceCommand","Line":38,"level":"info","msg":"Kopia Command","time":"2023-08-29T14:19:05.865403842+05:30"}
{"Command":"kopia --log-level=error --config-file=/tmp/kopia-repository --log-dir=/tmp/kopia-log --password=\u003c****\u003e server refresh --server-cert-fingerprint=\u003c****\u003e --address=https://0.0.0.0:54985 --server-username=user@localhost --server-password=\u003c****\u003e","File":"pkg/kopia/command/common.go","Function":"github.com/kanisterio/kanister/pkg/kopia/command.stringSliceCommand","Line":38,"level":"info","msg":"Kopia Command","time":"2023-08-29T14:19:13.628062139+05:30"}
Snapshotting testuser@localhost:/tmp/check-3731972233801028407/1 ...

Created snapshot with root k548573d97ba28e153a9370afc1217783 and ID 45c9ad46de4cfc98bac32428bd71ed39 in 3s
###Phase-output###: {"key":"kandoOutput","value":"{\"id\":\"45c9ad46de4cfc98bac32428bd71ed39\",\"logicalSize\":0,\"physicalSize\":0}"}
OK: 2 passed
PASS
ok      github.com/kanisterio/kanister/pkg/datamover    42.684s

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
@github-actions
Copy link
Contributor

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 Aug 29, 2023
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
r4rajat and others added 3 commits August 29, 2023 15:13
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
@r4rajat r4rajat changed the title Add tests for RepositoryServer Datamover Add Unit Tests for RepositoryServer Datamover Aug 29, 2023
Copy link
Contributor

@kale-amruta kale-amruta left a comment

Choose a reason for hiding this comment

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

Left few comments

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

@kale-amruta kale-amruta left a comment

Choose a reason for hiding this comment

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

lgtm

Kanister automation moved this from In Progress to Reviewer approved Aug 31, 2023
r4rajat and others added 4 commits August 31, 2023 20:15
Co-authored-by: kale-amruta <41624751+kale-amruta@users.noreply.github.com>
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
…datamover' into add-tests-for-repository-server-datamover
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
pkg/datamover/testutils.go Outdated Show resolved Hide resolved
repoConnectCmd, err := kopiacmd.RepositoryConnectCommand(repoCommandArgs)
c.Assert(err, IsNil)
_, err = Command(c, repoConnectCmd...)
if err != nil {
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 have a check if the error is due to the repo doesn't exist or some other 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.

Done

Comment on lines 73 to 76
switch a {
case "--access-key", "--secret-access-key", "--password", "--storage-account", "--storage-key":
redactNext = true
}
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 create maintain a map and check for the key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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

@PrasadG193 PrasadG193 left a comment

Choose a reason for hiding this comment

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

LGTM

@r4rajat r4rajat added the kueue label Sep 5, 2023
@mergify mergify bot merged commit 97fb058 into master Sep 5, 2023
16 checks passed
Kanister automation moved this from Reviewer approved to Done Sep 5, 2023
@mergify mergify bot deleted the add-tests-for-repository-server-datamover branch September 5, 2023 15:12
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

3 participants