Browse Source

Merge "Fix horizon dashboard"

changes/13/682113/3
Zuul 2 years ago
committed by Gerrit Code Review
parent
commit
fb4498b331
23 changed files with 174 additions and 54 deletions
  1. +1
    -1
      snap-overlay/bin/horizon-wsgi
  2. +0
    -22
      snap-overlay/lib/python2.7/site-packages/openstack_dashboard/local/local_settings.d/_05_snap_tweaks.py
  3. +53
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/local/local_settings.d/_05_snap_tweaks.py
  4. +40
    -22
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/local/local_settings.py
  5. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/_styles.scss
  6. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/_variables.scss
  7. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/_styles.scss
  8. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/_variables.scss
  9. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/components/_navbar.scss
  10. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/components/_navs.scss
  11. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/_styles.scss
  12. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/_variables.scss
  13. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_context_selection.scss
  14. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_pie_charts.scss
  15. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_sidebar.scss
  16. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/img/image-background-pattern.png
  17. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/img/logo-ubuntu-orange.svg
  18. +0
    -0
      snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/img/logo-ubuntu-white.svg
  19. +2
    -0
      test-requirements.txt
  20. +6
    -4
      tests/basic-test.sh
  21. +47
    -0
      tests/test_horizonlogin.py
  22. +10
    -1
      tools/lxd_build.sh
  23. +15
    -4
      tox.ini

+ 1
- 1
snap-overlay/bin/horizon-wsgi View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import os
import sys


+ 0
- 22
snap-overlay/lib/python2.7/site-packages/openstack_dashboard/local/local_settings.d/_05_snap_tweaks.py View File

@ -1,22 +0,0 @@
# Tweaks to make this run nicely in a snap.
# We don't want django to try writing the secret key before we've told
# it not to attempt to write it out in the read only snap dir in our
# local_settings.py. So we override the behavior of the default
# settings.py here.
SECRET_KEY = "overridethis!"
# Django wants to write out compressed files even when we turn
# compression off (either a bug or something that I'm not
# understanding). Tell it to write them some place writeable.
STATIC_ROOT = '/var/snap/microstack/common/var/horizon/static'
# Disable extra themes for now. TODO: Re-enable when
# https://github.com/CanonicalLtd/microstack/issues/39 is
# addressed. (You'll need to uncomment the material theme below when testing
# the fix.)
AVAILABLE_THEMES = [
('default', 'Default', 'themes/default'),
# ('material', 'Material', 'themes/material'),
('ubuntu', 'Ubuntu', 'themes/ubuntu'),
]

+ 53
- 0
snap-overlay/lib/python3.6/site-packages/openstack_dashboard/local/local_settings.d/_05_snap_tweaks.py View File

@ -0,0 +1,53 @@
# Tweaks to make this run nicely in a snap.
# TODO: turn this off once everything is working nicely.
DEBUG = True
# Set our webroot.
WEBROOT = '/'
# Caches and such should get written out here.
LOCAL_PATH = '/var/snap/microstack/common/etc/horizon/'
# We don't want django to try writing the secret key before we've told
# it not to attempt to write it out in the read only snap dir in our
# local_settings.py. So we override the behavior of the default
# settings.py here.
SECRET_KEY = secret_key.generate_or_read_from_file(
os.path.join(LOCAL_PATH, '.secret_key_store'))
# Django wants to write out compressed files even when we turn
# compression off (either a bug or something that I'm not
# understanding). Tell it to write them some place writeable.
STATIC_ROOT = '/var/snap/microstack/common/var/horizon/static'
# Disable extra themes for now. TODO: Re-enable when
# https://github.com/CanonicalLtd/microstack/issues/39 is
# addressed. (You'll need to uncomment the material theme below when testing
# the fix.)
AVAILABLE_THEMES = [
('default', 'Default', 'themes/default'),
# ('material', 'Material', 'themes/material'),
('ubuntu', 'Ubuntu', 'themes/ubuntu'),
]
# Point us at keystone.
OPENSTACK_HOST = "10.20.20.1"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
# Turn off external access for now. (This should be turned on once we
# have hooks for setting a non default password.)
ALLOWED_HOSTS = ['10.20.20.1', 'localhost', '127.0.0.1']
# Use memcached as our caching backend.
CACHES = {
'default': {
#
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '10.20.20.1:11211',
}
}
SESSION_ENGINE='django.contrib.sessions.backends.cache'

snap-overlay/lib/python2.7/site-packages/openstack_dashboard/local/local_settings.py → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/local/local_settings.py View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/_styles.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/_styles.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/_variables.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/_variables.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/_styles.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/_styles.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/_variables.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/_variables.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/components/_navbar.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/components/_navbar.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/components/_navs.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/bootstrap/components/_navs.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/horizon/_styles.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/_styles.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/horizon/_variables.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/_variables.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_context_selection.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_context_selection.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_pie_charts.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_pie_charts.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_sidebar.scss → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/horizon/components/_sidebar.scss View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/img/image-background-pattern.png → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/img/image-background-pattern.png View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/img/logo-ubuntu-orange.svg → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/img/logo-ubuntu-orange.svg View File


