Skip to content

Commit

Permalink
Make testsuite work again (#255)
Browse files Browse the repository at this point in the history
* Make the cli exceptions write to outputmanager

* Replace formatted datetime strings in output

* Fix workflow annotations about GH action versions

* Update testsuite json with modified label commands

* Workaround for json-incapable server

* Also use workaround for patch requests

* Use OutputManager instead of the cli_* methods

* Use specialized exceptions. (#256)

- This PR migrates all use of CliError and CliWarning to more specialized exceptions.
  - Also fix a bug with handling broken filter expressions.
  - Prefixes Errors with ERROR as not everyone has color vision.

* Cull utility functions that aren't used anymore

* Further culling of... old stuff.

* Fix valid_numeric_ttl min and max value handling

* Use `APIMixin.patch()` in `Zone.set_default_ttl()`

* Add missing OK message for `host add`

* Remove IP/network from `host add` OK message

* Verified behaviour for all zone commands

I have looked at the new output and api calls for the "zone" commands in
the testsuite and it looks good to me. Updating testsuite-result.json to
reflect that.

* Verified behaviour for all group commands

I have looked at the new output and api calls for the "group" commands
in the testsuite and it looks good to me.
Fixed a bug in history.py concerning how history is printed when owners
or hosts are added/removed from hostgroups.
Made a minor change to the datetime regex in diff.py to handle the extra
space that comes before a single digit date.

* Fix fetching network from location header (#258)

* Extract fetching resource by location to separate method

Fixes failing `network create` tests

* Use `field_for_endpoint()`

* Prefer using location header verbatim

Adds handling for endpoints that return invalid location headers.

* Remove `field_for_endpoint()`

* Remove placeholder comment, move src comments

* Remove special label handling, never re-fetch labels

* Add a check for frozen/force to "host add"

We forgot to check if the network was frozen in "host add". Added a
check for that in this commit, but we'll probably have to do
something similar in a_aaaa.py.

Went through more command output and verified it. Mostly network
commands this time.

Modified diff.py to not care about length of white space. Since ip
addresses can vary between runs, formatted output can vary in length,
spesifically how much whitespace is added.

* Fix fetching paginated endpoints twice in `get_list_generic` (#261)

* Fix fetching paginated endpoints twice in `get_list_generic`

* Break instead of return

* Refactor `get_list_generic` result checking

* Fix network excluded range output.

  - Also use IPAddressField for ips in excluded ranges.

* Fix delegeation response.

  - Add support for "delegation" scope akin to "zone" scope in server responses for zones.

* Implement logging. (#266)

* Implement logging.

  - Migrates out logging and recording commands to their own command files.
  - During the logging setup there was an issue trying to untangle commands and conventions, so most commands are now refactored into proper command files.
  - Add logging to API calls and output.
  - Move CliExit to exceptions.py...
  - When logging API calls, also logs the clients corrolation ID (for requests and respones) and the servers request ID (per request/response) for easier server side debugging. :)
  - Restrict logging (to errors only) when running the test suite, it's... noisy. :D

---------

Co-authored-by: Peder Hovdan Andresen <[email protected]>

* Support sending more than str to post. (#264)

* Support sending more than str to post.

Also fix some ruffs.

* Consistent signatures for get_list_generic.

---------

Co-authored-by: Peder Hovdan Andresen <[email protected]>

* Fix a bug in remove_excluded_range

models.Network.remove_excluded_range had a bug where it wouldn't match
the supplied parameters even when a range existed.
Solved by converting the ip address values to strings.

This commit also updates the rest of the "network" part of the test
suite results.

* Add network set_category/set_location commands

* Escape error messages (#269)

* Escape exception messages in HTML text

* Only escape message, not formatted exc

* Escape messages only in formatted exceptions (#271)

* Escape messages only in formatted exceptions

* Rename `escaped()` to `escape()`

* Add `QueryParams` type (#273)

* Add `QueryParams` type

* Remove redundant dict comprehension

* Add interactive diffing (#270)

Revert "Use dumb terminal only for diff.py"

This reverts commit 42a70de.

Use dumb terminal only for diff.py

Remove vertical borders for easier copying

Add comment about review mode

Invert conditional

Docstrings, ordering

Comments, names, docstrings

Don't review in CI

Change choices (order + choice)

Remove unused state

Revert "Run diff.py on testsuite results"

This reverts commit def4bc5.

Run diff.py on testsuite results

Refactor diff.py

Add interactive diffing

* Add force req for frozen nets to a_add, aaaa_add

Also:
- Add "rich" to requirements-dev.txt, it was missing
- Update testsuite-result.json with more verified test output

* Fix problems with history output

Also, update more test resuls

* Add minor quality of life + message changes to diff.py (#275)

* Remove `getattr()` usage in `_request_wrapper()`. (#274)

* Remove LoginFailedError message hard coding. (#277)

* Remove hardcoded LoginFailed output.

Fixes #272

* Fix quote usage and handle direction (im)possibly being unassigned. (#279)

* Add a regex for macaddress to diff.py

Macaddresses were caught by the IPv6 regex, which made certain commands
in the testsuite look like the wrong type of parameter was supplied.

* Add OK message to a_add when success

Also, avoid refetching the host twice.

* Remove unnecessary warning from dhcp assoc

dhcp assoc <hostname> <ip> would warn that hostname isn't a valid ip
address. This commit changes the code so the exception isn't raised but
otherwise it works the same.

Also:
- A minor change to an error message about a host having multiple ips.
- Verified the output from the rest of the commands in the dhcp section.

* Remove stripping of None values from PATCH calls (#282)

Also ensures nullable and non-nullable TTL fields are treated differently.

* Improve diff numbering + messages (#284)

* Add number to diff when reviewing

* Improve diff messages

* Handle `DiffError`

* Add `ERROR` msg prefix for exceptions

* Fix inconsistent stdout/stderr printing

* Remove parenthesis around plural s

* Fix `host set_comment` with empty string (#283)

* Use Pydantic v2 style model config in `FrozenModel` (#285)

* Use object repr when PATCH validation fails

* Improve type safety of validators (#286)

* Improve type safety of validators

* Remove unused import

* Improve safety of TTL methods for non-nullable fields (#287)

* Improve safety of TTL methods for non-nullable fields

* Add external id field for `Endpoint.Nameservers`

* Add QueryParam annotations for inline params

* Replace IDs & IPs in test result URLs (#288)

* Replace IDs & IPs in test result URLs

* Simplify `unquote_url`

* Expand match group explanations

* Fix comment typo

* A few code changes + changes to testsuite-result (#289)

- Changes to testsuite-result.json that came from #288
- The rest of the changes to testsuite-result.json, manually verified
- a_aaaa.py: Add a message and a requirement for force when adding an additional IP address to a host.
- rr.py: Replace occurrences of str(host.id) with host.id in API requests.

* Write back original lines in diff review (#290)

* Write back non-placeholder lines in diff reviews

* Refactor results to classes

* Rename `TestSuiteLog` to `TestSuiteResult`

* Delete .pyi file

* Fix missing None check

* Accept int values in queries

* Add missing annotations import

* Use uv in CI (#292)

* Use uv in CI

* Use official uv action

* Add build dependencies to pyproject.toml

* Use uv run?

* Set up python with uv in CI

* idk

* Use venv

* uv run?

* Use uv python when building too

* Remove system python env var

---------

Co-authored-by: pederhan <[email protected]>
Co-authored-by: Terje Kvernes <[email protected]>
Co-authored-by: Terje Kvernes <[email protected]>
Co-authored-by: Peder Hovdan Andresen <[email protected]>
  • Loading branch information
5 people authored Sep 17, 2024
1 parent 7485ec1 commit c5f46ca
Show file tree
Hide file tree
Showing 49 changed files with 18,041 additions and 14,666 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ jobs:
- name: Exit if not on master branch
if: github.ref_name != 'master'
run: exit -1

- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Set up Python 3.12
run: uv python install 3.12

- name: Install build dependencies
run: python -m pip install --upgrade build
run: |
uv venv
uv pip install --upgrade build
- name: Build source distribution
run: python -m build
run: uv run python -m build

- uses: actions/upload-artifact@v4
with:
Expand All @@ -43,15 +51,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Run PyInstaller with Tox
run: |
python -m ensurepip --upgrade
python -m pip install tox tox-uv tox-gh-actions
uv venv
uv pip install tox-uv tox-gh-actions
tox
- name: Rename binary
Expand Down
43 changes: 19 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
on: [push, pull_request]


name: CI
jobs:
test:
Expand All @@ -11,28 +12,22 @@ jobs:
python-version:
- '3.11'
- '3.12'
env:
# Disable colors and formatting in Rich console output
TERM: dumb
steps:
- name: Checkout
uses: actions/checkout@v3
# - name: Cache pip
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: v1-pip-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements-*.txt') }}
# restore-keys: |
# v1-pip-${{ runner.os }}-${{ matrix.python-version }}
# v1-pip-${{ runner.os }}
# v1-pip-
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install mreg-cli
run: |
python -m ensurepip --upgrade
pip install -e .
uv venv
uv pip install -e .[dev]
- name: Test and compare api calls
run: ci/run_testsuite_and_record.sh
run: uv run ci/run_testsuite_and_record.sh

tox:
name: tox
Expand All @@ -45,15 +40,15 @@ jobs:
- "3.12"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m ensurepip --upgrade
python -m pip install tox tox-uv tox-gh-actions
uv venv
uv pip install tox-uv tox-gh-actions
- name: Test with tox
run: tox r
run: uv run tox r

Loading

0 comments on commit c5f46ca

Please sign in to comment.