def test_positive_online_skip_pulp(self): """Katello-backup --online-backup with --skip-pulp-content option should not create pulp files in destination. :id: 0f0c1915-dd07-4571-9b05-e0778efc85b2 :Steps: 1. Run online backup with --skip-pulp-content option 2. List contents of the destination :expectedresults: ``/tmp/bck-no-pulp`` is created and pulp related files are not present. Services keep running. """ with get_connection() as connection: dir_name = make_random_tmp_directory(connection) connection.run('katello-service start') result = connection.run('katello-backup /tmp/{0} --online-backup ' '--skip-pulp-content'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(dir_name), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(dir_name), 'list') self.assertNotIn(u'pulp_data.tar', files.stdout) self.assertNotIn(u'.pulp.snar', files.stdout) # check if services are running correctly self.assertTrue(get_services_status()) tmp_directory_cleanup(connection, dir_name)
def test_positive_online_backup_with_existing_directory(self): """katello-backup --online-backup with existing directory :id: 3f8285d5-c68b-4d84-8568-bcd7e4f7f19e :Steps: 1. Create a directory (ie /tmp/xyz) 2. Run ``katello-backup --online-backup /tmp/xyz`` :expectedresults: The backup is successfully created in existing folder and contains all the default files needed to restore. Services keep running. """ with get_connection() as connection: dir_name = make_random_tmp_directory(connection) connection.run('katello-service start') result = connection.run( 'katello-backup /tmp/{0} --online-backup'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(dir_name), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(dir_name), ) # backup could have more files than the default so it is superset self.assertTrue( set(files.stdout).issuperset(set(HOT_BACKUP_FILES))) # check if services are running correctly self.assertTrue(get_services_status()) tmp_directory_cleanup(connection, dir_name)
def test_positive_skip_pulp(self): """Katello-backup with --skip-pulp-content option should not create pulp files in destination. :id: f0fa2daa-209e-4d46-9b67-3041768a2a77 :Steps: 1. Run online backup with --skip-pulp-content option 2. List contents of the destination :expectedresults: Backup is created and pulp related files are not present. Services are started back again. """ with get_connection() as connection: dir_name = make_random_tmp_directory(connection) result = connection.run('katello-backup /tmp/{0} ' '--skip-pulp-content'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(dir_name), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(dir_name), 'list') self.assertNotIn(u'pulp_data.tar', files.stdout) self.assertNotIn(u'.pulp.snar', files.stdout) # check if services are running correctly self.assertTrue(get_services_status()) tmp_directory_cleanup(connection, dir_name)
def test_positive_online_relative_path(self): """run katello-backup --online-backup with relative path :id: 3b5d8ac3-1ba1-4e3b-89f4-be950c8eef86 :Steps: 1. Run online backup to relative path 2. List contents of the destination :bz: 1444069 :expectedresults: backup is successful, foreman.dump and candlepin.dump are created """ with get_connection() as connection: connection.run('katello-service start') dir_name = gen_string('alpha') result = connection.run('katello-backup {0} --online-backup ' '--skip-pulp-content'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(dir_name), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(dir_name), 'list') self.assertIn(u'candlepin.dump', files.stdout) self.assertIn(u'foreman.dump', files.stdout) self.assertNotIn(u'pulp_data.tar', files.stdout) # check if services are running correctly self.assertTrue(get_services_status()) connection.run('rm -rf {0}'.format(dir_name))
def test_positive_online_backup_with_directory_created(self): """katello-backup --online with non-existing directory :id: 946991ad-125a-4f24-a33e-ea27fce38eda :Steps: 1. Ensure the directory /tmp/xyz does not exist. 2. Run ``katello-backup --online-backup /tmp/xyz`` :expectedresults: ``/tmp/xyz`` is created and the backup is saved to it containing all the default files needed to restore. Services keep running. """ with get_connection() as connection: dir_name = gen_string('alpha') tmp_directory_cleanup(connection, dir_name) connection.run('katello-service start') result = connection.run( 'katello-backup /tmp/{0} --online-backup'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(dir_name), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(dir_name), ) # backup could have more files than the default so it is superset self.assertTrue( set(files.stdout).issuperset(set(HOT_BACKUP_FILES))) # check if services are running correctly self.assertTrue(get_services_status()) tmp_directory_cleanup(connection, dir_name)
def check_services_status(self, max_attempts=5): for _ in range(max_attempts): try: result = get_services_status() self.assertEquals(result[0], 0) except AssertionError: sleep(30) else: break else: raise AssertionError(u'Some services failed to start:\ \n{0}'.format('\n'.join(result[1])))
def test_positive_online_incremental_skip_pulp(self): """Katello-backup with --online --skip-pulp-content and --incremental options :id: 49c42a81-88c3-4827-9b9e-6c41a8570234 :Steps: 1. Run full backup 2. Run online incremental backup without pulp from the previous backup :expectedresults: Incremental backup is created and pulp related files are not present. Services keep running. """ with get_connection() as connection: b1_dir = make_random_tmp_directory(connection) # run full backup result = connection.run( 'katello-backup /tmp/{0} --online-backup'.format(b1_dir), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(b1_dir), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(b1_dir), 'list') # backup could have more files than the default so it is superset self.assertTrue( set(files.stdout).issuperset(set(HOT_BACKUP_FILES))) # run incremental backup b1_dest = make_random_tmp_directory(connection) timestamped_dir = connection.run('ls /tmp/{0}/'.format(b1_dir), 'list') result = connection.run('''katello-backup --online-backup \ --skip-pulp-content /tmp/{0} \ --incremental /tmp/{1}/{2}'''.format( b1_dest, b1_dir, timestamped_dir.stdout[0]), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(b1_dest), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(b1_dest), 'list') self.assertNotIn(u'pulp_data.tar', files.stdout) rhel_release = ssh.command('lsb_release -r --short | cut -c1-1') if not bz_bug_is_open(1445224) or rhel_release == 6: self.assertNotIn(u'.pulp.snar', files.stdout) # check if services are running correctly self.assertTrue(get_services_status()) self.assertTrue(directory_size_compare(connection, b1_dir, b1_dest)) tmp_directory_cleanup(connection, b1_dir, b1_dest)
def check_services_status(self, max_attempts=5): for _ in range(max_attempts): try: result = get_services_status() self.assertEquals(result[0], 0) except AssertionError: sleep(30) else: break else: raise AssertionError( u'Some services failed to start:\ \n{0}'.format('\n'.join(result[1])))
def test_positive_incremental_skip_pulp(self): """Katello-backup with --skip-pulp-content and --incremental options :id: b2e6095c-648c-48a2-af5b-212c9d7e18e6 :Steps: 1. Run full backup 2. Run incremental backup without pulp from the previous backup :expectedresults: Incremental backup is created with and pulp related files are not present. Services are started back again. """ with get_connection() as connection: b1_dir = make_random_tmp_directory(connection) # run full backup result = connection.run( 'katello-backup /tmp/{0} --online-backup'.format(b1_dir), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(b1_dir), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(b1_dir), 'list') # backup could have more files than the default so it is superset self.assertTrue( set(files.stdout).issuperset(set(HOT_BACKUP_FILES))) # run incremental backup b1_dest = make_random_tmp_directory(connection) timestamped_dir = connection.run('ls /tmp/{0}/'.format(b1_dir), 'list') result = connection.run('''katello-backup \ --skip-pulp-content /tmp/{0} \ --incremental /tmp/{1}/{2}'''.format( b1_dest, b1_dir, timestamped_dir.stdout[0]), output_format='plain') self.assertEqual(result.return_code, 0) self.assertIn(BCK_MSG.format(b1_dest), result.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(b1_dest), 'list') self.assertNotIn(u'pulp_data.tar', files.stdout) # check if services are running correctly self.assertTrue(get_services_status()) self.assertTrue(directory_size_compare(connection, b1_dir, b1_dest)) tmp_directory_cleanup(connection, b1_dir, b1_dest)
def test_positive_incremental(self): """Katello-backup with --incremental option :id: 3bd1e85c-8c95-4198-a126-35eaf14572ed :Steps: 1. Run full backup 2. Run incremental backup from the previous backup :expectedresults: Incremental backup is created. Services are started back again. """ with get_connection() as connection: b1_dir = make_random_tmp_directory(connection) # run full backup result_full = connection.run( 'katello-backup /tmp/{0} --online-backup'.format(b1_dir), output_format='plain') self.assertEqual(result_full.return_code, 0) self.assertIn(BCK_MSG.format(b1_dir), result_full.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(b1_dir), 'list') # backup could have more files than the default so it is superset self.assertTrue( set(files.stdout).issuperset(set(HOT_BACKUP_FILES))) # run incremental backup b1_dest = make_random_tmp_directory(connection) timestamped_dir = connection.run('ls /tmp/{0}/'.format(b1_dir), 'list') result_inc = connection.run( 'katello-backup /tmp/{0} --incremental /tmp/{1}/{2}'.format( b1_dest, b1_dir, timestamped_dir.stdout[0]), output_format='plain') self.assertEqual(result_inc.return_code, 0) self.assertIn(BCK_MSG.format(b1_dest), result_inc.stdout) files = connection.run( 'ls -a /tmp/{0}/katello-backup*'.format(b1_dest), 'list') self.assertTrue(set(files.stdout).issuperset(set(BACKUP_FILES))) # check if services are running correctly self.assertTrue(get_services_status()) self.assertTrue(directory_size_compare(connection, b1_dir, b1_dest)) tmp_directory_cleanup(connection, b1_dir, b1_dest)
def test_negative_backup_with_no_directory(self): """katello-backup with no directory specified :id: e229a4e0-4944-4369-ab7f-0f4e65480e47 :Steps: 1. Run ``katello-backup`` :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: result = connection.run('katello-backup', output_format='plain') self.assertEqual(result.return_code, 1) self.assertIn(NODIR_MSG, result.stderr) self.assertTrue(get_services_status())
def test_negative_restore_no_directory(self): """run katello-restore with no directory specified :id: 61952f9b-1dbe-4154-83b6-f452eed798d6 :Steps: 1. Run ``katello-restore`` :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: result = connection.run('katello-restore', output_format='plain') self.assertEqual(result.return_code, 1) self.assertIn(NOVALID_MSG, result.stdout) self.assertTrue(get_services_status())
def test_negative_incremental_with_no_src_directory(self): """katello-backup --incremental with no source directory :id: 8bb36ffe-822e-448e-88cd-93885efd59a7 :Steps: 1. Run ``katello-backup --incremental`` :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: result = connection.run('katello-backup --incremental', output_format='plain') self.assertEqual(result.return_code, 1) self.assertIn(NOPREV_MSG, result.stderr) self.assertTrue(get_services_status())
def test_negative_incremental_with_no_dest_directory(self): """katello-backup --incremental with no destination directory :id: 183195df-b5df-4edf-814e-221bbcdcbde1 :Steps: 1. Run ``katello-backup --incremental /tmp`` :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: result = connection.run('katello-backup --incremental /tmp', output_format='plain') self.assertEqual(result.return_code, 1) self.assertIn(NODIR_MSG, result.stderr) self.assertTrue(get_services_status())
def test_negative_online_backup_with_no_directory(self): """katello-backup --online-backup with no directory :id: e5f58d05-1043-48c0-971f-8f30cc8642ed :Steps: 1. Run ``katello-backup --online-backup`` :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: result = connection.run('katello-backup --online-backup', output_format='plain') self.assertEqual(result.return_code, 1) self.assertIn(NODIR_MSG, result.stderr) self.assertTrue(get_services_status())
def test_negative_restore_nonexistent_directory(self): """run katello-restore with nonexistent directory specified :id: d825c43e-1be0-4aea-adcf-23fcf98e73c8 :Steps: 1. Run ``katello-restore`` fake_dir_name :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: name = gen_string('alpha') result = connection.run('katello-restore {}'.format(name), output_format='plain') self.assertEqual(result.return_code, 255) self.assertIn(NOVALID_MSG, result.stdout) self.assertTrue(get_services_status())
def test_negative_restore_with_empty_directory(self): """katello-backup with no directory specified :id: e229a4e0-4944-4369-ab7f-0f4e65480e47 :Steps: 1. Run ``katello-backup`` empty_dir :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: dir_name = make_random_tmp_directory(connection) result = connection.run( 'katello-restore -y /tmp/{}'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 255) self.assertIn(NOFILES_MSG, result.stdout) self.assertTrue(get_services_status())
def test_negative_incremental_with_invalid_dest_directory(self): """katello-backup --incremental with invalid destination directory :id: 1667f35e-049e-4a1a-ae7a-a2da6661b3d8 :Steps: 1. Run ``katello-backup /tmp --incremental nonexistent`` :expectedresults: The error message is shown, services are not stopped """ with get_connection() as connection: dir_name = gen_string('alpha') tmp_directory_cleanup(connection, dir_name) result = connection.run( 'katello-backup /tmp --incremental {0}'.format(dir_name), output_format='plain') self.assertEqual(result.return_code, 1) self.assertIn(BADPREV_MSG.format(dir_name), result.stderr) self.assertTrue(get_services_status())