Пример #1
0
def test_get_interpreters_to_show():
  default_interpreters = OrderedDict((
      ('hive', {
          'name': 'Hive', 'interface': 'hiveserver2', 'type': 'hive', 'is_sql': True, 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'hive'
      }),
      ('spark', {
          'name': 'Scala', 'interface': 'livy', 'type': 'spark', 'is_sql': False, 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'scala'
      }),
      ('pig', {
          'name': 'Pig', 'interface': 'pig', 'type': 'pig', 'is_sql': False, 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'pig'
      }),
      ('java', {
          'name': 'Java', 'interface': 'oozie', 'type': 'java', 'is_sql': False, 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'java'
      })
    ))

  expected_interpreters = OrderedDict((
      ('java', {
        'name': 'Java', 'interface': 'oozie', 'type': 'java', 'is_sql': False, 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'java'
      }),
      ('pig', {
        'name': 'Pig', 'interface': 'pig', 'is_sql': False, 'type': 'pig', 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'pig'
      }),
      ('hive', {
          'name': 'Hive', 'interface': 'hiveserver2', 'is_sql': True, 'type': 'hive', 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'hive'
      }),
      ('spark', {
          'name': 'Scala', 'interface': 'livy', 'type': 'spark', 'is_sql': False, 'options': {}, 'is_catalog': False, 'category': 'editor', 'dialect': 'scala'
      })
    ))

  try:
    resets = [INTERPRETERS.set_for_testing(default_interpreters), APP_BLACKLIST.set_for_testing('')]
    appmanager.DESKTOP_MODULES = []
    appmanager.DESKTOP_APPS = None
    appmanager.load_apps(APP_BLACKLIST.get())

    interpreters_shown_on_wheel_unset = get_ordered_interpreters()
    assert_equal(
      list(default_interpreters.values()),
      interpreters_shown_on_wheel_unset,
      'get_interpreters_to_show should return the same as get_interpreters when interpreters_shown_on_wheel is unset. expected: %s, actual: %s' % (
          list(default_interpreters.values()), interpreters_shown_on_wheel_unset
      )
    )

    resets.append(INTERPRETERS_SHOWN_ON_WHEEL.set_for_testing('java,pig'))
    assert_equal(list(expected_interpreters.values()), get_ordered_interpreters(),
                 'get_interpreters_to_show did not return interpreters in the correct order expected: %s, actual: %s'
                 % (list(expected_interpreters.values()), get_ordered_interpreters()))
  finally:
    for reset in resets:
      reset()
    appmanager.DESKTOP_MODULES = []
    appmanager.DESKTOP_APPS = None
    appmanager.load_apps(APP_BLACKLIST.get())
Пример #2
0
_lib_conf_modules = [
    dict(module=app.conf, config_key=None) for app in appmanager.DESKTOP_LIBS
    if app.conf is not None
]
LOCALE_PATHS.extend([app.locale_path for app in appmanager.DESKTOP_LIBS])

# Load desktop config
_desktop_conf_modules = [dict(module=desktop.conf, config_key=None)]
conf.initialize(_desktop_conf_modules, _config_dir)

# Register the redaction filters into the root logger as soon as possible.
desktop.redaction.register_log_filtering(desktop.conf.get_redaction_policy())

# Activate l10n
# Install apps
appmanager.load_apps(desktop.conf.APP_BLACKLIST.get())
for app in appmanager.DESKTOP_APPS:
    INSTALLED_APPS.extend(app.django_apps)
    LOCALE_PATHS.append(app.locale_path)

logging.debug("Installed Django modules: %s" %
              ",".join(map(str, appmanager.DESKTOP_MODULES)))

# Load app configuration
_app_conf_modules = [
    dict(module=app.conf, config_key=app.config_key)
    for app in appmanager.DESKTOP_APPS if app.conf is not None
]

