Skip to content
Snippets Groups Projects
Verified Commit 2b762539 authored by Varac's avatar Varac
Browse files

Test grafana login

parent bc2fcb25
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:
......
......@@ -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/prometheus_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,40 @@ def before_all(context):
chrome_options=chrome_options)
def before_tag(context, tag):
userdata = context.config.userdata
if tag == 'grafana':
context.grafana = {}
context.grafana['url'] = userdata.get('grafana.url')
context.grafana['username'] = \
userdata.get('grafana.username', 'admin')
context.grafana['password'] = \
userdata.get('grafana.password')
assert context.grafana['url'], 'grafana url variable missing in' \
'userdata. Provide it with "-D grafana.url".'
assert context.grafana['username'], 'grafana username variable' \
'missing in userdata. Provide it with "-D grafana.username".'
assert context.grafana['password'], 'grafana password variable' \
'missing in userdata. Provide it with "-D grafana.password".'
if tag == 'nextcloud':
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".'
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 "//form/div[1]/input" for 25000ms to be visible
And I expect that element "#inputPassword" is visible
Scenario: Login to grafana
Given the element "//form/div[1]/input" is visible
When I enter the "grafana" "username" in the inputfield "//form/div[1]/input"
And I enter the "grafana" "password" in the inputfield "#inputPassword"
And I click on the button "//form/div[3]/button"
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
......
......@@ -10,6 +10,13 @@ def step_impl(context):
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):
"""Login to grafana."""
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/prometheus_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