Exemplo n.º 1
0
    def test_service_specific_defaults_no_mutate_default_retry(self):
        retry = translate.build_retry_config('sts', self.retry['retry'],
                                             self.retry['definitions'])
        # sts has a specific policy
        self.assertEqual(
            retry['__default__'], {
                "max_attempts": 5,
                "delay": "service_specific_delay",
                "policies": {
                    "global_one": "global",
                    "override_me": "service",
                    "service_one": "service",
                }
            })

        # The general defaults for the upstream model should not have been
        # mutated from building the retry config
        self.assertEqual(
            self.retry['retry']['__default__'], {
                "max_attempts": 5,
                "delay": "global_delay",
                "policies": {
                    "global_one": "global",
                    "override_me": "global",
                }
            })
 def test_resolve_reference(self):
     retry = translate.build_retry_config('sts', self.retry['retry'],
                                          self.retry['definitions'])
     operation_config = retry['AssumeRole']
     # And we should resolve references.
     self.assertEqual(operation_config['policies']['other'],
                      {"from": {
                          "definition": "file"
                      }})
Exemplo n.º 3
0
 def test_client_override_max_attempts(self):
     retry = translate.build_retry_config(
         'sts',
         self.retry['retry'],
         self.retry['definitions'],
         client_retry_config={'max_attempts': 9})
     self.assertEqual(retry['__default__']['max_attempts'], 10)
     # But it should not mutate the original retry model
     self.assertEqual(self.retry['retry']['__default__']['max_attempts'], 5)
 def test_inject_retry_config(self):
     retry = translate.build_retry_config('sts', self.retry['retry'],
                                          self.retry['definitions'])
     self.assertIn('__default__', retry)
     self.assertEqual(
         retry['__default__'], {
             "max_attempts": 5,
             "delay": "service_specific_delay",
             "policies": {
                 "global_one": "global",
                 "override_me": "service",
                 "service_one": "service",
             }
         })
     # Policies should be merged.
     operation_config = retry['AssumeRole']
     self.assertEqual(operation_config['policies']['name'], 'policy')
Exemplo n.º 5
0
def _load_retry_config(loader, endpoint_prefix):
    original_config = loader.load_data('_retry')
    retry_config = translate.build_retry_config(
        endpoint_prefix, original_config['retry'],
        original_config.get('definitions', {}))
    return retry_config