conf.initialize(_lib_conf_modules, _config_dir)
conf.initialize(_app_conf_modules, _config_dir)
Пример #3
0
# Libraries are loaded and configured before the apps
appmanager.load_libs()
_lib_conf_modules = [dict(module=app.conf, config_key=None) for app in appmanager.DESKTOP_LIBS if app.conf is not None]
LOCALE_PATHS.extend([app.locale_path for app in appmanager.DESKTOP_LIBS])

# Load desktop config
_desktop_conf_modules = [dict(module=desktop.conf, config_key=None)]
conf.initialize(_desktop_conf_modules, _config_dir)

# Register the redaction filters into the root logger as soon as possible.
desktop.redaction.register_log_filtering(desktop.conf.get_redaction_policy())


# Activate l10n
# Install apps
appmanager.load_apps(desktop.conf.APP_BLACKLIST.get())
for app in appmanager.DESKTOP_APPS:
  INSTALLED_APPS.extend(app.django_apps)
  LOCALE_PATHS.append(app.locale_path)


logging.debug("Installed Django modules: %s" % ",".join(map(str, appmanager.DESKTOP_MODULES)))

# Load app configuration
_app_conf_modules = [dict(module=app.conf, config_key=app.config_key) for app in appmanager.DESKTOP_APPS if app.conf is not None]

conf.initialize(_lib_conf_modules, _config_dir)
conf.initialize(_app_conf_modules, _config_dir)

# Now that we've loaded the desktop conf, set the django DEBUG mode based on the conf.
DEBUG = desktop.conf.DJANGO_DEBUG_MODE.get()
Пример #4
0
LOGIN_REDIRECT_URL = "/"

PYLINTRC = get_desktop_root('.pylintrc')


############################################################
# Part 4: Installation of apps
############################################################

_config_dir = os.getenv("HUE_CONF_DIR", get_desktop_root("conf"))

# Libraries are loaded and configured before the apps
appmanager.load_libs()
_lib_conf_modules = filter(None, [app.conf for app in appmanager.DESKTOP_LIBS])

appmanager.load_apps()
for app in appmanager.DESKTOP_APPS:
  INSTALLED_APPS.extend(app.django_apps)

logging.debug("Installed Django modules: %s" % ",".join(map(str, appmanager.DESKTOP_MODULES)))

# Load app configuration
_app_conf_modules = filter(None, [app.conf for app in appmanager.DESKTOP_APPS])
_app_conf_modules.append(desktop.conf)

conf.initialize(_lib_conf_modules, _config_dir)
conf.initialize(_app_conf_modules, _config_dir)

appmanager.determine_broken_apps()

# Now that we've loaded the desktop conf, set the django DEBUG mode based on the conf.
Пример #5
0
)

############################################################
# Part 4: Installation of apps
############################################################

_config_dir = os.getenv("HUE_CONF_DIR", get_desktop_root("conf"))

# Libraries are loaded and configured before the apps
appmanager.load_libs()
_lib_conf_modules = [
    dict(module=app.conf, config_key=None) for app in appmanager.DESKTOP_LIBS
    if app.conf is not None
]

appmanager.load_apps()
for app in appmanager.DESKTOP_APPS:
    INSTALLED_APPS.extend(app.django_apps)

logging.debug("Installed Django modules: %s" %
              ",".join(map(str, appmanager.DESKTOP_MODULES)))

# Load app configuration
_app_conf_modules = [
    dict(module=app.conf, config_key=app.config_key)
    for app in appmanager.DESKTOP_APPS if app.conf is not None
]
_app_conf_modules.append(dict(module=desktop.conf, config_key=None))

