Run Tempest in a Pod

Sometimes, you may want to avoid running the whole operator, e.g. for debugging or development purposes. In that case, you can run Tempest in a pod.

Write Object Definitions

Create a file named tempest-config.yaml with the following content:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-tempest-data
data:
  include.txt: |
    tempest.api.identity.v3
  # exclude.txt: |
  #  tempest.api.identity.v3
  # worker_file.yaml: |
  #   - worker:
  #     - tempest.api.*
  #     - neutron_tempest_tests
  #   - worker:
  #    - tempest.scenario.*

  # TEMPEST env variables:
  # ----------------------
  # NOTE: All parameters have default values (use only when you want to override
  #       the default behaviour)
  TEMPEST_INCLUDE_LIST: "/var/lib/tempest/include.txt"
  # TEMPEST_EXCLUDE_LIST: "/var/lib/tempest/exclude.txt"
  # TEMPEST_WORKER_FILE: "/var/lib/tempest/worker_file.yaml"
  # TEMPEST_CONCURRENCY: 8
  # TEMPEST_SMOKE: true
  # TEMPEST_PARALLEL: true
  # TEMPEST_SERIAL: true
  # TEMPEST_EXTERNAL_PLUGIN_GIT_URL: "https://opendev.org/openstack/barbican-tempest-plugin.git,https://opendev.org/openstack/neutron-tempest-plugin.git"
  # TEMPEST_EXTERNAL_PLUGIN_CHANGE_URL: "-,https://review.opendev.org/openstack/neutron-tempest-plugin"
  # TEMPEST_EXTERNAL_PLUGIN_REFSPEC: "-,refs/changes/97/896397/2"

  # TEMPESTCONF env variables:
  # --------------------------
  # NOTE: All parameters have default values (use only when you want to override
  #       the default behaviour)
  # TEMPESTCONF_CREATE: "true"
  # TEMPESTCONF_INSECURE: "false"
  # TEMPESTCONF_COLLECT_TIMING: "false"
  # TEMPESTCONF_NO_DEFAULT_DEPLOYER: "false"
  # TEMPESTCONF_DEBUG: "false"
  # TEMPESTCONF_VERBOSE: "false"
  # TEMPESTCONF_NO_RNG: "false"
  # TEMPESTCONF_NON_ADMIN: "false"
  # TEMPESTCONF_RETRY_IMAGE: "false"
  # TEMPESTCONF_CONVERT_TO_RAW: "false"
  # TEMPESTCONF_TIMEOUT: "600"
  # TEMPESTCONF_OUT: "./etc/tempest.conf"
  # TEMPESTCONF_DEPLOYER_INPUT: "/etc/test_operator/deployer_input.yaml"
  # TEMPESTCONF_TEST_ACCOUNTS: "/etc/test_operator/accounts.yaml"
  # TEMPESTCONF_CREATE_ACCOUNTS_FILE: "/etc/test_operator/accounts.yaml"
  # TEMPESTCONF_PROFILE: "/etc/test_operator/profile.yaml"
  # TEMPESTCONF_GENERATE_PROFILE: "/etc/test_operator/profile.yaml"
  # TEMPESTCONF_IMAGE_DISK_FORMAT: "qcow2"
  # TEMPESTCONF_IMAGE: "https://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img"
  # TEMPESTCONF_FLAVOR_MIN_MEM: "128"
  # TEMPESTCONF_FLAVOR_MIN_DISK: "1"
  # TEMPESTCONF_NETWORK_ID: ""
  # TEMPESTCONF_APPEND: |
  #   section.value1 value1
  #   section.value1 value2
  # TEMPESTCONF_REMOVE: |
  #   section.value1 value1
  #   section.value1 value2
  # TEMPESTCONF_OVERRIDES: |
  #  section.value1 value1
  #  section.value1 value2

The file contains tempest configuration and will be used to pass any tempest options to the container running Tempest.

Then create a file named tempest-deployment.yaml with the following content:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: tempest-home
spec:
  storageClassName: local-storage
  resources:
    requests:
        storage: 10G
  accessModes:
    - ReadWriteMany
    - ReadWriteOnce
---
apiVersion: v1
kind: Pod
metadata:
  name: tempest-worker
