def test_positive_update_sync_date(module_org): """Check if syncplan sync date can be updated :id: f0c17d7d-3e86-4b64-9747-6cba6809815e :expectedresults: Sync plan is created and sync plan is updated :BZ: 1336790 :CaseImportance: Critical """ # Set the sync date to today/right now today = datetime.now() sync_plan_name = gen_string('alphanumeric') new_sync_plan = make_sync_plan({ 'name': sync_plan_name, 'sync-date': today.strftime(SYNC_DATE_FMT), 'organization-id': module_org.id, }) # Assert that sync date matches data passed assert new_sync_plan['start-date'] == today.strftime("%Y/%m/%d %H:%M:%S") # Set sync date 5 days in the future future_date = today + timedelta(days=5) # Update sync interval SyncPlan.update({ 'id': new_sync_plan['id'], 'sync-date': future_date.strftime(SYNC_DATE_FMT) }) # Fetch it result = SyncPlan.info({'id': new_sync_plan['id']}) assert result['start-date'] != new_sync_plan['start-date'] assert datetime.strptime( result['start-date'], '%Y/%m/%d %H:%M:%S') > datetime.strptime( new_sync_plan['start-date'], '%Y/%m/%d %H:%M:%S'), 'Sync date was not updated'
def test_positive_update_1(self, test_data): """@Test: Check if syncplan description can be updated @Feature: Sync Plan @Assert: Sync plan is created and description is updated """ new_sync_plan = self._make_sync_plan() # Assert that description matches data passed self.assertNotEqual( new_sync_plan['description'], test_data['description'], ) # Update sync plan SyncPlan.update({ u'description': test_data['description'], u'id': new_sync_plan['id'], }) # Fetch it result = SyncPlan.info({u'id': new_sync_plan['id']}) # Assert that description matches new value self.assertEqual(result['description'], test_data['description']) # Assert that description does not matches original value self.assertNotEqual( new_sync_plan['description'], result['description'], )
def test_positive_update_2(self, test_data): """@Test: Check if syncplan interval be updated @Feature: Sync Plan @Assert: Sync plan interval is updated """ new_sync_plan = self._make_sync_plan({ u'interval': test_data['interval'], u'name': test_data['name'], }) # Assert that name and interval matches data passed self.assertEqual(new_sync_plan['name'], test_data['name']) self.assertEqual(new_sync_plan['interval'], test_data['interval']) # Update sync interval SyncPlan.update({ u'id': new_sync_plan['id'], u'interval': test_data['new-interval'], }) # Fetch it result = SyncPlan.info({u'id': new_sync_plan['id']}) # Assert that interval was updated self.assertEqual(result['interval'], test_data['new-interval']) self.assertNotEqual(new_sync_plan['interval'], result['interval'])
def test_positive_synchronize_custom_products_future_sync_date(self): """Create a sync plan with sync date in a future and sync multiple custom products with multiple repos automatically. :id: dd262cf3-b836-422c-baca-b3adbc532478 :expectedresults: Products are synchronized successfully. :CaseLevel: System """ delay = 6 * 60 # delay for sync date in seconds sync_plan = self._make_sync_plan({ 'enabled': 'true', 'organization-id': self.org['id'], 'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) products = [ make_product({'organization-id': self.org['id']}) for _ in range(3) ] repos = [ make_repository({'product-id': product['id']}) for product in products for _ in range(2) ] # Verify products have not been synced yet for repo in repos: with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) # Associate sync plan with products for product in products: Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time self.logger.info('Waiting {0} seconds to check products' ' were not synced'.format(delay/2)) sleep(delay/4) # Verify products has not been synced yet for repo in repos: with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) # Wait the rest of expected time self.logger.info('Waiting {0} seconds to check products' ' were synced'.format(delay/2)) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully for repo in repos: self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content( repo, ['errata', 'package-groups', 'packages'])
def test_positive_synchronize_custom_product_past_sync_date(self): """Create a sync plan with a past datetime as a sync date, add a custom product and verify the product gets synchronized on the next sync occurrence :id: 21efdd08-698c-443c-a681-edce19a4c83a :expectedresults: Product is synchronized successfully. :BZ: 1279539 :CaseLevel: System """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 2 * 60 product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': self.org['id'], 'sync-date': (datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay / 4, product['name'])) sleep(delay / 4) with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait until the first recurrence self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay, product['name'])) sleep(delay * 3 / 4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': (datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content(repo, ['errata', 'package-groups', 'packages'])
def test_positive_synchronize_custom_product_weekly_recurrence(self): """Create a weekly sync plan with a past datetime as a sync date, add a custom product and verify the product gets synchronized on the next sync occurrence :id: 1079a66d-7c23-44f6-a4a0-47f4c74d92a4 :expectedresults: Product is synchronized successfully. :BZ: 1396647 :CaseLevel: System """ delay = 5 * 60 product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) start_date = datetime.utcnow() - timedelta(weeks=1)\ + timedelta(seconds=delay) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'weekly', 'organization-id': self.org['id'], 'sync-date': start_date.strftime("%Y-%m-%d %H:%M:%S"), }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay / 4, product['name'])) sleep(delay / 4) with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait until the first recurrence self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay, product['name'])) sleep(delay * 3 / 4) # Re-calculate and Update with the current UTC time start_date = datetime.utcnow() - timedelta(weeks=1)\ + timedelta(seconds=delay) SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': start_date.strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content(repo, ['errata', 'package-groups', 'packages'])
def test_positive_synchronize_custom_product_future_sync_date(self): """Create a sync plan with sync date in a future and sync one custom product with it automatically. :id: 635bffe2-df98-4971-8950-40edc89e479e :expectedresults: Product is synchronized successfully. :CaseLevel: System """ delay = 5 * 60 # delay for sync date in seconds sync_plan = self._make_sync_plan({ 'enabled': 'true', 'organization-id': self.org['id'], 'sync-date': (datetime.utcnow() + timedelta(seconds=delay)).strftime("%Y-%m-%d %H:%M:%S"), }) product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) # Verify product is not synced and doesn't have any content self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay / 2, product['name'])) sleep(delay / 4) # Verify product has not been synced yet with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay / 2, product['name'])) sleep(delay * 3 / 4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': (datetime.utcnow() + timedelta(seconds=delay)).strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content(repo, ['errata', 'package-groups', 'packages'])
def test_positive_synchronize_custom_product_past_sync_date(self): """Create a sync plan with a past datetime as a sync date, add a custom product and verify the product gets synchronized on the next sync occurrence :id: 21efdd08-698c-443c-a681-edce19a4c83a :expectedresults: Product is synchronized successfully. :BZ: 1279539 :CaseLevel: System """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 2 * 60 product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': self.org['id'], 'sync-date': ( datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay/4, product['name'])) sleep(delay/4) with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait until the first recurrence self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay, product['name'])) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': ( datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content( repo, ['errata', 'package-groups', 'packages'])
def test_positive_synchronize_custom_product_weekly_recurrence(self): """Create a weekly sync plan with a past datetime as a sync date, add a custom product and verify the product gets synchronized on the next sync occurrence :id: 1079a66d-7c23-44f6-a4a0-47f4c74d92a4 :expectedresults: Product is synchronized successfully. :BZ: 1396647 :CaseLevel: System """ delay = 5 * 60 product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) start_date = datetime.utcnow() - timedelta(weeks=1)\ + timedelta(seconds=delay) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'weekly', 'organization-id': self.org['id'], 'sync-date': start_date.strftime("%Y-%m-%d %H:%M:%S"), }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay/4, product['name'])) sleep(delay/4) with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait until the first recurrence self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay, product['name'])) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time start_date = datetime.utcnow() - timedelta(weeks=1)\ + timedelta(seconds=delay) SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': start_date.strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content( repo, ['errata', 'package-groups', 'packages'])
def test_positive_update_description(module_org, new_desc): """Check if syncplan description can be updated :id: 00a279cd-1f49-4ebb-a59a-6f0b4e4cb83c :parametrized: yes :expectedresults: Sync plan is created and description is updated """ new_sync_plan = make_sync_plan({'organization-id': module_org.id}) SyncPlan.update({'description': new_desc, 'id': new_sync_plan['id']}) result = SyncPlan.info({'id': new_sync_plan['id']}) assert result['description'] == new_desc
def test_positive_update_sync_date(self): """Check if syncplan sync date can be updated :id: f0c17d7d-3e86-4b64-9747-6cba6809815e :expectedresults: Sync plan is created and sync plan is updated :BZ: 1336790 :CaseImportance: Critical """ # Set the sync date to today/right now today = datetime.now() sync_plan_name = gen_string('alphanumeric') new_sync_plan = self._make_sync_plan({ u'name': sync_plan_name, u'sync-date': today.strftime("%Y-%m-%d %H:%M:%S"), }) # Assert that sync date matches data passed self.assertEqual( new_sync_plan['start-date'], today.strftime("%Y/%m/%d %H:%M:%S"), ) # Set sync date 5 days in the future future_date = today + timedelta(days=5) # Update sync interval SyncPlan.update({ u'id': new_sync_plan['id'], u'sync-date': future_date.strftime("%Y-%m-%d %H:%M:%S"), }) # Fetch it result = SyncPlan.info({ u'id': new_sync_plan['id'], }) self.assertNotEqual(result['start-date'], new_sync_plan['start-date']) self.assertGreater( datetime.strptime( result['start-date'], '%Y/%m/%d %H:%M:%S', ), datetime.strptime( new_sync_plan['start-date'], '%Y/%m/%d %H:%M:%S', ), 'Sync date was not updated', )
def test_positive_synchronize_custom_product_future_sync_date(self): """Create a sync plan with sync date in a future and sync one custom product with it automatically. :id: 635bffe2-df98-4971-8950-40edc89e479e :expectedresults: Product is synchronized successfully. :CaseLevel: System """ delay = 5 * 60 # delay for sync date in seconds sync_plan = self._make_sync_plan({ 'enabled': 'true', 'organization-id': self.org['id'], 'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) product = make_product({'organization-id': self.org['id']}) repo = make_repository({'product-id': product['id']}) # Verify product is not synced and doesn't have any content self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay/2, product['name'])) sleep(delay/4) # Verify product has not been synced yet with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay/2, product['name'])) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content( repo, ['errata', 'package-groups', 'packages'])
def test_positive_update_description(self): """Check if syncplan description can be updated @Feature: Sync Plan @Assert: Sync plan is created and description is updated """ new_sync_plan = self._make_sync_plan() for new_desc in valid_data_list(): with self.subTest(new_desc): SyncPlan.update({ u'description': new_desc, u'id': new_sync_plan['id'], }) result = SyncPlan.info({u'id': new_sync_plan['id']}) self.assertEqual(result['description'], new_desc)
def test_positive_update_description(self): """Check if syncplan description can be updated @id: 00a279cd-1f49-4ebb-a59a-6f0b4e4cb83c @Assert: Sync plan is created and description is updated """ new_sync_plan = self._make_sync_plan() for new_desc in valid_data_list(): with self.subTest(new_desc): SyncPlan.update({ u'description': new_desc, u'id': new_sync_plan['id'], }) result = SyncPlan.info({u'id': new_sync_plan['id']}) self.assertEqual(result['description'], new_desc)
def test_positive_update_1(self, test_data): """@Test: Check if syncplan description can be updated @Feature: Sync Plan @Assert: Sync plan is created and description is updated """ new_sync_plan = self._make_sync_plan() # Assert that description matches data passed self.assertNotEqual( new_sync_plan['description'], test_data['description'], "Descriptions don't match" ) # Update sync plan result = SyncPlan.update( { u'id': new_sync_plan['id'], u'description': test_data['description'] } ) self.assertEqual( result.return_code, 0, "Sync plan was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = SyncPlan.info( { u'id': new_sync_plan['id'], } ) self.assertEqual( result.return_code, 0, "Sync plan was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Assert that description matches new value self.assertIsNotNone( result.stdout.get('description', None), "The description field was not returned" ) self.assertEqual( result.stdout['description'], test_data['description'], "Descriptions should match" ) # Assert that description does not matches original value self.assertNotEqual( new_sync_plan['description'], result.stdout['description'], "Descriptions should not match" )
def test_positive_update_3(self, test_data): """@Test: Check if syncplan sync date can be updated @Feature: Sync Plan @Assert: Sync plan is created and sync plan is updated """ # Set the sync date to today/right now today = datetime.now() new_sync_plan = self._make_sync_plan({ u'name': test_data['name'], u'sync-date': today.strftime("%Y-%m-%d %H:%M:%S"), }) # Assert that sync date matches data passed self.assertEqual( new_sync_plan['start-date'], today.strftime("%Y/%m/%d %H:%M:%S"), ) # Set sync date 5 days in the future future_date = today + timedelta(days=5) # Update sync interval result = SyncPlan.update({ u'id': new_sync_plan['id'], u'sync-date': future_date.strftime("%Y-%m-%d %H:%M:%S"), }) self.assertEqual( result.return_code, 0, "Sync plan was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = SyncPlan.info({ u'id': new_sync_plan['id'], }) self.assertEqual( result.return_code, 0, "Sync plan was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") self.assertNotEqual( result.stdout['start-date'], new_sync_plan['start-date'], "Sync date was not updated" ) self.assertGreater( datetime.strptime( result.stdout['start-date'], "%Y/%m/%d %H:%M:%S"), datetime.strptime( new_sync_plan['start-date'], "%Y/%m/%d %H:%M:%S"), "Sync date was not updated" )
def test_positive_update_description(self): """Check if syncplan description can be updated :id: 00a279cd-1f49-4ebb-a59a-6f0b4e4cb83c :expectedresults: Sync plan is created and description is updated :CaseImportance: Critical """ new_sync_plan = self._make_sync_plan() for new_desc in valid_data_list(): with self.subTest(new_desc): SyncPlan.update({ u'description': new_desc, u'id': new_sync_plan['id'], }) result = SyncPlan.info({u'id': new_sync_plan['id']}) self.assertEqual(result['description'], new_desc)
def test_positive_update_interval(self): """Check if syncplan interval be updated @Feature: Sync Plan @Assert: Sync plan interval is updated """ for test_data in valid_name_interval_update_tests(): with self.subTest(test_data): new_sync_plan = self._make_sync_plan({ u'interval': test_data['interval'], u'name': test_data['name'], }) SyncPlan.update({ u'id': new_sync_plan['id'], u'interval': test_data['new-interval'], }) result = SyncPlan.info({u'id': new_sync_plan['id']}) self.assertEqual(result['interval'], test_data['new-interval'])
def test_positive_update_interval(self): """Check if syncplan interval be updated @id: d676d7f3-9f7c-4375-bb8b-277d71af94b4 @Assert: Sync plan interval is updated """ for test_data in valid_name_interval_update_tests(): with self.subTest(test_data): new_sync_plan = self._make_sync_plan({ u'interval': test_data['interval'], u'name': test_data['name'], }) SyncPlan.update({ u'id': new_sync_plan['id'], u'interval': test_data['new-interval'], }) result = SyncPlan.info({u'id': new_sync_plan['id']}) self.assertEqual(result['interval'], test_data['new-interval'])
def test_positive_update_3(self): """@Test: Check if syncplan sync date can be updated @Feature: Sync Plan @Assert: Sync plan is created and sync plan is updated """ # Set the sync date to today/right now today = datetime.now() sync_plan_name = gen_string('alphanumeric') new_sync_plan = self._make_sync_plan({ u'name': sync_plan_name, u'sync-date': today.strftime("%Y-%m-%d %H:%M:%S"), }) # Assert that sync date matches data passed self.assertEqual( new_sync_plan['start-date'], today.strftime("%Y/%m/%d %H:%M:%S"), ) # Set sync date 5 days in the future future_date = today + timedelta(days=5) # Update sync interval SyncPlan.update({ u'id': new_sync_plan['id'], u'sync-date': future_date.strftime("%Y-%m-%d %H:%M:%S"), }) # Fetch it result = SyncPlan.info({ u'id': new_sync_plan['id'], }) self.assertNotEqual(result['start-date'], new_sync_plan['start-date']) self.assertGreater( datetime.strptime( result['start-date'], '%Y/%m/%d %H:%M:%S', ), datetime.strptime( new_sync_plan['start-date'], '%Y/%m/%d %H:%M:%S', ), 'Sync date was not updated', )
def test_positive_update_interval(self): """Check if syncplan interval be updated :id: d676d7f3-9f7c-4375-bb8b-277d71af94b4 :expectedresults: Sync plan interval is updated :CaseImportance: Critical """ for test_data in valid_name_interval_update_tests(): with self.subTest(test_data): new_sync_plan = self._make_sync_plan({ u'interval': test_data['interval'], u'name': test_data['name'], }) SyncPlan.update({ u'id': new_sync_plan['id'], u'interval': test_data['new-interval'], }) result = SyncPlan.info({u'id': new_sync_plan['id']}) self.assertEqual(result['interval'], test_data['new-interval'])
def test_positive_update_interval(module_org, test_data): """Check if syncplan interval can be updated :id: d676d7f3-9f7c-4375-bb8b-277d71af94b4 :parametrized: yes :expectedresults: Sync plan interval is updated :CaseImportance: Critical """ new_sync_plan = make_sync_plan( { 'interval': test_data['interval'], 'name': test_data['name'], 'organization-id': module_org.id, } ) SyncPlan.update({'id': new_sync_plan['id'], 'interval': test_data['new-interval']}) result = SyncPlan.info({'id': new_sync_plan['id']}) assert result['interval'] == test_data['new-interval']
def test_positive_update_interval(self): """Check if syncplan interval be updated :id: d676d7f3-9f7c-4375-bb8b-277d71af94b4 :expectedresults: Sync plan interval is updated :CaseImportance: Critical """ for test_data in valid_name_interval_update_tests(): with self.subTest(test_data): new_sync_plan = self._make_sync_plan({ 'interval': test_data['interval'], 'name': test_data['name'] }) SyncPlan.update({ 'id': new_sync_plan['id'], 'interval': test_data['new-interval'] }) result = SyncPlan.info({'id': new_sync_plan['id']}) self.assertEqual(result['interval'], test_data['new-interval'])
def test_positive_update_3(self, test_data): """@Test: Check if syncplan sync date can be updated @Feature: Sync Plan @Assert: Sync plan is created and sync plan is updated """ # Set the sync date to today/right now today = datetime.now() new_sync_plan = self._make_sync_plan({ u'name': test_data['name'], u'sync-date': today.strftime("%Y-%m-%d %H:%M:%S"), }) # Assert that sync date matches data passed self.assertEqual( new_sync_plan['start-date'], today.strftime("%Y/%m/%d %H:%M:%S"), ) # Set sync date 5 days in the future future_date = today + timedelta(days=5) # Update sync interval result = SyncPlan.update({ u'id': new_sync_plan['id'], u'sync-date': future_date.strftime("%Y-%m-%d %H:%M:%S"), }) self.assertEqual(result.return_code, 0, "Sync plan was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Fetch it result = SyncPlan.info({ u'id': new_sync_plan['id'], }) self.assertEqual(result.return_code, 0, "Sync plan was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") self.assertNotEqual(result.stdout['start-date'], new_sync_plan['start-date'], "Sync date was not updated") self.assertGreater( datetime.strptime(result.stdout['start-date'], "%Y/%m/%d %H:%M:%S"), datetime.strptime(new_sync_plan['start-date'], "%Y/%m/%d %H:%M:%S"), "Sync date was not updated")
def test_positive_update_1(self, test_data): """@Test: Check if syncplan description can be updated @Feature: Sync Plan @Assert: Sync plan is created and description is updated """ new_sync_plan = self._make_sync_plan() # Assert that description matches data passed self.assertNotEqual(new_sync_plan['description'], test_data['description'], "Descriptions don't match") # Update sync plan result = SyncPlan.update({ u'id': new_sync_plan['id'], u'description': test_data['description'] }) self.assertEqual(result.return_code, 0, "Sync plan was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Fetch it result = SyncPlan.info({ u'id': new_sync_plan['id'], }) self.assertEqual(result.return_code, 0, "Sync plan was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Assert that description matches new value self.assertIsNotNone(result.stdout.get('description', None), "The description field was not returned") self.assertEqual(result.stdout['description'], test_data['description'], "Descriptions should match") # Assert that description does not matches original value self.assertNotEqual(new_sync_plan['description'], result.stdout['description'], "Descriptions should not match")
def test_positive_update_2(self, test_data): """@Test: Check if syncplan interval be updated @Feature: Sync Plan @Assert: Sync plan interval is updated """ new_sync_plan = self._make_sync_plan({ u'name': test_data['name'], u'interval': test_data['interval'] }) # Assert that name and interval matches data passed self.assertEqual(new_sync_plan['name'], test_data['name'], "Descriptions don't match") self.assertEqual(new_sync_plan['interval'], test_data['interval'], "Intervals don't match") # Update sync interval result = SyncPlan.update({ u'id': new_sync_plan['id'], u'interval': test_data['new-interval'] }) self.assertEqual(result.return_code, 0, "Sync plan was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Fetch it result = SyncPlan.info({ u'id': new_sync_plan['id'], }) self.assertEqual(result.return_code, 0, "Sync plan was not updated") self.assertEqual(len(result.stderr), 0, "No error was expected") # Assert that interval was updated self.assertEqual(result.stdout['interval'], test_data['new-interval'], "Intervals don't match") self.assertNotEqual(new_sync_plan['interval'], result.stdout['interval'], "Intervals don't match")
def test_positive_synchronize_rh_product_future_sync_date(self): """Create a sync plan with sync date in a future and sync one RH product with it automatically. :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa :expectedresults: Product is synchronized successfully. :CaseLevel: System """ delay = 5 * 60 # delay for sync date in seconds org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'organization-id': org['id'], 'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Verify product is not synced and doesn't have any content with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay/2, product['name'])) sleep(delay/4) # Verify product has not been synced yet with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay/2, product['name'])) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content(repo, ['errata', 'packages'])
def test_positive_synchronize_rh_product_past_sync_date(self): """Create a sync plan with past datetime as a sync date, add a RH product and verify the product gets synchronized on the next sync occurrence :id: 47280ef4-3936-4dbc-8ed0-1076aa8d40df :expectedresults: Product is synchronized successfully. :BZ: 1279539 :CaseLevel: System """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 3 * 60 org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': org['id'], 'sync-date': ( datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay/4, product['name'])) sleep(delay/4) with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay, product['name'])) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': ( datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content(repo, ['errata', 'packages'])
def test_positive_update_2(self, test_data): """ @Test: Check if syncplan interval be updated @Feature: Sync Plan @Assert: Sync plan interval is updated """ new_sync_plan = self._make_sync_plan( { u'name': test_data['name'], u'interval': test_data['interval'] }) # Assert that name and interval matches data passed self.assertEqual( new_sync_plan['name'], test_data['name'], "Descriptions don't match" ) self.assertEqual( new_sync_plan['interval'], test_data['interval'], "Intervals don't match" ) # Update sync interval result = SyncPlan.update( { u'id': new_sync_plan['id'], u'interval': test_data['new-interval'] } ) self.assertEqual( result.return_code, 0, "Sync plan was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Fetch it result = SyncPlan.info( { u'id': new_sync_plan['id'], } ) self.assertEqual( result.return_code, 0, "Sync plan was not updated") self.assertEqual( len(result.stderr), 0, "No error was expected") # Assert that interval was updated self.assertEqual( result.stdout['interval'], test_data['new-interval'], "Intervals don't match" ) self.assertNotEqual( new_sync_plan['interval'], result.stdout['interval'], "Intervals don't match" )