예제 #1
0
파일: test_config.py 프로젝트: dcos/dcos
def test_exhibitor_storage_master_discovery():
    msg_master_discovery = "When master_discovery is not static, exhibitor_storage_backend must be " \
        "non-static. Having a variable list of master which are discovered by agents using the " \
        "master_discovery method but also having a fixed known at install time static list of " \
        "master ips doesn't `master_http_load_balancer` then exhibitor_storage_backend must not " \
        "be static."

    validate_success({
        'exhibitor_storage_backend': 'static',
        'master_discovery': 'static'})
    validate_success({
        'exhibitor_storage_backend': 'aws_s3',
        'master_discovery': 'master_http_loadbalancer',
        'aws_region': 'foo',
        'exhibitor_address': 'http://foobar',
        'exhibitor_explicit_keys': 'false',
        'num_masters': '5',
        's3_bucket': 'baz',
        's3_prefix': 'mofo'})
    validate_success({
        'exhibitor_storage_backend': 'aws_s3',
        'master_discovery': 'static',
        'exhibitor_explicit_keys': 'false',
        's3_bucket': 'foo',
        'aws_region': 'bar',
        's3_prefix': 'baz/bar'})
    validate_error_multikey(
        {'exhibitor_storage_backend': 'static',
         'master_discovery': 'master_http_loadbalancer'},
        ['exhibitor_storage_backend', 'master_discovery'],
        msg_master_discovery,
        unset={'exhibitor_address', 'num_masters'})
예제 #2
0
def test_exhibitor_storage_master_discovery():
    msg_master_discovery = "When master_discovery is not static, exhibitor_storage_backend must be " \
        "non-static. Having a variable list of master which are discovered by agents using the " \
        "master_discovery method but also having a fixed known at install time static list of " \
        "master ips doesn't `master_http_load_balancer` then exhibitor_storage_backend must not " \
        "be static."

    validate_success({
        'exhibitor_storage_backend': 'static',
        'master_discovery': 'static'})
    validate_success({
        'exhibitor_storage_backend': 'aws_s3',
        'master_discovery': 'master_http_loadbalancer',
        'aws_region': 'foo',
        'exhibitor_address': 'http://foobar',
        'exhibitor_explicit_keys': 'false',
        'num_masters': '5',
        's3_bucket': 'baz',
        's3_prefix': 'mofo'})
    validate_success({
        'exhibitor_storage_backend': 'aws_s3',
        'master_discovery': 'static',
        'exhibitor_explicit_keys': 'false',
        's3_bucket': 'foo',
        'aws_region': 'bar',
        's3_prefix': 'baz/bar'})
    validate_error_multikey(
        {'exhibitor_storage_backend': 'static',
         'master_discovery': 'master_http_loadbalancer'},
        ['exhibitor_storage_backend', 'master_discovery'],
        msg_master_discovery,
        unset={'exhibitor_address', 'num_masters'})
예제 #3
0
 def test_public_key_not_provided(self):
     """
     An error is shown when ``superuser_service_account_uid`` is
     provided but ``superuser_service_account_public_key`` is not.
     """
     validate_error_multikey(
         new_arguments={'superuser_service_account_uid': str(uuid.uuid4())},
         keys=[
             'superuser_service_account_uid',
             'superuser_service_account_public_key',
         ],
         message=("'superuser_service_account_uid' and "
                  "'superuser_service_account_public_key' "
                  "must both be empty or both be non-empty"))
예제 #4
0
파일: test_config.py 프로젝트: dcos/dcos
def test_validate_default_overlay_network_name():
    msg = "Default overlay network name does not reference a defined overlay network: foo"
    validate_error_multikey(
        {'dcos_overlay_network': json.dumps({
            'vtep_subnet': '44.128.0.0/20',
            'vtep_subnet6': 'fd01:a::/64',
            'vtep_mac_oui': '70:B3:D5:00:00:00',
            'overlays': [{
                'name': 'bar',
                'subnet': '1.1.1.0/24',
                'prefix': 24
            }],
        }), 'dcos_overlay_network_default_name': 'foo'},
        ['dcos_overlay_network_default_name', 'dcos_overlay_network'],
        msg)
예제 #5
0
def test_validate_default_overlay_network_name():
    msg = "Default overlay network name does not reference a defined overlay network: foo"
    validate_error_multikey(
        {'dcos_overlay_network': json.dumps({
            'vtep_subnet': '44.128.0.0/20',
            'vtep_subnet6': 'fd01:a::/64',
            'vtep_mac_oui': '70:B3:D5:00:00:00',
            'overlays': [{
                'name': 'bar',
                'subnet': '1.1.1.0/24',
                'prefix': 24
            }],
        }), 'dcos_overlay_network_default_name': 'foo'},
        ['dcos_overlay_network_default_name', 'dcos_overlay_network'],
        msg)
