You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ``job_scheduler_preamble`` contains the backend job scheduler directives that control the job allocation.
398
-
The ``test_environment`` are the necessary commands for setting up the environment of the test.
399
+
The ``prepare_cmds`` are commands that can be emitted before the test environment commands.
400
+
These can be specified with the :js:attr:`prepare_cmds <.systems[].partitions[].prepare_cmds>` partition configuration option.
401
+
The ``env_load_cmds`` are the necessary commands for setting up the environment of the test.
399
402
These include any modules or environment variables set at the `system partition level <config_reference.html#system-partition-configuration>`__ or any `modules <regression_test_api.html#reframe.core.pipeline.RegressionTest.modules>`__ or `environment variables <regression_test_api.html#reframe.core.pipeline.RegressionTest.variables>`__ set at the test level.
400
403
Then the commands specified in :attr:`prerun_cmds <reframe.core.pipeline.RegressionTest.prerun_cmds>` follow, while those specified in the :attr:`postrun_cmds <reframe.core.pipeline.RegressionTest.postrun_cmds>` come after the launch of the parallel job.
401
404
The parallel launch itself consists of three parts:
@@ -671,13 +674,14 @@ ReFrame can be used also to test applications that run inside a container.
671
674
First, we need to enable the container platform support in ReFrame's configuration and, specifically, at the partition configuration level:
For each partition, users can define a list of container platforms supported using the :js:attr:`container_platforms` `configuration parameter <config_reference.html#.systems[].partitions[].container_platforms>`__.
678
-
In this case, we define the `Singularity <https://sylabs.io>`__ platform, for which we set the :js:attr:`modules` parameter in order to instruct ReFrame to load the ``singularity`` module, whenever it needs to run with this container platform.
681
+
In this case, we define the `Sarus <https://github.com/eth-cscs/sarus>`__ platform for which we set the :js:attr:`modules` parameter in order to instruct ReFrame to load the ``sarus`` module, whenever it needs to run with this container platform.
682
+
Similarly, we add an entry for the `Singularity <https://sylabs.io>`__ platform.
679
683
680
-
The following test will use a Singularity container to run:
684
+
The following parameterized test, will create two tests, one for each of the supported container platforms:
681
685
682
686
.. code-block:: console
683
687
@@ -690,29 +694,66 @@ The following test will use a Singularity container to run:
690
694
691
695
A container-based test can be written as :class:`RunOnlyRegressionTest <reframe.core.pipeline.RunOnlyRegressionTest>` that sets the :attr:`container_platform <reframe.core.pipeline.RegressionTest.container_platform>` attribute.
692
696
This attribute accepts a string that corresponds to the name of the container platform that will be used to run the container for this test.
693
-
In this case, the test will be using `Singularity <https://sylabs.io>`__ as a container platform.
694
697
If such a platform is not `configured <config_reference.html#container-platform-configuration>`__ for the current system, the test will fail.
695
698
696
-
As soon as the container platform to be used is defined, you need to specify the container image to use and the commands to run inside the container by setting the :attr:`image <reframe.core.containers.ContainerPlatform.image>` and the :attr:`commands <reframe.core.containers.ContainerPlatform.commands>` container platform attributes.
697
-
These two attributes are mandatory for container-based checks.
699
+
As soon as the container platform to be used is defined, you need to specify the container image to use by setting the :attr:`image <reframe.core.containers.ContainerPlatform.image>`.
700
+
In the ``Singularity`` test variant, we add the ``docker://`` prefix to the image name, in order to instruct ``Singularity`` to pull the image from `DockerHub <https://hub.docker.com/>`__.
701
+
The default command that the container runs can be overwritten by setting the :attr:`command <reframe.core.containers.ContainerPlatform.command>` attribute of the container platform.
702
+
703
+
The :attr:`image <reframe.core.containers.ContainerPlatform.image>` is the only mandatory attribute for container-based checks.
698
704
It is important to note that the :attr:`executable <reframe.core.pipeline.RegressionTest.executable>` and :attr:`executable_opts <reframe.core.pipeline.RegressionTest.executable_opts>` attributes of the actual test are ignored in case of container-based tests.
699
705
700
-
ReFrame will run the container as follows:
706
+
ReFrame will run the container according to the given platform as follows:
707
+
708
+
.. code-block:: bash
709
+
710
+
# Sarus
711
+
sarus run --mount=type=bind,source="/path/to/test/stagedir",destination="/rfm_workdir" ubuntu:18.04 bash -c 'cat /etc/os-release | tee /rfm_workdir/release.txt'
In the ``Sarus`` case, ReFrame will prepend the following command in order to pull the container image before running the container:
705
718
706
-
By default ReFrame will mount the stage directory of the test under ``/rfm_workdir`` inside the container and it will always prepend a ``cd`` command to that directory.
707
-
The user commands are then run from that directory one after the other.
719
+
.. code-block:: bash
720
+
721
+
sarus pull ubuntu:18.04
722
+
723
+
724
+
This is the default behavior of ReFrame, which can be changed if pulling the image is not desired by setting the :attr:`pull_image <reframe.core.containers.ContainerPlatform.pull_image>` attribute to :class:`False`.
725
+
By default ReFrame will mount the stage directory of the test under ``/rfm_workdir`` inside the container.
708
726
Once the commands are executed, the container is stopped and ReFrame goes on with the sanity and performance checks.
709
-
Users may also change the default mount point of the stage directory by using :attr:`workdir <reframe.core.pipeline.RegressionTest.container_platform.workdir>` attribute:
710
727
Besides the stage directory, additional mount points can be specified through the :attr:`mount_points <reframe.core.pipeline.RegressionTest.container_platform.mount_points>` attribute:
The container filesystem is ephemeral, therefore, ReFrame mounts the stage directory under ``/rfm_workdir`` inside the container where the user can copy artifacts as needed.
736
+
These artifacts will therefore be available inside the stage directory after the container execution finishes.
737
+
This is very useful if the artifacts are needed for the sanity or performance checks.
738
+
If the copy is not performed by the default container command, the user can override this command by settings the :attr:`command <reframe.core.containers.ContainerPlatform.command>` attribute such as to include the appropriate copy commands.
739
+
In the current test, the output of the ``cat /etc/os-release`` is available both in the standard output as well as in the ``release.txt`` file, since we have used the command:
740
+
741
+
.. code-block:: bash
742
+
743
+
bash -c 'cat /etc/os-release | tee /rfm_workdir/release.txt'
744
+
745
+
746
+
and ``/rfm_workdir`` corresponds to the stage directory on the host system.
747
+
Therefore, the ``release.txt`` file can now be used in the subsequent sanity checks:
For a complete list of the available attributes of a specific container platform, please have a look at the :ref:`container-platforms` section of the :doc:`regression_test_api` guide.
718
759
On how to configure ReFrame for running containerized tests, please have a look at the :ref:`container-platform-configuration` section of the :doc:`config_reference`.
0 commit comments