conf.initialize(_lib_conf_modules, _config_dir)
conf.initialize(_app_conf_modules, _config_dir)
Пример #6
0
def test_get_ordered_interpreters():
  default_interpreters = OrderedDict((
    ('hive', {
        'name': 'Hive', 'displayName': 'Hive', 'interface': 'hiveserver2', 'type': 'hive', 'is_sql': True,
        'options': {}, 'dialect_properties': None, 'is_catalog': False, 'category': 'editor', 'dialect': 'hive'
    }),
    ('impala', {
        'name': 'Impala', 'displayName': 'Impala', 'interface': 'hiveserver2', 'type': 'impala', 'is_sql': True,
        'options': {}, 'dialect_properties': None, 'is_catalog': False, 'category': 'editor', 'dialect': 'impala'
    }),
    ('spark', {
        'name': 'Scala', 'displayName': 'Scala', 'interface': 'livy', 'type': 'spark', 'is_sql': False, 'options': {},
        'dialect_properties': None, 'is_catalog': False, 'category': 'editor', 'dialect': 'scala'
    }),
    ('pig', {
        'name': 'Pig', 'displayName': 'Pig', 'interface': 'pig', 'type': 'pig', 'is_sql': False, 'options': {},
        'dialect_properties': None, 'is_catalog': False, 'category': 'editor', 'dialect': 'pig'
    }),
    ('java', {
        'name': 'Java', 'displayName': 'Java', 'interface': 'oozie', 'type': 'java', 'is_sql': False, 'options': {},
        'dialect_properties': None, 'is_catalog': False, 'category': 'editor', 'dialect': 'java'
    })
  ))

  try:
    resets = [APP_BLACKLIST.set_for_testing('')]
    appmanager.DESKTOP_MODULES = []
    appmanager.DESKTOP_APPS = None
    appmanager.load_apps(APP_BLACKLIST.get())

    with patch('notebook.conf.is_cm_managed') as is_cm_managed:
      with patch('notebook.conf.appmanager.get_apps_dict') as get_apps_dict:
        with patch('notebook.conf.has_connectors') as has_connectors:
          get_apps_dict.return_value = {'hive': {}}
          has_connectors.return_value = False
          notebook.conf.INTERPRETERS_CACHE = None

          is_cm_managed.return_value = False

          # No CM --> Verbatim
          INTERPRETERS.set_for_testing(
            OrderedDict((
              ('phoenix', {
                  'name': 'Phoenix', 'interface': 'sqlalchemy', 'dialect': 'phoenix'
              }),)
            )
          )
          assert_equal(
            [interpreter['dialect'] for interpreter in get_ordered_interpreters()],
            ['phoenix']
          )
          assert_equal(  # Check twice because of cache
            [interpreter['dialect'] for interpreter in get_ordered_interpreters()],
            ['phoenix']
          )

          is_cm_managed.return_value = True
          notebook.conf.INTERPRETERS_CACHE = None

          # CM --> Append []
          INTERPRETERS.set_for_testing(
            OrderedDict(()
            )
          )

          assert_equal(
            [interpreter['dialect'] for interpreter in get_ordered_interpreters()],
            ['hive']
          )
          assert_equal(  # Check twice
            [interpreter['dialect'] for interpreter in get_ordered_interpreters()],
            ['hive']
          )

          notebook.conf.INTERPRETERS_CACHE = None

          # CM --> Append [Phoenix]
          INTERPRETERS.set_for_testing(
            OrderedDict((
              ('phoenix', {
                  'name': 'Phoenix', 'interface': 'sqlalchemy', 'dialect': 'phoenix'
              }),)
            )
          )
          assert_equal(
            [interpreter['dialect'] for interpreter in get_ordered_interpreters()],
            ['hive', 'phoenix']
          )
          assert_equal(  # Check twice
            [interpreter['dialect'] for interpreter in get_ordered_interpreters()],
            ['hive', 'phoenix']
          )
  finally:
    for reset in resets:
      reset()
    appmanager.DESKTOP_MODULES = []
    appmanager.DESKTOP_APPS = None
    appmanager.load_apps(APP_BLACKLIST.get())
    notebook.conf.INTERPRETERS_CACHE = None