-
Run spread tests for the project. charmcraft test [options]
-
See also: Create a unit test suite A unit test suite is a collection of unit tests. Each suite has a distinct set-up and tear-down logic. Unit test suites are often composed of util suites.
-
Source: https://github.com/juju/juju/tree/main/tests/suites An integration test suite is a collection of integration tests. Each suite has a distinct set-up and tear-down logic. Integration test suite...
-
Finally, to run the test, do: go test github.com/juju/juju/x/y/magic/ This will run all the tests registered in the magic package, including the one we just wrote. You can also chose to run specific t...
-
Source: https://github.com/juju/juju/tree/main/tests/includes In Juju, test includes are special bash util functions designed to help in creating effective integration test suites for juju. This docum...
-
See also: Integration testing This document demonstrates how to write an integration test for juju. First, navigate to the suites folder. In this directory, create a subdirectory named after the integ...
-
See also: Unit test suite To create a new unit test suite, you can do something like: type ToolsSuite struct { testing.BaseSuite dataDir string } var _ = gc.Suite(&ToolsSuite{}) If there is no extra s...
-
Since the version isn’t set by the charm code itself, you’ll want to test that the version is correctly set with an integration test, and don’t need to write a unit test. See first: How to write integ...
-
All code contributions must include tests. To run the tests locally before submitting your changes: TODO: test command 1 TODO: test command 2 Check linked code elements: Ensure coupled code elements, ...
-
To write a test function, use a Context object to encapsulate the charm type (MyCharm) and any necessary metadata. The test should then define the initial State and call Context.run with an event and ...
-
See first: How to write integration tests for a charm To verify that setting the workload version works correctly in an integration test, get the status of the model, and check the workload_version at...
-
Run juju add-secret to create a Juju user secret: juju add-secret metrics-user-password username=test password=test Caution Use a random password generator to create a password. You can use your prefe...
-
To test a relation between two applications, integrate them through the model. Both applications have to be deployed beforehand. ... async def test_my_integration(ops_test: OpsTest): # both applicatio...
-
Write an integration test that verifies that your charm behaves as expected in a real Juju environment. Other than when testing peer relations, as well as deploying your own charm, the test needs to ...
-
You’ll want to add unit tests. For integration tests: stored state isn’t a feature, it’s functionality that enables features, so your integration tests that make use of the stored state will verify th...
-
Here’s a minimal example: # Import Ops library's legacy testing harness import ops import ops.testing import pytest # Import your charm class from charm import TestCharmCharm @pytest.fixture def harne...
-
See first: How to write integration tests for a charm To verify that adding and removing storage works correctly against a real Juju instance, write an integration test with pytest_operator. For examp...
-
Append to test_provider.py the code below: import json from interface_tester import Tester from scenario import State, Relation def test_contract_happy_path(): # GIVEN that the remote end has requeste...
-
It is in our interest to move the handler logic for each /hooks/<hook_name> to Microsample._on_<hook_name>, for several reasons: We can avoid code duplication by accessing shared data via the CharmBas...
-
You’ll want to add unit and integration tests. See first: How to write unit tests for a charm, How to write integration tests for a charm To verify that the correct ports are open in an integration te...
-
window.location.href = '../create-a-unit-test-suite/index.html' + (window.location.search || '') + (window.location.hash || ''); You should have been redirected. If not, click here to continue.
-
See first: How to write unit tests for a charm If your charm requires access to resources, you can make them available to it through State.resources. For example, to make a foo resource that is a path...
-
If you’ve added custom instrumentation, it is because something important is recorded. Let’s validate that in a unit test. The trace_data attribute of the ops.testing.Context class of the testing fra...
-
To test charms that use Pebble Notices, use the pebble_custom_notice method to simulate recording a notice with the given details. For example, to simulate the “backup-done” notice handled above, as w...
-
window.location.href = '../../index.html' + (window.location.search || '') + (window.location.hash || ''); You should have been redirected. If not, click here to continue.
-
data "juju_jaas_group" "test" { name = "group-0" } output "group_uuid" { value = data.juju_jaas_group.test.uuid }
-
data "juju_jaas_role" "test" { name = "role-0" } output "role_uuid" { value = data.juju_jaas_role.test.uuid }
-
window.location.href = '../test-include/index.html' + (window.location.search || '') + (window.location.hash || ''); You should have been redirected. If not, click here to continue.
-
We introduced two new init profiles, test-machine and test-kubernetes. They provide a framework for using the charmcraft test command. These profiles are experimental, so we can’t guarantee their stab...
-
See also: Write an integration test Integration testing juju currently relies on a series of custom-made bash scripts. All these scripts live in the tests directory. This directory includes two subdir...
-
We recommend using pytest for writing tests. You can define a pytest fixture to create a temporary Juju model for each test. The jubilant.temp_model context manager creates a randomly-named model on e...
-
An accessor for the mounts in a container. Dict keys match key name in StorageMeta Example: storage: foo: type: filesystem location: /test containers: bar: mounts: - storage: foo - location: /test/mou...
-
juju remove-saas hosted-mysql juju remove-saas -m test-model hosted-mariadb
-
See also: Write a unit test Unit testing juju currently involves the gocheck package and the go test CLI command. A typical unit testing package is placed alongside the code package that you want to t...
-
To set annotations for a model, in your Terraform, in the model’s resource definition, specify an annotations block, listing all the key=value pairs you want to set. For example: resource "juju_model"...
-
To add a public ssh key to a model, in your Terraform plan create a resource of the juju_ssh_key type, specifying the name of the model and the payload (here, the SSH key itself). For example: resourc...
-
Who: JIMM controller admin See also: Group Note This guide assumes you have the jaas plugin installed. See here for more information. Preview an example workflow # Create a group: juju add-group A # V...
-
Model log files (e.g., /var/log/juju/models/admin-test-3850c8.log) contain the logs for all the workers on a model.
-
Jubilant communicates with Juju by running processes in the test environment (the Juju CLI). See also: Juju CLI
-
In your Multipass Ubuntu VM shell, run your test: ubuntu@charm-dev:~/fastapi-demo$ tox -e unit The result should be similar to the following output: unit: install_deps> python -I -m pip install cosl '...
-
heap profile: 31: 694464 [33638: 106713992] @ heap/1048576 1: 196608 [1: 196608] @ 0x2d3fa53 0x2d3f9f6 0x2d40545 0x2d4030f 0x2d05ddb 0x2d0479f 0x2d05bf1 0x2d26c32 0x8a3cef 0x2d0381d 0x2d04146 0x2d008b...
-
window.location.href = '../../howto/write-a-unit-test/index.html' + (window.location.search || '') + (window.location.hash || ''); You should have been redirected. If not, click here to continue.
-
The go test command is used to run the tests. Juju uses the gocheck package (”gopkg.in/check.v1”) to provide a checkers and assert methods for the test writers. The use of gocheck replaces the standar...
-
Packing and deploying the charm Charm actions Charm relations Charm configuration That the workload is up and running, and responsive Upgrade sequence Regression test: upgrade stable/candidate/beta/ed...
-
See first: How to write integration tests for a charm Juju is in sole control over which unit is the leader, so leadership changes are not usually tested with integration tests. If this is required, t...
-
Now that our charm integrates with the PostgreSQL database, if there’s not a database relation, the app will be in blocked status instead of active. Let’s tweak our existing integration test test_buil...
-
On your machine, install Multipass and use it to set up an Ubuntu virtual machine (VM) called my-juju-vm. This will provide all the necessary tools and configuration for the tutorial (a localhost mach...
-
Bases: Generic[CharmType] This class represents a way to build up the model that will drive a test suite. The model created is from the viewpoint of the charm that is being tested. Always call harness...
-
The tests/integration/test_charm.py file is the companion to src/charm.py for integration testing. When a charm is initialized with the Kubernetes or machine profile, Charmcraft creates this file with...
-
Let’s add a test to check the behaviour of the get_db_info action that we just set up. Our test sets up the context, defines the input state with a relation, then runs the action and checks whether th...
-
The problem with the code as written is that the ExampleBlog daemon will restart every time the config-changed hook fires. That’s definitely unwanted downtime! We might be tempted to solve the issue w...
-
Open a shell in your Multipass Ubuntu VM, navigate inside your project directory, and run all of the following. First, repack and refresh your charm: charmcraft pack juju refresh \ --path="./demo-api-...
-
Install ops with the testing extra to use this API; for example: pip install ops[testing] State-transition tests, previously known as ‘Scenario’, expect you to define the Juju state all at once, defin...
-
Client for the Pebble API. This module provides a way to interact with Pebble, including: Client; communicates directly with the Pebble API. Layer class to define Pebble configuration layers, includin...
-
If DatabaseRequirer is a relation endpoint wrapper, a frequent pattern is to allow customising the name of the endpoint that the object is wrapping. Examples: Traefik’s ingress-per-unit lib In your te...
-
Since we added a new feature to configure server-port and use it in the Pebble layer dynamically, we should write tests for the feature. First, we’ll add a test that sets the port in the input state a...
-
Important Tempted to skip this step? We strongly recommend that you do not! As you will see in a minute, the VM you set up in this step does not just provide you with an isolated test environment but ...
-
To verify that the configuration option works as intended, pack your charm, update it in the Juju model, and run juju config followed by the name of the application deployed by your charm and then you...
-
When you’re trying things out it’s nice to work in an isolated test environment. Let’s spin up an Ubuntu virtual machine (VM) with Multipass! First, install Multipass. Now, launch an Ubuntu VM and ope...
-
ops[testing] (formerly Scenario) replaces the OpenTelemetry tracer provider with a mocked version that keeps the emitted spans in memory. This data is not presently exposed to the tests. See ops_traci...