Skip to content

Conversation

@james-garner-canonical
Copy link
Contributor

@james-garner-canonical james-garner-canonical commented Dec 12, 2025

The ops.testing framework currently exposes the private _CharmSpec class via the Context.charm_spec attribute (canonical/operator#2131). Charm Tech will deprecate this attribute soon (canonical/operator#2219). Charmcraft currently uses charm_spec in the init-extensions tests, so this PR preemptively modernises the test to use State.from_context, avoiding the need to access Context.charm_spec.

The init-extensions tests run only in the Ubuntu 22.04 spread tests. While that job is currently failing, the failing tests do not appear to be the init-extensions tests:

2025-12-12 04:44:41 Successful tasks: 50
error: unsuccessful run
2025-12-12 04:44:41 Aborted tasks: 0
2025-12-12 04:44:41 Failed tasks: 3
    - google:ubuntu-22.04-64:tests/spread/smoketests/different-dir
    - google:ubuntu-22.04-64:tests/spread/smoketests/multi-base:basic
    - google:ubuntu-22.04-64:tests/spread/smoketests/multi-base:one_platform
2025-12-12 04:44:41 Failed task restore: 2
    - google:ubuntu-22.04-64:tests/spread/smoketests/multi-base:basic
    - google:ubuntu-22.04-64:tests/spread/smoketests/multi-base:one_platform
AFAICT the init-extensions tests pass, here's some relevant output from this run.
2025-12-12 03:40:14 Restoring google:ubuntu-22.04-64:tests/spread/commands/init-extensions:springboot (dec120311-758761)...
2025-12-12 03:40:28 Preparing google:ubuntu-22.04-64:tests/spread/smoketests/reactive:stable (dec120311-758761)...
2025-12-12 03:40:29 Executing google:ubuntu-22.04-64:tests/spread/smoketests/reactive:stable (dec120311-758761) (7/53)...
2025-12-12 03:40:34 Restoring google:ubuntu-22.04-64:tests/spread/commands/init-extensions:flask (dec120311-758749)...
2025-12-12 03:40:50 Preparing google:ubuntu-22.04-64:tests/spread/smoketests/reactive:two (dec120311-758749)...
2025-12-12 03:40:51 Executing google:ubuntu-22.04-64:tests/spread/smoketests/reactive:two (dec120311-758749) (8/53)...
2025-12-12 03:41:14 Restoring google:ubuntu-22.04-64:tests/spread/commands/init-extensions:expressjs (dec120311-758638)...
2025-12-12 03:41:14 Restoring google:ubuntu-22.04-64:tests/spread/commands/init-extensions:fastapi (dec120311-758711)...
2025-12-12 03:41:30 Preparing google:ubuntu-22.04-64:tests/spread/dependencies/ (dec120311-758711)...
2025-12-12 03:41:30 Preparing google:ubuntu-22.04-64:tests/spread/dependencies/ (dec120311-758638)...
2025-12-12 03:41:34 Restoring google:ubuntu-22.04-64:tests/spread/commands/init-extensions:go (dec120311-758738)...
2025-12-12 03:41:52 Preparing google:ubuntu-22.04-64:tests/spread/smoketests/multi-base:all (dec120311-758738)...
2025-12-12 03:41:55 Executing google:ubuntu-22.04-64:tests/spread/smoketests/multi-base:all (dec120311-758738) (9/53)...
2025-12-12 03:42:40 Restoring google:ubuntu-22.04-64:tests/spread/commands/init-extensions:django (dec120311-758757)...

  • I've followed the contribution guidelines.
  • I've signed the CLA.
  • I've successfully run make lint && make test.
  • I've added or updated any relevant documentation. (N/A)
  • I've updated the relevant release notes. (N/A)

@james-garner-canonical james-garner-canonical changed the title test: refactor to avoid using ops.testing.Context.charm_spec test: refactor init-extensions to avoid using ops.testing.Context.charm_spec Dec 14, 2025
@james-garner-canonical james-garner-canonical changed the title test: refactor init-extensions to avoid using ops.testing.Context.charm_spec test: refactor init-extensions tests to avoid using ops.testing.Context.charm_spec Dec 14, 2025
@james-garner-canonical james-garner-canonical marked this pull request as ready for review December 14, 2025 20:43
Copy link
Collaborator

@lengau lengau left a comment

Choose a reason for hiding this comment

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

Thanks! We need this sort of modernisation in a lot of places ☺️

@james-garner-canonical
Copy link
Contributor Author

The 3.5.0 ops release yesterday includes the deprecation of Context.charm_spec. Is anything further needed in this PR before merging?

@lengau
Copy link
Collaborator

lengau commented Dec 19, 2025

@james-garner-canonical nope — I just didn't see the approval. Merging nowe!

@lengau lengau merged commit ede1738 into canonical:main Dec 19, 2025
21 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants