Skip to content

fix: unbreak the collection against current DVLS - #34

Merged
Danny Bédard (DannyBedard) merged 4 commits into
masterfrom
devops/deterministic-integration-tests
Sep 11, 2026
Merged

Danny Bédard (DannyBedard) merged 4 commits into
masterfrom
devops/deterministic-integration-tests

Conversation

@DannyBedard

@DannyBedard Danny Bédard (DannyBedard) commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

La CI était rouge depuis avril: les tests dépendaient d'entrées déjà présentes sur le serveur, dont un id codé en dur, et faisaient surtout des debug au lieu d'assertions. Chaque play crée maintenant ce qu'il lit sous un nom unique au run, vérifie ce qu'il a écrit, et supprime ses entrées ensuite. Deux vrais bugs sont sortis de là.

create_secret ne pouvait plus mettre à jour un secret existant: DVLS exige maintenant le champ tags sur un PUT et renvoyait un 400 nu. Les mises à jour renvoient les tags que l'entrée possède déjà, et le test le vérifie en posant un tag puis en le relisant après coup.

Tout échec de login remontait en « Module result deserialization failed » sur ansible-core 2.19, parce que le finally appelait logout avec un token jamais assigné. C'est le cas de support de février, invisible sur 2.18. Un nouveau job rejoue les trois modules contre un serveur injoignable, sur ansible 11 et ansible 12, pour que ça ne repasse plus inaperçu.

Les erreurs de DVLS sont aussi remontées telles quelles au lieu du seul code HTTP. C'est ce qui a permis de trouver les deux bugs.

Run vert: https://github.com/Devolutions/ansible-dvls/actions/runs/34516089755

…osable

The playbooks read entries that had to already exist on the test server,
including a hardcoded entry id, so the suite broke whenever that server
drifted. Most tasks also only printed their result instead of asserting
anything. Each play now creates what it reads under a name unique to the
run, asserts the values it wrote, and deletes its entries afterwards.
Updating an existing secret failed with a bare 400: DVLS now requires the
tags field on a PUT. Updates resend the tags the entry already has.

Any login failure surfaced as "Module result deserialization failed" on
ansible-core 2.19, because the finally block called logout with a token
that was never assigned. This is the February support case, invisible on
2.18.

DVLS error messages are reported instead of only the status code, and
the entry payload matches the public API (subType, non null
description).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Tests retain external-state dependencies, expose cleanup tokens, and do not cover key regressions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Improves DVLS integration-test reliability while fixing secret updates and login-error handling.

Changes:

  • Creates run-specific test secrets with assertions and cleanup.
  • Preserves tags during updates and surfaces DVLS response details.
  • Safely handles failed authentication and bumps version to 1.3.1.
File summaries
File Description
tests/integration/test_manage_server.yml Replaces debug output with server assertions.
tests/integration/test_manage_secrets.yml Adds isolated secret lifecycle tests and cleanup.
tests/integration/test_lookup_plugins.yml Reworks lookup tests around generated credentials.
tests/integration/configurations.yml Uses the current run’s generated entry name.
plugins/modules/fetch_server.py Prevents logout after failed login.
plugins/modules/fetch_secrets.py Prevents logout after failed login.
plugins/modules/create_secret.py Fixes payloads, tag preservation, errors, and logout handling.
galaxy.yml Bumps the collection version to 1.3.1.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/integration/test_lookup_plugins.yml
Comment thread tests/integration/test_manage_secrets.yml
app_key = module.params["app_key"]
app_secret = module.params["app_secret"]

token = None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien vu, requirements.txt épingle ansible~=11.3 donc la suite ne tournait que sur core 2.18, exactement la version où le bug est invisible.

Ajouté: tests/integration/test_error_handling.yml appelle les trois modules contre un serveur injoignable et vérifie que c'est bien l'erreur de login qui remonte, avec un job matriciel sur ansible 11 et ansible 12. Vérifié en réintroduisant le bug localement: sur 2.19 le test échoue avec « fetch_server masked the login error instead of reporting it: Module result deserialization failed ».

Comment thread tests/integration/test_lookup_plugins.yml
Comment thread tests/integration/test_manage_secrets.yml
@DannyBedard
Danny Bédard (DannyBedard) force-pushed the devops/deterministic-integration-tests branch 3 times, most recently from 73090a3 to f6bcd7d Compare September 10, 2026 18:43
@DannyBedard Danny Bédard (DannyBedard) changed the title Devops/deterministic integration tests fix: unbreak the collection against current DVLS Sep 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Integration tests can expose credential data in verbose logs and leave direct API sessions unreleased.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

tests/integration/test_manage_secrets.yml:220

  • The three direct API login tasks in this play never call /api/v1/logout, and reassigning dvls_login also loses the earlier token. Each CI run can therefore leave multiple sessions active until server-side expiry; reuse the first token where possible and revoke every acquired token from an always cleanup path, as the collection modules do.
        - name: Log in to DVLS
          ansible.builtin.uri:
            url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}/api/v1/login"
            method: POST
            body_format: json

tests/integration/test_lookup_plugins.yml:103

  • This cleanup creates a fresh DVLS session but never calls /api/v1/logout, so repeated CI runs can accumulate active tokens until server-side expiry. Wrap deletion in a nested block/always and revoke cleanup_login.json.tokenId through the logout endpoint even when deletion fails.
        - name: Log in to DVLS for the cleanup
          ansible.builtin.uri:
            url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}/api/v1/login"
            method: POST
            body_format: json
  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread tests/integration/test_lookup_plugins.yml
Comment thread tests/integration/test_manage_secrets.yml
@DannyBedard
Danny Bédard (DannyBedard) force-pushed the devops/deterministic-integration-tests branch from f6bcd7d to b2e79d1 Compare September 10, 2026 19:34
…eanup token

The suite runs on ansible-core 2.18 only, so it could not catch the
login failure masking that only shows up on 2.19. A new play calls every
module against an unreachable server and asserts the login error is
reported, and it runs on both ansible 11 and ansible 12.

The update test now seeds a tag through the API and checks it survives,
so it actually covers the tag preservation it relies on.

The cleanup passed tokenId through the generic uri headers argument,
which Ansible does not redact, so a verbose or failed cleanup could
print it. Those tasks are no_log now.
@DannyBedard
Danny Bédard (DannyBedard) force-pushed the devops/deterministic-integration-tests branch from b2e79d1 to 8170972 Compare September 10, 2026 19:38
@DannyBedard

Copy link
Copy Markdown
Contributor Author

Deuxième passe traitée. Les tâches qui ramènent des credentials sont no_log: true, côté modules comme côté lookups.

Sur les sessions API laissées ouvertes que mentionne le résumé: un logout explicite a été essayé puis retiré. Une app identity DVLS ne tient qu'une session à la fois, donc chaque login invalide le précédent et le play en garde au plus une, qui expire seule. La tâche de logout ajoutait surtout une surface d'échec dans le bloc de nettoyage.

Reste connu et non traité ici: le test de lookup par path dépend encore de l'entrée tests\lookup-plugin et du fait qu'elle soit seule dans son dossier. L'isoler demande de créer un dossier, ce que la collection ne sait pas faire.

Run vert: https://github.com/Devolutions/ansible-dvls/actions/runs/34521604516

@DannyBedard
Danny Bédard (DannyBedard) merged commit 1ae6209 into master Sep 11, 2026
6 checks passed
@DannyBedard
Danny Bédard (DannyBedard) deleted the devops/deterministic-integration-tests branch September 11, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants