-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial E2E tests for Kimchi #1293
Open
ramonmedeiros
wants to merge
6
commits into
kimchi-project:master
Choose a base branch
from
ramonmedeiros:add_e2e_tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ po/gen-pot | |
*.rej | ||
*.pem | ||
ui/pages/help/*/*.html | ||
tests/ui/.env | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Kimchi E2E Tests | ||
|
||
The tests are located in `tests/ui`. You should go to the directory to start them | ||
``` | ||
$ cd tests/ui | ||
``` | ||
|
||
## How to run | ||
|
||
First you need to install all dependencies to run the tests | ||
|
||
### Optional: install a virtual environment | ||
|
||
``` | ||
$ python3 -m venv .env | ||
$ source .env/bin/activate | ||
``` | ||
|
||
### Install deps | ||
``` | ||
$ pip install -r requirements.txt | ||
``` | ||
|
||
### Run in headless mode | ||
The script expect some environment variables to run kimchi-project tests, which are: | ||
|
||
``` | ||
Expect environment variables: | ||
USERNAME: username for the host default: root | ||
PASSWORD: password for the host | ||
HOST: host for kimchi default: localhost | ||
ramonmedeiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PORT: port for kimchi default: 8001 | ||
ramonmedeiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
So, if you are running against a remote host: | ||
|
||
``` | ||
$ HOST=<HOST> ./run_tests.sh | ||
Type password for host USER@HOST | ||
|
||
``` | ||
|
||
### Run in debug mode | ||
If you use the command above, the browser will no be visible for you. | ||
|
||
To see the browser action, add the variable `DEBUG` | ||
|
||
``` | ||
$ HOST=<HOST> DEBUG=true ./run_tests.sh | ||
Type password for host USER@HOST | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import utils | ||
from pages.login import KimchiLoginPage | ||
ramonmedeiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
VIRTUALIZATION_TAB = "//a[@class = 'item virtualizationTab']" | ||
TEMPLATES_TAB = "//a[@href = 'plugins/kimchi/tabs/templates.html']" | ||
ADD_TEMPLATE = "template-add" | ||
ISOS_LIST = "list-local-iso" | ||
|
||
class KimchiTemplatePage(): | ||
|
||
def __init__(self, browser): | ||
self.browser = browser | ||
assert KimchiLoginPage(browser).login(), "Cannot login to Kimchi" | ||
ramonmedeiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def retrieveDefaulTemplates(self): | ||
# click virtualization Tab | ||
utils.clickIfElementIsVisibleByXpath(self.browser, | ||
VIRTUALIZATION_TAB) | ||
|
||
# click templates tab | ||
utils.clickIfElementIsVisibleByXpath(self.browser, | ||
TEMPLATES_TAB) | ||
|
||
|
||
# click add template | ||
utils.clickIfElementIsVisibleById(self.browser, | ||
ADD_TEMPLATE) | ||
|
||
# iterate over default templates | ||
utils.waitElementIsVisibleById(self.browser, | ||
ISOS_LIST) | ||
|
||
# retrieve info | ||
info = [] | ||
for template in self.browser.find_elements_by_tag_name("dl"): | ||
info.append([info.text for info in template.find_elements_by_tag_name("dt")]) | ||
return info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
verbose = True | ||
log_cli = True | ||
log_cli_level = INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
appnope==0.1.0 | ||
attrs==19.3.0 | ||
backcall==0.1.0 | ||
chromedriver-binary==78.0.3904.105.0 | ||
decorator==4.4.1 | ||
importlib-metadata==1.3.0 | ||
ipdb==0.12.3 | ||
ipython==7.11.0 | ||
ipython-genutils==0.2.0 | ||
jedi==0.15.2 | ||
more-itertools==8.0.2 | ||
packaging==19.2 | ||
parso==0.5.2 | ||
pexpect==4.7.0 | ||
pickleshare==0.7.5 | ||
pluggy==0.13.1 | ||
prompt-toolkit==3.0.2 | ||
ptyprocess==0.6.0 | ||
py==1.8.1 | ||
Pygments==2.5.2 | ||
pyparsing==2.4.6 | ||
pytest==5.3.2 | ||
selenium==3.141.0 | ||
six==1.13.0 | ||
traitlets==4.3.3 | ||
urllib3==1.25.7 | ||
wcwidth==0.1.7 | ||
zipp==0.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
HOST=${HOST:-localhost} | ||
PORT=${PORT:-8001} | ||
USERNAME=${USERNAME:-root} | ||
|
||
# ask for password if not passed | ||
if [ -z $PASSWORD ]; then | ||
echo "Type password for host ${USERNAME}@${HOST}" | ||
read -s PASSWORD | ||
fi | ||
|
||
# ../../../../../../ is wok root | ||
|
||
HOST=${HOST} PASSWORD=${PASSWORD} USERNAME=${USERNAME} PORT=${PORT} \ | ||
PYTHONPATH=$PYTHONPATH:../../../../../../tests/ui/ python3 -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
|
||
from utils import getBrowser | ||
from pages.templates import KimchiTemplatePage | ||
EXPECTED_TEMPLATES = [['Debian', '10', 'Not Available'], | ||
['Fedora', '30', 'Not Available'], | ||
['Fedora', '31', 'Not Available'], | ||
['Opensuse', '15.1', 'Not Available'], | ||
['Ubuntu', '19.04', 'Not Available'], | ||
['Ubuntu', '19.10', 'Not Available'] | ||
] | ||
|
||
|
||
|
||
VIRTUALIZATION_TAB = "//a[@class = 'item virtualizationTab']" | ||
TEMPLATES_TAB = "//a[@href = 'plugins/kimchi/tabs/templates.html']" | ||
ADD_TEMPLATE = "template-add" | ||
ISOS_LIST = "list-local-iso" | ||
|
||
|
||
@pytest.fixture() | ||
def templatePage(): | ||
browser = getBrowser() | ||
templatePage = KimchiTemplatePage(browser) | ||
yield templatePage | ||
browser.close() | ||
|
||
def test_default_templates(templatePage): | ||
templates = templatePage.retrieveDefaulTemplates() | ||
|
||
# assert templates | ||
for template in templates: | ||
assert template in EXPECTED_TEMPLATES, f"{template} not found" | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need
.env
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its optional