Example #1
0
 def run_step(self, pipeline_data):
     client = redis.get_client()
     cluster_name = pipeline_data[data_defs.APPLICATION_CLUSTER]
     application_name = pipeline_data[data_defs.APPLICATION_NAME]
     key = f'{cluster_name}.{application_name}'
     redis.execute_json_delete(client, key)
     return pipeline_data
Example #2
0
 def run_step(self, pipeline_data):
     redis_client = redis.get_client()
     cache_key = get_cache_key(pipeline_data)
     cache_entry = redis.execute_json_get(redis_client, cache_key)
     self.log.debug('Got cache entry "%s"', cache_entry)
     pipeline_data[data_defs.CACHE_ENTRY] = cache_entry
     return pipeline_data
Example #3
0
 def run_step(self, pipeline_data):
     redis_client = redis.get_client()
     image_versions = self.generate_image_versions(pipeline_data)
     cache_entry = self.generate_cache_entry(pipeline_data, image_versions)
     cache_key = get_cache_key(pipeline_data)
     redis.execute_json_set(redis_client, cache_key, cache_entry)
     self.log.debug('Wrote cache entry "%s" for key "%s"', cache_entry,
                    cache_key)
     return pipeline_data
Example #4
0
 def test_2_delete_entire_cache(self):
     client = redis.get_client()
     redis.execute_json_set(client, 'test.Key.1', {'value': 'testValue'})
     redis.execute_json_set(client, 'test.Key.2', {'value': 'testValue'})
     redis.delete_entire_cache()
     # Allow the cache to be flushed
     time.sleep(0.5)
     self.assertIsNone(redis.execute_json_get(client, 'test.Key.1'))
     self.assertIsNone(redis.execute_json_get(client, 'test.Key.2'))
Example #5
0
 def test_1_get_set_delete(self):
     client = redis.get_client()
     redis.execute_json_set(client, 'test.Key', {'value': 'testValue'})
     # Allow the object to be written
     time.sleep(0.5)
     result = redis.execute_json_get(client, 'test.Key')
     self.assertEqual(result, {'value': 'testValue'})
     redis.execute_json_delete(client, 'test.Key')
     # Allow the object to be deleted
     time.sleep(0.5)
     result = redis.execute_json_get(client, 'test.Key')
     self.assertIsNone(result)
Example #6
0
File: run.py Project: KTH/aspen
def get_status(mgt_res_grp):
    logger = logging.getLogger(__name__)
    logger.info('Returning status')
    redis_client = redis.get_client()
    cache_size = redis.get_management_key_count(redis_client, mgt_res_grp)
    sync_thread = thread.get_sync_thread()
    if not sync_thread:
        running = False
    else:
        running = sync_thread.stopped()
    status = {'sync_thread_running': running, 'cache_size': cache_size}
    return jsonify(status)
Example #7
0
 def test_5_key_count(self):
     client = redis.get_client()
     redis.delete_entire_cache()
     redis.execute_json_set(
         client, 'dev-ev/repos/deploy/tamarack/stage/docker-stack.yml',
         {'value': '1'})
     redis.execute_json_set(
         client, 'everest-management/repos/deploy/tamarack-test/test',
         {'value': '2'})
     redis.execute_json_set(
         client, 'everest-management/repos/deploy/tamarack-test2/test',
         {'value': '3'})
     key_count = redis.get_management_key_count(client, 'dev-ev')
     self.assertEqual(key_count, 1)
     key_count = redis.get_management_key_count(client,
                                                'everest-management')
     self.assertEqual(key_count, 2)
