Esempio n. 1
0
def test_missing_hostname():
    """Test deployment parameters without a hostname.
    """
    dep = LSSTNotebookAspectDeployment(params={})
    assert(dep)

    with pytest.raises(ValueError):
        dep._validate_deployment_params()
Esempio n. 2
0
def check_default_options():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "github_organization_whitelist":
                                               "nkvd"})
    dep._validate_deployment_params()
    dep._normalize_params()
    dep._check_optional()
    assert dep.params['dhparam_bits'] == 2048
    assert dep.params['session_db_url'] == ('sqlite:////home/jupyter' +
                                            '/jupyterhub.sqlite')
Esempio n. 3
0
def test_callback_url():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "github_organization_whitelist":
                                               "nkvd"})
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['oauth_callback_url'] == (
        "https://kremvax.ru/nb/hub/oauth_callback")
Esempio n. 4
0
def test_github_organization_whitelist():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    with pytest.raises(KeyError):
        dep._normalize_params()
    dep.params['github_organization_whitelist'] = []
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_organization_whitelist'] == ''
    dep.params['github_organization_whitelist'] = ['nkvd']
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_organization_whitelist'] == 'nkvd'
    dep.params['github_organization_whitelist'] = ['nkvd', 'kgb']
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_organization_whitelist'] == 'nkvd,kgb'
Esempio n. 5
0
def test_filesystem_calculate_sizes():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "github_organization_whitelist":
                                               "nkvd"})
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['volume_size'] == '20Gi'
    assert dep.params['nfs_volume_size'] == '19Gi'
    dep.params['volume_size_gigabytes'] = 1
    dep._normalize_params()
    assert dep.params['volume_size'] == '1Gi'
    assert dep.params['nfs_volume_size'] == '950Mi'
    dep.params['volume_size_gigabytes'] = 1392
    dep._normalize_params()
    assert dep.params['volume_size'] == '1392Gi'
    assert dep.params['nfs_volume_size'] == '1322Gi'
Esempio n. 6
0
def test_missing_params():
    """Test deployment without any parameters at all.
    """
    dep = LSSTNotebookAspectDeployment()
    assert dep.params is None
Esempio n. 7
0
def test_filesystem_illegal_size():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "volume_size_gigabytes": -2})
    with pytest.raises(ValueError):
        dep._validate_deployment_params()
Esempio n. 8
0
def test_filesystem_default_size():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep.params['volume_size_gigabytes'] == 20
Esempio n. 9
0
def test_explicit_cluster_namespace():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "kubernetes_cluster_namespace":
                                               "raskolnikov"})
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_namespace'] == 'raskolnikov'
Esempio n. 10
0
def test_default_cluster_namespace():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_namespace'] == 'kremvax'
Esempio n. 11
0
def test_explicit_cluster_name():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "westwing.ru"})
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_name'] == "westwing-ru"
Esempio n. 12
0
def test_empty_param_method():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep._empty_param('missing')
    assert not dep._empty_param('hostname')
Esempio n. 13
0
def test_enable_logging():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "github_organization_whitelist":
                                               "nkvd"})
    dep._validate_deployment_params()
    dep._normalize_params()
    dep._check_optional()
    assert not dep.enable_logging
    for l in ['rabbitmq_pan_password',
              'rabbitmq_target_host',
              'rabbitmq_target_vhost',
              'log_shipper_name',
              'beats_key',
              'beats_ca',
              'beats_cert']:
        dep.params[l] = 'da, tovarisch'
    dep._check_optional()
    assert dep.enable_logging
Esempio n. 14
0
def test_enable_firefly():
    dep = LSSTNotebookAspectDeployment(params={"hostname": "kremvax.ru",
                                               "github_organization_whitelist":
                                               "nkvd"})
    dep._validate_deployment_params()
    dep._normalize_params()
    dep._check_optional()
    assert not dep.enable_firefly
    dep.params['firefly_admin_password'] = '******'
    dep._check_optional()
    assert dep.enable_firefly