Skip to content

Commit

Permalink
use json to get backup count if cbbackupmgr version >= 6.6
Browse files Browse the repository at this point in the history
Change-Id: Icb0b2a2b80763a75c1ef93f24fa25bd945d013e1
Reviewed-on: http://review.couchbase.org/c/testrunner/+/152517
Tested-by: Thuan Nguyen <soccon@gmail.com>
Reviewed-by: Arunkumar Senthilnathan <arun.couchbase@yahoo.com>
  • Loading branch information
saigon authored and arod1987 committed Apr 29, 2021
1 parent 92900a0 commit d4cbffd
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions pytests/ent_backup_restore/enterprise_backup_restore_bwc.py
@@ -1,3 +1,4 @@
import json
from random import randrange
from couchbase_helper.cluster import Cluster
from couchbase_helper.documentgenerator import BlobGenerator, DocumentGenerator
Expand Down Expand Up @@ -311,21 +312,37 @@ def test_backup_merge_bwc(self):
if not status:
self.fail(message)
backup_count = 0
""" remove last 6 chars of offset time in backup name"""
if self.backups and self.backups[0][-3:] == "_00":
strip_backupset = [s[:-6] for s in self.backups]

for line in output:
if "entbackup" in line:
continue
if re.search("\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}.\d+", line):
backup_name = re.search("\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}.\d+", line).group()
if self.debug_logs:
print "backup name ", backup_name
print "backup set ", strip_backupset
if backup_name in strip_backupset:
backup_count += 1
self.log.info("{0} matched in list command output".format(backup_name))
if self.backupset.current_bkrs_client_version[:3] < "6.6":
""" remove last 6 chars of offset time in backup name """
if self.backups and self.backups[0][-3:] == "_00":
strip_backupset = [s[:-6] for s in self.backups]
for line in output:
if "entbackup" in line:
continue
if re.search("\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}.\d+", line):
backup_name = re.search("\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}.\d+", line).group()
if self.debug_logs:
print "backup name ", backup_name
print "backup set ", strip_backupset
if backup_name in strip_backupset:
backup_count += 1
self.log.info("{0} matched in list command output".format(backup_name))
else:
if output and output[0]:
bk_info = json.loads(output[0])
bk_info = bk_info["repos"][0]
else:
return False, "No output content"
if bk_info["backups"]:
for i in range(0, len(bk_info["backups"])):
backup_name = bk_info["backups"][i]["date"]
if self.debug_logs:
print("backup name ", backup_name)
print("backup set ", self.backups)
if backup_name in self.backups:
backup_count += 1
self.log.info("{0} matched in info command output".format(backup_name))
self.assertEqual(backup_count, len(strip_backupset), "Initial number of backups did not match")
self.log.info("Initial number of backups matched")
self.backupset.start = randrange(1, self.backupset.number_of_backups)
Expand Down

0 comments on commit d4cbffd

Please sign in to comment.