Commit Graph

89 Commits

Author SHA1 Message Date
David Shea
587f05e551 Add tests for /compose/status filter arguments 2018-08-10 10:18:27 -04:00
Chris Lumens
4cb15e0a0f Fix more tests.
These were broken due to me rebasing before sending a PR off.  They
should work now.
2018-08-09 16:11:32 -04:00
Chris Lumens
b3bb438254 Add error IDs to things that can go wrong when running a compose.
Note the exception string checking around compose_type.  I didn't really
want to introduce a new exception type just for this, but also didn't
want to duplicate strings.  I'd be open to other suggestions for how to
do this.
2018-08-09 16:11:32 -04:00
Chris Lumens
a925cc7ddb Add error IDs for when an unknown blueprint is requested.
This adds some fairly redundant code to the beginning of all the
blueprint routes to attempt reading a commit from git for the
blueprint's recipe.  If it succeeds, the blueprint exists and the route
can continue.  Otherwise, return an error.  Hopefully this doesn't slow
things down too much.
2018-08-09 16:11:32 -04:00
Chris Lumens
6497b4fb65 Add error IDs for when an unknown build UUID is requested.
Note that this also changes the return type of uuid_info to return None
when an unknown ID is given.  The other uuid_* functions are fine
because they are checked ahead of time.
2018-08-09 16:11:32 -04:00
Brian C. Lane
eda5c9bde1 Add a test for the pylorax.api.timestamp functions 2018-08-07 10:51:06 -07:00
Brian C. Lane
86d79cd8a6 Add input string checks to the branch and format arguments
Make sure no UTF8 characters are allowed and return an error if they
are.

Also includes tests to make sure the correct error is returned.
2018-08-06 14:21:24 -07:00
Brian C. Lane
74f5def3d4 Add a test for invalid characters in the API route
Currently the code is not UTF8 safe, so we need to return a clear error
when invalid characters are passed in.

This also adds tests for the routes to confirm that an error is
correctly returned.
2018-08-06 13:24:24 -07:00
Brian C. Lane
3fd5e50c80 Use the first enabled system repo for the test 2018-07-27 17:25:06 -07:00
Brian C. Lane
26df083bd4 Show more details when the system repo delete test fails
Works fine for me locally, but not in Travis for some reason so let's
get more info.
2018-07-27 15:47:22 -07:00
Brian C. Lane
7700ae3135 Add composer-cli function tests
These depend on there being a freshly installed lorax-composer API
server running, if there is no /run/weldr/api.socket they will be
skipped.
2018-07-26 18:12:02 -07:00
Brian C. Lane
eeae331ba0 Add a test library
This adds empty __init__.py to tests so that a lib.py library of helper
functions can be imported from the tests.

Add captured_output to use with composer-cli tests to capture stdout/err
output from the functions.
2018-07-26 18:12:02 -07:00
Brian C. Lane
638fdb49cb Adjust the tests so they will pass on CentOS7 and RHEL7
Also pulls the name of a system repo from /etc/yum.repos.d/ instead of
hard-coding 'base' in there.
2018-07-26 15:06:05 -07:00
Brian C. Lane
35fa067219 Modify handle_api_result so it can be used in more places
Some results have errors and no status, others have status and errors.
Update the function to return the final rc to exit with, and a bool
indicating whether or not to continue processing the other fields.

Add a bunch of tests for the new function to make sure I have the logic
correct.
2018-07-25 17:30:50 -07:00
Chris Lumens
ab0655d5a9 Add group-based tests. 2018-07-12 17:31:56 -04:00
Chris Lumens
5fe4b47072 Include groups in depsolving.
This adds a new argument to projects_depsolve and
projects_depsolve_with_size that contains the group list, unfortunately.
I would have prefered adding a function that just returns a list of all
the contents of a group and then add that to what was being passed into
projects_depsolve.  However, there does not appear to be any good way to
do that in yum aside from a lot of grubbing around in the comps object,
which I am unwilling to do.
2018-07-12 17:31:44 -04:00
Chris Lumens
0f69d2084c Add support for groups to blueprints.
Nothing is currently being done with this information, but it will be
soon.
2018-07-12 17:31:44 -04:00
Brian C. Lane
d692a7dddd Check the compose templates at startup
Depsolve the packages included in the templates and report any errors
using the /api/status 'msgs' field. This should help narrow down
problems with package sources not being setup correctly.
2018-07-12 09:25:22 -07:00
Brian C. Lane
3cfb895054 Use yum.add_enable_repo() for new repos
Yum needs to have some other attrs setup on the YumRepository object, so
use the function provided to ensure that everything is correct. Also
switch the related functions to use a dict instead of a YumRepository
object.
2018-06-11 16:54:59 -07:00
Brian C. Lane
2e95b56508 Fix DNF related issues with source selection
yum TumRepository.dump() function cannot be used as a .repo file Add a
new function to write this in the correct format, and limited to the
fields we use.

Add a test for the new function.

Fix /projects/source/info to return an error 400 if a nonexistant TOML
source is requested. If JSON is used the error is part of the standard
response.