snap-overlay/lib/python2.7/site-packages/openstack_dashboard/themes/ubuntu/img/logo-ubuntu-white.svg → snap-overlay/lib/python3.6/site-packages/openstack_dashboard/themes/ubuntu/img/logo-ubuntu-white.svg View File


+ 2
- 0
test-requirements.txt View File

@ -1 +1,3 @@
petname
selenium
xvfbwrapper

+ 6
- 4
tests/basic-test.sh View File

@ -161,12 +161,14 @@ done;
# Cleanup
unset IP
echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "++ Completed tests. Cleaning up ++"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
if [[ $PREFIX == *"multipass"* ]]; then
echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "++ Completed tests. Cleaning up ++"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
sudo multipass delete $MACHINE
sudo multipass purge
else
$PREFIX sudo snap remove microstack
echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "++ Completed tests. Leaving snap installed. ++"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
fi

+ 47
- 0
tests/test_horizonlogin.py View File

@ -0,0 +1,47 @@
#!/usr/bin/env python
"""
test_horizonlogin.py
This is a basic test of Horizon functionality. We verify that:
1) Horizon is running, and we can hit the landing page.
2) We can login successfully.
This is based on code generated by the Selinum Web IDE.
"""
import os
import socket
import unittest
import xvfbwrapper
from selenium import webdriver
from selenium.webdriver.common.by import By
class TestHorizonlogin(unittest.TestCase):
def setUp(self):
self.display = xvfbwrapper.Xvfb(width=1280, height=720)
self.display.start()
self.driver = webdriver.PhantomJS()
def tearDown(self):
self.driver.quit()
self.display.stop()
def test_horizonlogin(self):
self.driver.get("http://10.20.20.1/")
# Login to horizon!
self.driver.find_element(By.ID, "id_username").click()
self.driver.find_element(By.ID, "id_username").send_keys("admin")
self.driver.find_element(By.ID, "id_password").send_keys("keystone")
self.driver.find_element(By.CSS_SELECTOR, "#loginBtn > span").click()
# Verify that we can click something on the dashboard -- e.g.,
# we're still not sitting at the login screen.
self.driver.find_element(By.LINK_TEXT, "Images").click()
if __name__ == '__main__':
# Run our tests, ignorning deprecation warnings and warnings about
# unclosed sockets. (TODO: setup a selenium server so that we can
# move from PhantomJS, which is deprecated, to to Selenium headless.)
unittest.main(warnings='ignore')

+ 10
- 1
tools/lxd_build.sh View File

@ -5,10 +5,19 @@ set -ex
export PATH=/snap/bin:$PATH
sudo apt update
sudo apt install -y snapd
# Install the X virtual framebuffer, which is required for selenium
# tests of the horizon dashboard.
sudo apt install -y xvfb npm libfontconfig1
sudo npm install -g phantomjs-prebuilt
# Verify that PhantomJS, our selenium web driver, works.
phantomjs -v
# Setup snapd and snapcraft
sudo apt install -y snapd
sudo snap install --classic snapcraft
sudo snap install --classic lxd
sudo lxd init --auto
# Build our snap!
sudo snapcraft --use-lxd

+ 15
- 4
tox.ini View File

@ -3,9 +3,10 @@ envlist = init_lint, init_unit, multipass
skipsdist = True
[testenv]
basepython=python3
install_command = pip install {opts} {packages}
setenv =
PATH = {env:PATH}:/snap/bin
PATH = /snap/bin:{env:PATH}
passenv = HOME TERM
whitelist_externals =
sudo
@ -15,10 +16,12 @@ whitelist_externals =
# Testing environment for the gerrit gate. Named 'snap' to conform to
# the requirements of the snap friendly job that we inherit from in
# .zuul.yaml.
basepython=python3
deps = -r{toxinidir}/test-requirements.txt
commands =
{toxinidir}/tools/lxd_build.sh
{toxinidir}/tests/basic-test.sh
{toxinidir}/tests/test_horizonlogin.py
[testenv:multipass]
# Default testing environment for a human operated machine. Builds the
@ -28,6 +31,7 @@ commands =
# use the "snap" environment above. Beware that you will wind up with
# a lot of things installed, including potentially the locally built
# version of MicroStack!
deps = -r{toxinidir}/test-requirements.txt
commands =
{toxinidir}/tools/multipass_build.sh
{toxinidir}/tests/basic-test.sh -m
@ -37,15 +41,22 @@ commands =
commands =
{toxinidir}/tests/basic-test.sh -m
[testenv:init_lint]
basepython=python3
deps = -r{toxinidir}/tools/init/test-requirements.txt
-r{toxinidir}/tools/init/requirements.txt
commands = flake8 {toxinidir}/tools/init/init/
[testenv:init_unit]
basepython=python3
deps = -r{toxinidir}/tools/init/test-requirements.txt
-r{toxinidir}/tools/init/requirements.txt
commands = stestr run {posargs}
[testenv:browser]
# Run browser tests. Assumes that you have the snap installed and
# initialized locally, and a valid DISPLAY (install xvfb for a virtual
# one).
# TODO: figure out how to integrate this w/ multipass. (e.g. setup
# port forwarding and call into the mulitpass machine.)
deps = -r{toxinidir}/test-requirements.txt
commands =
{toxinidir}/tests/test_horizonlogin.py

Loading…
Cancel
Save