-
-
Notifications
You must be signed in to change notification settings - Fork 227
Add tests for ansible and system manager modules #1746
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
Open
jfroche
wants to merge
64
commits into
update-nixpkgs
Choose a base branch
from
feat/ansible-testing
base: update-nixpkgs
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 all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
d5dc875
chore: fix missing required `teams` meta attribute
jfroche bf68f79
chore: update old (unsupported) version of nix used in script
jfroche 8167ac8
fix: overlay and use our `buildPgrxExtension` function
jfroche 6b7dc77
chore: fix formatting
jfroche f9be109
chore: replace (deprecated) `substituteAll` by `replaceVars`
jfroche 8394196
chore: update (and refactor) flake inputs
jfroche f1f0461
chore: bump `pgrouting` version to 3.8.0
yvan-sraka 7e93371
fix: backport tzdata fixes for postgresql 15
jfroche d2b1c7a
fix: plv8 3.1 requires older v8
jfroche 54f6a29
chore: update fmt
jfroche 0165589
chore: update cargo-pgrx 1.14.3 cargo hash
jfroche 8ec7f60
chore(postgresql): add isOrioleDB condition
jfroche 64e3a3e
fix: pgregress tests
jfroche 8782e79
fix: update schema for dbmate schema_migrations table
jfroche 3e4220f
Structured attributes are now required when building with separateDeb…
jfroche fed71be
chore: version bump
samrose 4cce9ef
fix: rebase on develop and fix code api changes from nixpkgs
samrose 89be0d3
tests: try to get passing tests
samrose 86ba986
feat: pin icu75 for postgres build to maintain compat with existing
samrose 9088d48
chore: remove commented out code not needed in latest changes to pg
samrose 87184c9
fix: apparently incorrectly rebased changes, and % nix fmt
yvan-sraka 8fec562
chore: remove nixpkgs-pgbackrest input, and % nix flake update
yvan-sraka 8b409f2
fix: replace deprecated v8 package, and wrong packages arguments
yvan-sraka b6f1ac1
chore: fix formatting
jfroche 643b221
fix(darwin): remove reference to apple-sdk
jfroche e1bcb9b
fix(ext): missing required attributes in some extension tests
jfroche b6e94d9
chore: % nix flake update && nix fmt
yvan-sraka 34cdc8c
fix(orioledb): fixed installedExtensions reference to use proper self…
yvan-sraka 053dd20
fix(postgresql): remove redundant patch substitutions
yvan-sraka 8de15a6
fix(pgrx): remove deprecated darwin.apple_sdk.frameworks.Security
yvan-sraka 0481809
fix(postgis): remove custom sfcgal package dependency
yvan-sraka c1e47a6
fix(pg_net): pin curl to older nixpkgs version
yvan-sraka cc9ceae
fix(pgrx): error: multiple input filenames provided
yvan-sraka cf8aa90
fix(tests): updated test expectations
yvan-sraka 55d1468
feat: (re)add check_pg_regress method to PostgresExtensionTest
yvan-sraka 174a305
refactor: replace fetchTarball with flake input for nixpkgs-oldstable
yvan-sraka ab08aec
fix(pg_net): disable dangling-assignment warning for v0.19.5 on aarch…
yvan-sraka 3c2cb90
fix(plv8): add headerpad_max_install_names for macOS builds
yvan-sraka 2ab7cfe
fix(tests): correct library naming and symlinks for background worker…
yvan-sraka 3692bae
refactor(exts): replace nixpkgs-oldstable with specific overlay packages
yvan-sraka 8b3e1e8
fix: restore revision support for orioledb builds (introduced it #1880)
yvan-sraka b4a7968
fix(exts): remove old files that were moved to subdirectories
yvan-sraka 8c86bb4
fix(flake): remove nixpkgs-go124 and nix-fast-build dependencies
yvan-sraka d5e4727
fix(flake): update flake.lock and cargo-pgrx hashes
yvan-sraka e0a9e5e
fix(exts): remove remaining duplicated files
yvan-sraka 8f4a99a
refactor(pgrx): conditionally apply rustc wrapper when < 0.12
yvan-sraka 7597e3b
refactor(nixpkgs): use let binding for oldstable instead of overlay
yvan-sraka 2ac85c8
refactor(groonga): move groonga package to pgroonga extension
yvan-sraka 3e9d6b5
fix(ansible): remove supabase-groonga from package install list
yvan-sraka 962db9e
Revert "fix(ansible): remove supabase-groonga from package install list"
yvan-sraka 1f5ab20
Revert "refactor(groonga): move groonga package to pgroonga extension"
yvan-sraka 3e729f7
fix(darwin): remove deprecated apple_sdk frameworks from supascan
yvan-sraka 747a547
chore: bump version suffix to test
yvan-sraka 2b48244
chore: bump to retest
samrose 4e32d5b
chore: suffix to test
samrose 6c2d201
chore: bump to test
samrose 1efb657
feat: add ansible task testing infrastructure based on Docker and pytest
jfroche 2afe94e
feat: deploy nginx using system manager
jfroche 83f8ad3
chore: simplify system manager tests
jfroche 9144fcc
chore: formatting
jfroche 9556ef7
Test system manager deployment triggered by Ansible
jfroche a6de462
Create default system manager configuration
jfroche f892bb3
ci: make sure we cache system manager and its test dependencies
jfroche 0b687d4
chores: add nix run .#ansible-test and .#check-system-module to githu…
yvan-sraka 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 hidden or 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,27 @@ | ||
| name: Ansible Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - feat/ansible-testing | ||
| pull_request: | ||
| branches: | ||
| - feat/ansible-testing | ||
|
|
||
| jobs: | ||
| ansible-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: supabase/postgres/.github/actions/shared-checkout@HEAD | ||
|
|
||
| - name: Install nix | ||
| uses: cachix/install-nix-action@v27 | ||
| with: | ||
| install_url: https://releases.nixos.org/nix/nix-2.29.1/install | ||
| extra_nix_config: | | ||
| substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com | ||
| trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= | ||
|
|
||
| - name: Run Ansible Test | ||
| run: nix run .#ansible-test |
This file contains hidden or 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,27 @@ | ||
| name: Check System Manager | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - feat/ansible-testing | ||
| pull_request: | ||
| branches: | ||
| - feat/ansible-testing | ||
|
|
||
| jobs: | ||
| check-system-manager: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: supabase/postgres/.github/actions/shared-checkout@HEAD | ||
|
|
||
| - name: Install nix | ||
| uses: cachix/install-nix-action@v27 | ||
| with: | ||
| install_url: https://releases.nixos.org/nix/nix-2.29.1/install | ||
| extra_nix_config: | | ||
| substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com | ||
| trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= | ||
|
|
||
| - name: Run check-system-manager | ||
| run: nix run .#check-system-manager |
This file contains hidden or 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 @@ | ||
| ../files |
This file contains hidden or 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,11 @@ | ||
| --- | ||
| - name: Check if nix is installed | ||
| ansible.builtin.command: which nix | ||
| register: nix_installed | ||
| failed_when: nix_installed.rc != 0 | ||
| ignore_errors: true | ||
|
|
||
| - name: Install nix | ||
| ansible.builtin.shell: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm --extra-conf 'substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com' --extra-conf 'trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' | ||
| when: nix_installed.rc != 0 | ||
| become: true | ||
This file contains hidden or 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,7 @@ | ||
| --- | ||
| - name: Deploy system manager | ||
| ansible.builtin.shell: | | ||
| . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh | ||
| cd /tmp | ||
| nix run /flake#system-manager -- switch --flake /flake | ||
| become: true |
This file contains hidden or 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,79 @@ | ||
| import pytest | ||
| import subprocess | ||
| import testinfra | ||
| from rich.console import Console | ||
|
|
||
| console = Console() | ||
|
|
||
|
|
||
| def pytest_addoption(parser): | ||
| parser.addoption( | ||
| "--flake-dir", | ||
| action="store", | ||
| help="Directory containing the current flake", | ||
| ) | ||
|
|
||
| parser.addoption( | ||
| "--docker-image", | ||
| action="store", | ||
| help="Docker image and tag to use for testing", | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def host(request): | ||
| flake_dir = request.config.getoption("--flake-dir") | ||
| docker_id = ( | ||
| subprocess.check_output( | ||
| [ | ||
| "docker", | ||
| "run", | ||
| "--privileged", | ||
| "--cap-add", | ||
| "SYS_ADMIN", | ||
| "--security-opt", | ||
| "seccomp=unconfined", | ||
| "--cgroup-parent=docker.slice", | ||
| "--cgroupns", | ||
| "private", | ||
| "-v", | ||
| f"{flake_dir}:/flake", | ||
| "-d", | ||
| "ubuntu-cloudimg-with-tools:0.1", | ||
| ] | ||
| ) | ||
| .decode() | ||
| .strip() | ||
| ) | ||
| yield testinfra.get_host("docker://" + docker_id) | ||
| subprocess.check_call(["docker", "rm", "-f", docker_id], stdout=subprocess.DEVNULL) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def run_ansible_playbook(host): | ||
| def _run_playbook(playbook_name, verbose=False): | ||
| cmd = [ | ||
| "ANSIBLE_HOST_KEY_CHECKING=False", | ||
| "ansible-playbook", | ||
| "--connection=local", | ||
| ] | ||
| if verbose: | ||
| cmd.append("-vvv") | ||
| cmd.extend( | ||
| [ | ||
| "-i", | ||
| "localhost,", | ||
| "--extra-vars", | ||
| "@/flake/ansible/vars.yml", | ||
| f"/flake/ansible/tests/{playbook_name}", | ||
| ] | ||
| ) | ||
| result = host.run(" ".join(cmd)) | ||
| if result.failed: | ||
| console.log(result.stdout) | ||
| console.log(result.stderr) | ||
| raise pytest.fail( | ||
| f"Ansible playbook {playbook_name} failed with return code {result.rc}" | ||
| ) | ||
|
|
||
| return _run_playbook |
This file contains hidden or 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,14 @@ | ||
| --- | ||
| - hosts: localhost | ||
| tasks: | ||
| - name: Install dependencies | ||
| apt: | ||
| pkg: | ||
| - build-essential | ||
| update_cache: yes | ||
| - import_tasks: ../tasks/setup-nginx.yml | ||
| - name: Start Nginx service | ||
| service: | ||
| name: nginx | ||
| state: started | ||
| enabled: yes |
This file contains hidden or 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,5 @@ | ||
| --- | ||
| - hosts: localhost | ||
| tasks: | ||
| - import_tasks: ../tasks/setup-nix.yml | ||
| - import_tasks: ../tasks/setup-system-manager.yml |
This file contains hidden or 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,11 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
| def run_ansible(run_ansible_playbook): | ||
| run_ansible_playbook("nginx.yaml") | ||
|
|
||
|
|
||
| def test_nginx_service(host): | ||
| assert host.service("nginx.service").is_valid | ||
| assert host.service("nginx.service").is_running |
This file contains hidden or 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,10 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
| def run_ansible(run_ansible_playbook): | ||
| run_ansible_playbook("nix.yaml", verbose=True) | ||
|
|
||
|
|
||
| def test_nix_service(host): | ||
| assert host.service("nix-daemon.service").is_running |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
instead of
ignore_errors, why not use a block/rescue