spec:
  securityContext:
     fsGroup: 42480
  volumes:
    - name: tempest-workdir
      persistentVolumeClaim:
        claimName: tempest-home
    - name: cloud-passwd
      secret:
         secretName: openstack-config-secret
    - name: clouds-config
      configMap:
          name: openstack-config
    - name: tempest-config
      configMap:
          name: my-tempest-data
    - name: certificate
      secret:
          secretName: combined-ca-bundle
    - name: pre-install
      emptyDir: {}
  containers:
    - name: tempest-container
      image: quay.io/podified-antelope-centos9/openstack-tempest:current-podified
      # Uncomment the following line to make the container sleep - that overrides
      # any run commands defined in the tempest image - that will allow you to
      # ssh to the container, install e.g. tempest plugins, change the tempest
      # configuration and run tempest yourself.
      # command: ["/usr/bin/dumb-init", "sleep", "infinity"]
      restartPolicy: Never
      envFrom:
        - configMapRef:
            name: my-tempest-data
      volumeMounts:
        - mountPath: "/var/lib/tempest/external_files/"
          name: tempest-workdir
        - mountPath: "/var/lib/tempest/include.txt"
          name: tempest-config
          subPath: include.txt
        - mountPath: "/etc/openstack"
          name: pre-install
        - mountPath: "/etc/openstack/clouds.yaml"
          name: clouds-config
          subPath: clouds.yaml
        - mountPath: "/etc/openstack/secure.yaml"
          name: cloud-passwd
          subPath: secure.yaml
        - mountPath: "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
          name: certificate
          subPath: tls-ca-bundle.pem
      env:
        - name: OS_CLOUD
          valueFrom:
            configMapKeyRef:
              name: openstack-config
              key: OS_CLOUD

The file contains a pod definition - it tells OpenShift to create a pod running one container that will run Tempest from the openstack-tempest image. More about images can be found here.

Create Resources

Run the oc apply command to create the resources:

oc apply -f tempest-config.yaml
oc apply -f tempest-deployment.yaml

You can verify that the resources were created with:

oc get configmap my-tempest-data
oc get pods tempest-worker

Add -o yaml to the above commands to see the details of the resources.

Debug Tempest Container

Use oc describe command to see the full definition of the pod including latest events, such as pulling of the tempest image, creating and starting a container.

oc describe pod tempest-worker

To see the console output from the tempest run execute:

oc logs tempest-worker

SSH to the Tempest Container

In case you want to SSH the container to run Tempest manually, you may want to run the pod as a sleepy pod. Uncomment the command option in the tempest-deployment.yaml file shared above to create such pod.

Then SSH to the container:

oc rsh --container tempest-container tempest-worker

Note

If a pod runs only one container you can omit --container argument.

Once inside the container, change directory to /var/lib/tempest to find tempest configuration together with the run_tempest.sh script.

While inside the container, you can run Tempest commands according to the Tempest documentation.

The container has also installed python-tempestconf project (discover-tempest-config command). If you run the pod as a sleepy one, run_tempest.sh defined in the image wasn’t executed. In that case, you have to generate tempest.conf manually - either run run_tempest.sh or discover-tempest-config command according to its documentation.

Custom Tempest Configuration

In order to pass custom configuration to tempest and python-tempestconf, you can either SSH to the running tempest container where you can interact with tempest and discover-tempest-config commands directly according to their documentations, see SSH to the Tempest Container, or follow the steps described below.

python-tempestconf configuration

The only, currently, supported way for passing custom arguments to discover-tempest-config command is via a file called profile.yaml. See the python-tempestconf’s official documentation for more details about the file.

Add the content of the profile.yaml file to the tempest-config.yaml file under data section like this:

data:
  <any existing configuration>
  profile.yaml: |
    <file content>

And then add the following to the tempest-deployment.yaml under volumeMounts section of the tempest-container:

- mountPath: "/var/lib/tempest/external_files/profile.yaml"
  name: tempest-config
  subPath: profile.yaml

Tempest configuration

Change the tempest-config.yaml file accordingly to pass any custom configuration to Tempest. Please mind the content of the run_tempest.sh script defined inside the tempest image as that is the limitation of what can be recognized, parsed and taken into account during the tempest run.

The content of the run_tempest.sh can be found here.