Update test_server.py to check for the correct error code.
2018-06-11 16:54:59 -07:00
Brian C. Lane
3f7997d7ae Fix handling bad source repos and add a test
When adding a source failed it wasn't being removed from the dnf object.
This fixes that, and returns an error when setting up the source fails.
Also adds a test for it.
2018-06-11 16:54:59 -07:00
Brian C. Lane
f1000b448d Make sure new sources show up in the source/list output
Also remove an unneeded makedirs from test_server.py
2018-06-11 16:54:59 -07:00
Brian C. Lane
33c84331fe Add support for user defined package sources API
This lives under /api/v0/projects/source/*

See the documentation for details
2018-06-11 16:54:59 -07:00
Brian C. Lane
b99d8d7f6b Add support for version globs to blueprints
You can use '*' wildcards and '?' for single character matching.
2018-06-11 16:54:59 -07:00
Brian C. Lane
050f87168a Skip creating groups with the same name as a user
Otherwise the user creation fails when anaconda sees there is already a
group with that name. Log a warning and continue on.

(cherry picked from commit a363aee971)
2018-06-11 16:54:59 -07:00
Brian C. Lane
5b7b37860a Add user and group creation to blueprint
[[customizations.user]] and [[customizations.group]]
2018-06-11 16:54:59 -07:00
Brian C. Lane
ccafa76019 Add blueprint customization support for hostname and ssh key
This adds support for the optional blueprint section [customizations].

Use it like this:

[customizations]
hostname = yourhostnamehere

[[customizations.sshkey]]
user = root
key = root user key
2018-06-11 16:54:59 -07:00
Brian C. Lane
85f365bd73 Sort the list of supported output types 2018-06-11 16:54:59 -07:00
Brian C. Lane
1fc7cff52b Add some tests for error conditions. 2018-06-11 16:54:59 -07:00
Brian C. Lane
520439a7c4 Move status to /api/status
Also drops /api/v0/test, and redirects / to /api/docs/

db and schema are fixed at 0 since lorax-composer uses yum, not the bdcs
metadata.db
2018-06-11 16:54:59 -07:00
Brian C. Lane
0d7e1dacfd Update the path for the test blueprints 2018-06-11 16:54:59 -07:00
Brian C. Lane
5efeb05aa7 Update composer-cli to use blueprint instead of recipe 2018-06-11 16:54:59 -07:00
Brian C. Lane
8c65257a5a Update the tests for the recipe -> blueprint change 2018-06-11 16:54:59 -07:00
Brian C. Lane
c22d05032e Change the tests for /recipes/ routes to /blueprints/ 2018-06-11 16:54:59 -07:00
Brian C. Lane
47a3980b12 Fix some pylint warnings 2018-06-11 16:54:59 -07:00
Brian C. Lane
6560cc6f27 Fix the prettyDiffEntry test so that it fails correctly 2018-06-11 16:54:58 -07:00
Brian C. Lane
1a4a4defcc Make sure lorax-composer tests only use temporary directories
It was using /var/tmp/composer/, now it places everything under a
temporary directory that is removed when it is finished.
2018-06-11 16:54:58 -07:00
Brian C. Lane
597c19466e Add some tests for composer-cli
These tests a fairly minimal, testing things that can be tested without
setting up a full API server.
2018-06-11 16:54:58 -07:00
Brian C. Lane
d2f784e5da Add composer-cli utility and implement the recipes commands
composer-cli --help shows the commands.
Output defaults to human readable, but raw json can be displayed by
passing --json
2018-06-11 16:54:58 -07:00
Brian C. Lane
0ea4eb5206 Fix epoch to ouput an int instead of a str
Also updates the tests.
2018-06-11 16:54:58 -07:00
Brian C. Lane
74326ba7a3 Fix a problem with diff/NEWEST/WORKSPACE
If there is no WORKSPACE yet it was not falling back to using NEWEST.
Also add a test for this.
2018-06-11 16:54:58 -07:00
Alexander Todorov
06648d415a Don't be overly strict when validating /api/docs/ response in tests
this avoids comparing against files on disk (and the huge diff the
test runner produces in case of failure). Instead we look for a
200 HTTP response with large enough size and some well known
strings inside the response data.
2018-06-11 16:54:58 -07:00
Alexander Todorov
91cebe7b67 Measure coverage for parallel processes 2018-06-11 16:54:58 -07:00
Alexander Todorov
af8c193b52 Remove calls to print() 2018-06-11 16:54:58 -07:00
Alexander Todorov
98f3b7e7eb Add tests for api.crossdomain.py 2018-06-11 16:54:58 -07:00
Alexander Todorov
3dd5612732 Fix syntax error caused by conflict resolution 2018-06-11 16:54:58 -07:00
Brian C. Lane
fdecf13299 Add tests for /compose API
Because you cannot share data between test methods these have to all be
in one big function. This adds one series to test the failed compose
results, and a 2nd function to test for the successful compose.
2018-06-11 16:54:58 -07:00
Alexander Todorov
d3d92d13b1 Add tests for functions in api/projects 2018-06-11 16:54:58 -07:00
Alexander Todorov
1c977b79ef Add tests for api/server.py
some of the new tests require that we first build the documentation
2018-06-11 16:54:58 -07:00
Alexander Todorov
32db249538 Add tests for yumbase and update how we inspect boolean options
.get_default() returns string so make sure we're actually parsing
the value as boolean and not evaluating a non-empty string in a
boolean context (which will always return True)
2018-06-11 16:54:58 -07:00