예제 #6
0
 def test_public_key_not_provided(self):
     """
     An error is shown when ``superuser_service_account_uid`` is
     provided but ``superuser_service_account_public_key`` is not.
     """
     validate_error_multikey(
         new_arguments={'superuser_service_account_uid': str(uuid.uuid4())},
         keys=[
             'superuser_service_account_uid',
             'superuser_service_account_public_key',
         ],
         message=(
             "'superuser_service_account_uid' and "
             "'superuser_service_account_public_key' "
             "must both be empty or both be non-empty"
         )
     )
예제 #7
0
 def test_provided_uid_empty(self):
     """
     An error is shown when an empty ``superuser_service_account_uid``
     is together with a valid ``superuser_service_account_public_key``.
     """
     validate_error_multikey(
         new_arguments={
             'superuser_service_account_uid': '',
             'superuser_service_account_public_key':
             generate_rsa_public_key(),
         },
         keys=[
             'superuser_service_account_uid',
             'superuser_service_account_public_key',
         ],
         message=("'superuser_service_account_uid' and "
                  "'superuser_service_account_public_key' "
                  "must both be empty or both be non-empty"))
예제 #8
0
 def test_provided_uid_empty(self):
     """
     An error is shown when an empty ``superuser_service_account_uid``
     is together with a valid ``superuser_service_account_public_key``.
     """
     validate_error_multikey(
         new_arguments={
             'superuser_service_account_uid': '',
             'superuser_service_account_public_key': generate_rsa_public_key(),
         },
         keys=[
             'superuser_service_account_uid',
             'superuser_service_account_public_key',
         ],
         message=(
             "'superuser_service_account_uid' and "
             "'superuser_service_account_public_key' "
             "must both be empty or both be non-empty"
         )
     )
예제 #9
0
def test_validate_mesos_default_container_shm_size():
    validate_success({'mesos_default_container_shm_size': '64MB'})

    validate_success({'mesos_default_container_shm_size': '1gb'})

    validate_error_multikey({'mesos_default_container_shm_size': '64.5MB'}, [
        'mesos_default_container_shm_size',
        'has_mesos_default_container_shm_size'
    ], "Fractional bytes: 64.5.")

    validate_error_multikey({'mesos_default_container_shm_size': 'asdf'}, [
        'mesos_default_container_shm_size',
        'has_mesos_default_container_shm_size'
    ], "Error parsing 'mesos_default_container_shm_size' value: asdf.")

    validate_error_multikey({'mesos_default_container_shm_size': '64PB'}, [
        'mesos_default_container_shm_size',
        'has_mesos_default_container_shm_size'
    ], "Unit 'PB' not in ['B', 'KB', 'MB', 'GB', 'TB'].")
예제 #10
0
def test_validate_custom_checks():
    check_config = json.dumps({
        'cluster_checks': {
            'cluster-check-1': {
                'description': 'Cluster check 1',
                'cmd': ['echo', 'cluster-check-1'],
                'timeout': '1s',
            },
        },
        'node_checks': {
            'checks': {
                'node-check-1': {
                    'description': 'Node check 1',
                    'cmd': ['echo', 'node-check-1'],
                    'timeout': '1s',
                },
                'node-check-2': {
                    'description': 'Node check 2',
                    'cmd': ['echo', 'node-check-2'],
                    'timeout': '1s',
                    'roles': ['agent']
                },
            },
            'prestart': ['node-check-1'],
            'poststart': ['node-check-1', 'node-check-2'],
        },
    })
    custom_checks = json.dumps({
        'cluster_checks': {
            'custom-cluster-check-1': {
                'description': 'Custom cluster check 1',
                'cmd': ['echo', 'custom-cluster-check-1'],
                'timeout': '1s',
            },
        },
        'node_checks': {
            'checks': {
                'custom-node-check-1': {
                    'description': 'Custom node check 1',
                    'cmd': ['echo', 'custom-node-check-1'],
                    'timeout': '1s',
                },
            },
            'prestart': ['custom-node-check-1'],
            'poststart': ['custom-node-check-1'],
        }
    })

    # Empty and non-empty check_config and custom_checks.
    validate_success({
        'check_config': json.dumps({}),
        'custom_checks': json.dumps({}),
    })
    validate_success({
        'check_config': check_config,
        'custom_checks': json.dumps({}),
    })
    validate_success({
        'check_config': check_config,
        'custom_checks': custom_checks,
    })
    validate_success({
        'check_config': json.dumps({}),
        'custom_checks': custom_checks,
    })

    # Invalid custom checks.
    validate_error(
        {
            'custom_checks':
            json.dumps({
                'node_checks': {
                    'checks': {
                        'node-check-1': {
                            'description': 'Node check 1',
                            'cmd': ['echo', 'node-check-1'],
                            'timeout': '1s',
                        },
                        'node-check-2': {
                            'description': 'Node check 2',
                            'cmd': ['echo', 'node-check-2'],
                            'timeout': '1s',
                        },
                    },
                    'poststart':
                    ['node-check-1', 'node-check-2', 'node-check-3'],
                },
            })
        },
        'custom_checks',
        'All node checks must be referenced in either prestart or poststart, or both',
    )

    # Custom checks re-use check name used by builtin checks.
    validate_error_multikey(
        {
            'check_config':
            check_config,
            'custom_checks':
            json.dumps({
                'cluster_checks': {
                    'cluster-check-1': {
                        'description': 'Cluster check 1',
                        'cmd': ['echo', 'cluster-check-1'],
                        'timeout': '1s',
                    },
                },
                'node_checks': {
                    'checks': {
                        'node-check-1': {
                            'description': 'Node check 1',
                            'cmd': ['echo', 'node-check-1'],
                            'timeout': '1s',
                        },
                        'node-check-2': {
                            'description': 'Node check 2',
                            'cmd': ['echo', 'node-check-2'],
                            'timeout': '1s',
                        },
                    },
                    'poststart': ['node-check-1', 'node-check-2'],
                },
            }),
        },
        ['check_config', 'custom_checks'],
        ('Custom check names conflict with builtin checks. Reserved cluster check names: cluster-check-1. Reserved '
         'node check names: node-check-1, node-check-2.'),
    )
