Skip to content
Snippets Groups Projects
Commit 5fc783a1 authored by Arie Peterson's avatar Arie Peterson
Browse files

Merge branch '145-tests-for-prometheus-and-grafana' into 'master'

Resolve "Tests for prometheus and grafana"

Closes #145

See merge request openappstack/bootstrap!107
parents bc2fcb25 4768a4e0
No related branches found
No related tags found
No related merge requests found
......@@ -84,15 +84,15 @@ certs:
- cd test/
- py.test -s -m 'certs' --connection=ansible --ansible-inventory=./inventory.yml --hosts='ansible://*'
behave:
behave-nextcloud:
stage: integration-test
script:
# Debug failing CI caches which happened in the past
- find . -name behave.ini
- ls -al test/behave
- grep -v 'nextcloud.password' test/behave/behave.ini
- grep -v 'password' test/behave/behave.ini
- cd test/behave/
- behave -D headless=True || behave -D headless=True @rerun_failing.features
- behave -D headless=True -t nextcloud || behave -D headless=True @rerun_failing.features -t nextcloud
artifacts:
paths:
- test/behave/screenshots/
......@@ -100,6 +100,21 @@ behave:
when: on_failure
retry: 2
behave-grafana:
stage: integration-test
script:
# Debug failing CI caches which happened in the past
- find . -name behave.ini
- ls -al test/behave
- grep -v 'password' test/behave/behave.ini
- cd test/behave/
- behave -D headless=True -t grafana || behave -D headless=True @rerun_failing.features -t grafana
artifacts:
paths:
- test/behave/screenshots/
expire_in: 1 month
when: on_failure
terminate:
stage: cleanup
script:
......
......@@ -11,10 +11,10 @@ nextcloud_password: "{{ lookup('password', './secrets/nextcloud_admin_password c
nextcloud_mariadb_password: "{{ lookup('password', './secrets/nextcloud_mariadb_password chars=ascii_letters') }}"
nextcloud_mariadb_root_password: "{{ lookup('password', './secrets/nextcloud_mariadb_root_password chars=ascii_letters') }}"
collabora_password: "{{ lookup('password', './secrets/collabora_admin_password chars=ascii_letters') }}"
prometheus_grafana_admin_password: "{{ lookup('password', './secrets/prometheus_grafana_admin_password chars=ascii_letters') }}"
grafana_admin_password: "{{ lookup('password', './secrets/grafana_admin_password chars=ascii_letters') }}"
# git repo versions
git_helmfiles_version: '2c0fcbeda044d53cf742280936baa87b8b22d139'
git_helmfiles_version: '6c5b62376e8ca8cd8789ece716e91ad0693e6f9f'
git_charts_version: 'HEAD'
git_local_storage_version: 'HEAD'
......
......@@ -218,7 +218,7 @@
- NEXTCLOUD_PASSWORD: "{{ nextcloud_password }}"
- NEXTCLOUD_MARIADB_PASSWORD: "{{ nextcloud_mariadb_password }}"
- NEXTCLOUD_MARIADB_ROOT_PASSWORD: "{{ nextcloud_mariadb_root_password }}"
- PROMETHEUS_GRAFANA_ADMIN_PASSWORD: "{{ prometheus_grafana_admin_password }}"
- GRAFANA_ADMIN_PASSWORD: "{{ grafana_admin_password }}"
command: '/usr/local/bin/helmfile -b /snap/bin/helm -e oas -f /oas/source/repos/helmfiles/helmfile.d/ apply --suppress-secrets'
- name: Get current krew version (plugin manager for kubectl)
......
......@@ -2,8 +2,17 @@
Change to the `test/behave` directory and run:
For nextcloud test:
behave -D nextcloud.url=https://files.example.openappstack.net \
-D nextcloud.password="$(cat ../../ansible/secrets/nextcloud_admin_password)"
-D nextcloud.password="$(cat ../../ansible/secrets/nextcloud_admin_password)" \
-t nextcloud
For grafana test:
behave -D grafana.url=https://grafana.example.openappstack.net \
-D grafana.password="$(cat ../../ansible/secrets/grafana_admin_password)" \
-t grafana
# Run behave tests in bootstrap-ci docker image
......
......@@ -22,16 +22,6 @@ def save_screenshot(context, step):
def before_all(context):
"""Run at the very beginning."""
userdata = context.config.userdata
context.nextcloud = {}
context.nextcloud['url'] = userdata.get('nextcloud.url')
context.nextcloud['username'] = \
userdata.get('nextcloud.username', 'admin')
context.nextcloud['password'] = \
userdata.get('nextcloud.password')
assert context.nextcloud['url'], 'Nextcloud url variable missing in userdata. Provide it with "-D nextcloud.url".'
assert context.nextcloud['username'], 'Nextcloud username variable missing in userdata. Provide it with "-D nextcloud.username".'
assert context.nextcloud['password'], 'Nextcloud password variable missing in userdata. Provide it with "-D nextcloud.password".'
headless = userdata.get('headless', 'False')
......@@ -44,6 +34,31 @@ def before_all(context):
chrome_options=chrome_options)
def before_tag(context, tag):
def get_values(app):
values = {}
values['url'] = userdata.get(app + '.url')
values['username'] = \
userdata.get(app + '.username', 'admin')
values['password'] = \
userdata.get(app + '.password')
assert values['url'], '{0}.url variable missing in' \
'userdata. Provide it with "-D {0}.url".'.format(app)
assert values['username'], '{0}.username variable missing in' \
'userdata. Provide it with "-D {0}.username".'.format(app)
assert values['password'], '{0}.password variable missing in' \
'userdata. Provide it with "-D {0}.password".'.format(app)
return(values)
userdata = context.config.userdata
if tag == 'grafana':
context.grafana = get_values('grafana')
if tag == 'nextcloud':
context.nextcloud = get_values('nextcloud')
def after_all(context):
"""Cleanup after tests run."""
context.behave_driver.quit()
......
@grafana
Feature: Test grafana admin login
As an OAS admin
I want to be able to login to grafana as the user admin
Scenario: Open grafana
When I open the grafana URL
Then I wait on element "//input[@name='username']" for 25000ms to be visible
And I expect that element "#inputPassword" is visible
Scenario: Login to grafana
Given the element "//input[@name='username']" is visible
When I enter the "grafana" "username" in the inputfield "//input[@name='username']"
And I enter the "grafana" "password" in the inputfield "#inputPassword"
And I click on the button "//div[@id='login-view']//button[@type='submit']"
Then I wait on element "/html/body/grafana-app/sidemenu/a" for 25000ms to be visible
And I expect that the title is "Home - Grafana"
@nextcloud
Feature: Test nextcloud admin login
As an OAS admin
I want to be able to login to nextcloud as the user admin
......
......@@ -6,10 +6,17 @@ from behave_webdriver.steps import *
@when(u'I open the nextcloud URL')
@given(u'I open the nextcloud URL')
def step_impl(context):
"""Login to nextcloud."""
"""Open nextcloud URL."""
context.behave_driver.get(context.nextcloud['url'])
@when(u'I open the grafana URL')
@given(u'I open the grafana URL')
def step_impl(context):
"""Open grafana URL."""
context.behave_driver.get(context.grafana['url'])
@when(u'I enter the "{section}" "{cred_type}" in the inputfield "{element}"')
def step_impl(context, section, cred_type, element):
"""Enter username/password into login inputfields."""
......
......@@ -273,17 +273,29 @@ def write_behave_config(settings=None):
with open('./secrets/nextcloud_admin_password', 'r') as stream:
nextcloud_admin_password = yaml.safe_load(stream)
with open('./secrets/grafana_admin_password', 'r') as stream:
grafana_admin_password = yaml.safe_load(stream)
behave_config = configparser.ConfigParser()
behave_config['behave'] = {}
behave_config['behave']['format'] = 'rerun'
behave_config['behave']['outfiles'] = 'rerun_failing.features'
behave_config['behave']['show_skipped'] = 'false'
behave_config['behave.userdata'] = {}
behave_config['behave.userdata']['nextcloud.url'] = \
'https://files.{}'.format(settings['domain'])
behave_config['behave.userdata']['nextcloud.username'] = 'admin'
behave_config['behave.userdata']['nextcloud.password'] = \
nextcloud_admin_password
behave_config['behave.userdata']['grafana.url'] = \
'https://grafana.{}'.format(settings['domain'])
behave_config['behave.userdata']['grafana.username'] = 'admin'
behave_config['behave.userdata']['grafana.password'] = \
grafana_admin_password
with open('./behave/behave.ini', 'w') as configfile:
behave_config.write(configfile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment