Skip to content

Commit

Permalink
Add rbac test case for backup udf
Browse files Browse the repository at this point in the history
Change-Id: Idec4596c3ef5d4b7454ee7a020fb75d3ba31118d
Reviewed-on: http://review.couchbase.org/c/testrunner/+/160134
Reviewed-by: Ajay Bhullar <ajay.bhullar@couchbase.com>
Tested-by: Pierre Regazzoni <pierre.regazzoni@couchbase.com>
(cherry picked from commit 27cb45f)
Reviewed-on: http://review.couchbase.org/c/testrunner/+/161046
  • Loading branch information
pierrecouch committed Sep 10, 2021
1 parent 9a2737b commit be074d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions conf/tuq/py-tuq-backup-udf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tuqquery.tuq_backup_udf.QueryBackupUDFTests:
test_restore_all,compact=True
test_restore_all,disable=bucket
test_restore_all,disable=cluster
test_restore_all,role=data_backup
test_restore_include,include=bucket1
test_restore_include,include=bucket2
test_restore_include,include=bucket1.scope1
Expand Down
20 changes: 16 additions & 4 deletions pytests/tuqquery/tuq_backup_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def setUp(self):
self.map = self.input.param("map", "bucket1=bucket1b")
self.compact = self.input.param("compact", False)
self.disable = self.input.param("disable", None)
self.role = self.input.param("role", None)

self.backup_user = self.username
self.backup_password = self.password

self.log.info("============== QueryBackupUDFTests setup has completed ==============")
self.log_config_info()

Expand Down Expand Up @@ -55,7 +60,7 @@ def backup_config(self, archive="/backup-1", repo="my_backup"):
output = shell.execute_command(f"{self.path}/cbbackupmgr remove -a {archive} -r {repo}")
output = shell.execute_command(f"{self.path}/cbbackupmgr config -a {archive} -r {repo}")

def backuo_info(self, archive="/backup-1", repo="my_backup"):
def backup_info(self, archive="/backup-1", repo="my_backup"):
shell = RemoteMachineShellConnection(self.master)
output = shell.execute_command(f"{self.path}/cbbackupmgr info -a {archive} -r {repo} -j")
return self.convert_list_to_json(output[0])
Expand All @@ -67,15 +72,15 @@ def backup_merge(self, archive="/backup-1", repo="my_backup", start=1, end=2):

def backup(self, archive="/backup-1", repo="my_backup"):
shell = RemoteMachineShellConnection(self.master)
output = shell.execute_command(f"{self.path}/cbbackupmgr backup -a {archive} -r {repo} -c http://{self.master.ip}:8091 -u {self.username} -p {self.password}")
output = shell.execute_command(f"{self.path}/cbbackupmgr backup -a {archive} -r {repo} -c http://{self.master.ip}:8091 -u {self.backup_user} -p {self.backup_password}")
if self.compact:
self.log.info("Compacting backup")
compact = shell.execute_command(f"{self.path}/cbbackupmgr compact -a {archive} -r {repo} --backup latest")
self.log.info(compact)
return output

def restore(self, archive="/backup-1", repo="my_backup", disable=None, start=None, end=None, include=None, exclude=None, map=None):
bar_command=f"{self.path}/cbbackupmgr restore -a {archive} -r {repo} -c http://{self.master.ip}:8091 -u {self.username} -p {self.password}"
bar_command=f"{self.path}/cbbackupmgr restore -a {archive} -r {repo} -c http://{self.master.ip}:8091 -u {self.backup_user} -p {self.backup_password}"
if include:
bar_command += f" --include-data {include}"
if exclude:
Expand Down Expand Up @@ -120,7 +125,7 @@ def test_backup_info(self):
self.create_udf()
self.backup_config()
self.backup()
info = self.backuo_info()
info = self.backup_info()
global_count = info['backups'][0]['query_udfs']
self.assertEqual(global_count, 1)
scope_count = {}
Expand All @@ -130,6 +135,13 @@ def test_backup_info(self):
self.assertEqual(scope_count['bucket2'], 2)

def test_restore_all(self):
if self.role:
self.users = [{"id": "jackDoe", "name": "Jack Downing", "password": "password1"}]
self.create_users()
self.backup_user, self.backup_password = self.users[0]['id'], self.users[0]['password']
self.run_cbq_query(query=f"GRANT {self.role} on bucket1,bucket2,default to {self.backup_user}")
self.run_cbq_query(query=f"GRANT query_system_catalog to {self.backup_user}")

self.create_udf()
self.backup_config()
self.backup()
Expand Down

0 comments on commit be074d3

Please sign in to comment.