예제 #11
0
파일: test_config.py 프로젝트: dcos/dcos
def test_validate_custom_checks():
    check_config = json.dumps({
        'cluster_checks': {
            'cluster-check-1': {
                'description': 'Cluster check 1',
                'cmd': ['echo', 'cluster-check-1'],
                'timeout': '1s',
            },
        },
        'node_checks': {
            'checks': {
                'node-check-1': {
                    'description': 'Node check 1',
                    'cmd': ['echo', 'node-check-1'],
                    'timeout': '1s',
                },
                'node-check-2': {
                    'description': 'Node check 2',
                    'cmd': ['echo', 'node-check-2'],
                    'timeout': '1s',
                    'roles': ['agent']
                },
            },
            'prestart': ['node-check-1'],
            'poststart': ['node-check-1', 'node-check-2'],
        },
    })
    custom_checks = json.dumps({
        'cluster_checks': {
            'custom-cluster-check-1': {
                'description': 'Custom cluster check 1',
                'cmd': ['echo', 'custom-cluster-check-1'],
                'timeout': '1s',
            },
        },
        'node_checks': {
            'checks': {
                'custom-node-check-1': {
                    'description': 'Custom node check 1',
                    'cmd': ['echo', 'custom-node-check-1'],
                    'timeout': '1s',
                },
            },
            'prestart': ['custom-node-check-1'],
            'poststart': ['custom-node-check-1'],
        }
    })

    # Empty and non-empty check_config and custom_checks.
    validate_success({
        'check_config': json.dumps({}),
        'custom_checks': json.dumps({}),
    })
    validate_success({
        'check_config': check_config,
        'custom_checks': json.dumps({}),
    })
    validate_success({
        'check_config': check_config,
        'custom_checks': custom_checks,
    })
    validate_success({
        'check_config': json.dumps({}),
        'custom_checks': custom_checks,
    })

    # Invalid custom checks.
    validate_error(
        {
            'custom_checks': json.dumps({
                'node_checks': {
                    'checks': {
                        'node-check-1': {
                            'description': 'Node check 1',
                            'cmd': ['echo', 'node-check-1'],
                            'timeout': '1s',
                        },
                        'node-check-2': {
                            'description': 'Node check 2',
                            'cmd': ['echo', 'node-check-2'],
                            'timeout': '1s',
                        },
                    },
                    'poststart': ['node-check-1', 'node-check-2', 'node-check-3'],
                },
            })
        },
        'custom_checks',
        'All node checks must be referenced in either prestart or poststart, or both',
    )

    # Custom checks re-use check name used by builtin checks.
    validate_error_multikey(
        {
            'check_config': check_config,
            'custom_checks': json.dumps({
                'cluster_checks': {
                    'cluster-check-1': {
                        'description': 'Cluster check 1',
                        'cmd': ['echo', 'cluster-check-1'],
                        'timeout': '1s',
                    },
                },
                'node_checks': {
                    'checks': {
                        'node-check-1': {
                            'description': 'Node check 1',
                            'cmd': ['echo', 'node-check-1'],
                            'timeout': '1s',
                        },
                        'node-check-2': {
                            'description': 'Node check 2',
                            'cmd': ['echo', 'node-check-2'],
                            'timeout': '1s',
                        },
                    },
                    'poststart': ['node-check-1', 'node-check-2'],
                },
            }),
        },
        ['check_config', 'custom_checks'],
        (
            'Custom check names conflict with builtin checks. Reserved cluster check names: cluster-check-1. Reserved '
            'node check names: node-check-1, node-check-2.'
        ),
    )