Example #8
0
 def test_3_clear_cache_for_cluster_and_app(self):
     client = redis.get_client()
     redis.delete_entire_cache()
     time.sleep(0.5)
     mgt_res_grp = 'everest-management'
     redis.execute_json_set(
         client,
         f'{mgt_res_grp}/repos/deploy/tamarack/stage/docker-stack.yml',
         {'value': '1'})
     redis.execute_json_set(client,
                            f'{mgt_res_grp}/repos/deploy/tamarack/active',
                            {'value': '2'})
     redis.execute_json_set(
         client, f'{mgt_res_grp}/repos/deploy/kth-azure-app/active',
         {'value': '3'})
     redis.execute_json_set(
         client, f'error/{mgt_res_grp}/repos/deploy/kth-azure-app/stage',
         {'value': '4'})
     time.sleep(0.5)
     keys = redis.get_all_keys(client)
     self.assertEqual(len(keys), 4)
     redis.clear_cache_for_cluster_and_app(client, 'everest-management',
                                           'stage', 'tamarack')
     keys = redis.get_all_keys(client)
     self.assertEqual(len(keys), 3)
     self.assertTrue(f'{mgt_res_grp}/repos/deploy/tamarack/active' in keys)
     self.assertTrue(
         f'{mgt_res_grp}/repos/deploy/kth-azure-app/active' in keys)
     self.assertTrue(
         f'error/{mgt_res_grp}/repos/deploy/kth-azure-app/stage' in keys)
     redis.clear_cache_for_cluster_and_app(client, 'everest-management',
                                           'active', 'kth-azure-app')
     keys = redis.get_all_keys(client)
     self.assertEqual(len(keys), 2)
     self.assertTrue(
         f'error/{mgt_res_grp}/repos/deploy/kth-azure-app/stage' in keys)
     self.assertTrue(f'{mgt_res_grp}/repos/deploy/tamarack/active' in keys)
Example #9
0
 def test_4_clear_cache_for_cluster(self):
     client = redis.get_client()
     redis.delete_entire_cache()
     time.sleep(0.5)
     mgt_res_grp = 'dev-ev'
     redis.execute_json_set(
         client,
         f'{mgt_res_grp}/repos/deploy/tamarack/stage/docker-stack.yml',
         {'value': '1'})
     redis.execute_json_set(
         client, f'{mgt_res_grp}/repos/deploy/tamarack-test/test',
         {'value': '2'})
     redis.execute_json_set(
         client, f'error/{mgt_res_grp}/repos/deploy/tamarack-test/test',
         {'value': '2'})
     redis.execute_json_set(
         client, f'{mgt_res_grp}/repos/deploy/tamarack-test/active',
         {'value': '3'})
     time.sleep(0.5)
     redis.clear_cache_for_cluster(client, 'dev-ev', 'test')
     keys = redis.get_all_keys(client)
     self.assertEqual(len(keys), 3)
     self.assertTrue(
         f'{mgt_res_grp}/repos/deploy/tamarack/stage/docker-stack.yml' in
         keys)
     self.assertTrue(
         f'error/{mgt_res_grp}/repos/deploy/tamarack-test/test' in keys)
     self.assertTrue(
         f'{mgt_res_grp}/repos/deploy/tamarack-test/active' in keys)
     redis.clear_cache_for_cluster(client, 'dev-ev', 'stage')
     keys = redis.get_all_keys(client)
     self.assertEqual(len(keys), 2)
     self.assertTrue(
         f'error/{mgt_res_grp}/repos/deploy/tamarack-test/test' in keys)
     self.assertTrue(
         f'{mgt_res_grp}/repos/deploy/tamarack-test/active' in keys)
Example #10
0
def get_error_cache(error_cache_key):
    if not error_cache_key:
        return None
    redis_client = redis.get_client()
    return redis.execute_json_get(redis_client, error_cache_key)
Example #11
0
def write_to_error_cache(error: exceptions.DeploymentError):
    pipeline_data = error.pipeline_data
    cache_key = get_cache_key(pipeline_data)
    cache_entry = create_cache_entry(error.step_name)
    redis_client = redis.get_client()
    redis.execute_json_set(redis_client, cache_key, cache_entry)
Example #12
0
 def test_0_get_client(self):
     client = redis.get_client()
     self.assertIsNotNone(client)
Example #13
0
File: run.py Project: KTH/aspen
def clear_cluster_from_cache(mgt_res_grp, cluster):
    client = redis.get_client()
    redis.clear_cache_for_cluster(client, mgt_res_grp, cluster)
    return jsonify(message='Cache cleared')