Skip to content
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

feat: add test command and templates #1660

Merged

Conversation

cmatsuoka
Copy link
Contributor

The charmcraft test command invokes spread to run test suites on
local and remote machines. A pre-defined spread configuration and
multipass back-end are supplied.

Signed-off-by: Claudio Matsuoka claudio.matsuoka@canonical.com

@cmatsuoka cmatsuoka requested review from lengau and mr-cal April 19, 2024 11:58
@cmatsuoka cmatsuoka force-pushed the CRAFT-2707-Write-k8s-charm-test-templates-for-charmcraft-test branch 4 times, most recently from f07efab to c6df503 Compare April 22, 2024 17:01
The `charmcraft test` command invokes spread to run test suites on
local and remote machines. A pre-defined spread configuration and
multipass back-end are supplied.

Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
@cmatsuoka cmatsuoka force-pushed the CRAFT-2707-Write-k8s-charm-test-templates-for-charmcraft-test branch from c6df503 to eb6213a Compare April 22, 2024 18:10
@cmatsuoka
Copy link
Contributor Author

Rebased on main.

Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
@cmatsuoka cmatsuoka force-pushed the CRAFT-2707-Write-k8s-charm-test-templates-for-charmcraft-test branch from eb6213a to cfda0e4 Compare April 22, 2024 18:21
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
@cmatsuoka cmatsuoka force-pushed the CRAFT-2707-Write-k8s-charm-test-templates-for-charmcraft-test branch from 7efba0b to 0d5c2a0 Compare April 22, 2024 19:01
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
@cmatsuoka cmatsuoka force-pushed the CRAFT-2707-Write-k8s-charm-test-templates-for-charmcraft-test branch from 0d5c2a0 to 6b1bb65 Compare April 22, 2024 19:39
# arguments. We should implement better support for this case
# in craft-application.
idx = sys.argv.index("test") + 1
sys.argv = [*sys.argv[:idx], "--", *sys.argv[idx:]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still going to be a little bit weird because charmcraft test will take arguments like -shell rather than --shell. Can you think of a downside of stripping -- off the start of test parameters and replacing it with -?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The -- separator is actually parsed by argparse to make it ignore any argument after that (so we can pass it directly to spread). The - vs -- inconsistency is an issue however, we can discuss that further and maybe go back to using -- as an explicit separator.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, especially with the way this obscures the help text. I think long-term we'll probably need to make our own items for common parameters and then let the user pass -- <spread-params> if they want to do anything fancy with spread.

Copy link
Contributor

@mr-cal mr-cal left a comment

Choose a reason for hiding this comment

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

Looking good!

Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Also don't run the github back-end locally.

Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
@cmatsuoka cmatsuoka requested review from lengau and mr-cal April 29, 2024 15:59
Copy link
Contributor

@mr-cal mr-cal left a comment

Choose a reason for hiding this comment

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

Nice work!

Do you need charmcraft/templates/init-machine/tests/spread/lib/tools/retry.j2?

charmcraft/application/commands/test.py Outdated Show resolved Hide resolved
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
@lengau lengau merged commit 097a4e9 into main May 8, 2024
14 checks passed
@lengau lengau deleted the CRAFT-2707-Write-k8s-charm-test-templates-for-charmcraft-test branch May 8, 2024 14:08
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