Skip to content

test_molecule

Michal Opala edited this page Feb 11, 2025 · 7 revisions

Molecule testing

Requirements (Client)

Install hatch into your OS.

Install one-deploy requirements using the included Makefile:

make requirements

Use hatch to (re)create the "default" venv:

hatch env prune
hatch env create

Enter the "default" venv:

hatch shell

Check ansible version:

ansible-playbook --version | head -n1
ansible-playbook [core 2.16.14]

Warning

For the ceph-hci scenario you should use the "ceph" hatch venv.

Continue in the venv! πŸ€—

Requirements (Server)

To deploy Molecule integration environments (ceph-hci, passenger-ha, ...) you will need a working OpenNebula instance with pre-configured networking and pre-installed OS images and VM templates.

Note

You can download OS images and VM templates from OpenNebula's Public Marketplace.

Download (and rename) VM templates and OS images into your OpenNebula instance:

  • Ubuntu 24.04 -> ubuntu2404
  • Ubuntu 22.04 -> ubuntu2204
  • AlmaLinux 9 -> alma9
  • AlmaLinux 8 -> alma8

Configuration

Create the .env.yml file in your one-deploy's root directory, with the following content (you can use .env.yml.sample as a template):

ONE_HOST: http://localhost:2633/RPC2
ONE_USER: oneadmin
ONE_PSWD: opennebula
ONE_TOKEN: example:example
ONE_VNET: service
ONE_SUBNET: 172.20.0.0/16
ONE_RANGE1: 172.20.86.100 4
ONE_RANGE2: 172.20.86.104 4
ONE_RANGE3: 172.20.86.108 4
  • Provide OpenNebula endpoint and credentials.
  • Provide your support token (optional).
  • Customize VNET name, subnet and IP ranges.

Converging Environments

To list all available environments/tests:

molecule list
~/one-deploy $ molecule list
INFO     Running ceph-hci > list
INFO     Running federation > list
INFO     Running federation-ha > list
INFO     Running prometheus-ha > list
INFO     Running ssl-ha > list
                   β•·             β•·                  β•·               β•·         β•·
  Instance Name    β”‚ Driver Name β”‚ Provisioner Name β”‚ Scenario Name β”‚ Created β”‚ Converged
╢──────────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  ceph-hci-f1      β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ false   β”‚ false
  ceph-hci-n1      β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ false   β”‚ false
  ceph-hci-n2      β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ false   β”‚ false
  federation-f1    β”‚ default     β”‚ ansible          β”‚ federation    β”‚ false   β”‚ false
  federation-f2    β”‚ default     β”‚ ansible          β”‚ federation    β”‚ false   β”‚ false
  federation-f3    β”‚ default     β”‚ ansible          β”‚ federation    β”‚ false   β”‚ false
  federation-ha-f1 β”‚ default     β”‚ ansible          β”‚ federation-ha β”‚ false   β”‚ false
  federation-ha-f2 β”‚ default     β”‚ ansible          β”‚ federation-ha β”‚ false   β”‚ false
  federation-ha-f3 β”‚ default     β”‚ ansible          β”‚ federation-ha β”‚ false   β”‚ false
  federation-ha-f4 β”‚ default     β”‚ ansible          β”‚ federation-ha β”‚ false   β”‚ false
  prometheus-ha-f1 β”‚ default     β”‚ ansible          β”‚ prometheus-ha β”‚ false   β”‚ false
  prometheus-ha-f2 β”‚ default     β”‚ ansible          β”‚ prometheus-ha β”‚ false   β”‚ false
  prometheus-ha-f3 β”‚ default     β”‚ ansible          β”‚ prometheus-ha β”‚ false   β”‚ false
  prometheus-ha-f4 β”‚ default     β”‚ ansible          β”‚ prometheus-ha β”‚ false   β”‚ false
  ssl-ha-f1        β”‚ default     β”‚ ansible          β”‚ ssl-ha        β”‚ false   β”‚ false
  ssl-ha-f2        β”‚ default     β”‚ ansible          β”‚ ssl-ha        β”‚ false   β”‚ false
  ssl-ha-f3        β”‚ default     β”‚ ansible          β”‚ ssl-ha        β”‚ false   β”‚ false
  ssl-ha-f4        β”‚ default     β”‚ ansible          β”‚ ssl-ha        β”‚ false   β”‚ false

To deploy the ceph-hci environment:

~/one-deploy $ molecule converge -s ceph-hci

If everything goes well, you should be able to log in and examine the environment:

~/one-deploy $ molecule list -s ceph-hci
INFO     Running ceph-hci > list
                β•·             β•·                  β•·               β•·         β•·
  Instance Name β”‚ Driver Name β”‚ Provisioner Name β”‚ Scenario Name β”‚ Created β”‚ Converged
╢───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  ceph-hci-f1   β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ true    β”‚ true
  ceph-hci-n1   β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ true    β”‚ true
  ceph-hci-n2   β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ true    β”‚ true
$ onevm ssh ceph-hci-f1

Destroying environments

To destroy a specific environment:

~/one-deploy $ molecule destroy -s ceph-hci
~/one-deploy $ molecule list -s ceph-hci
INFO     Running ceph-hci > list
                β•·             β•·                  β•·               β•·         β•·
  Instance Name β”‚ Driver Name β”‚ Provisioner Name β”‚ Scenario Name β”‚ Created β”‚ Converged
╢───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  ceph-hci-f1   β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ false   β”‚ false
  ceph-hci-n1   β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ false   β”‚ false
  ceph-hci-n2   β”‚ default     β”‚ ansible          β”‚ ceph-hci      β”‚ false   β”‚ false

To destroy all available environments:

~/one-deploy $ molecule destroy --all