diff --git a/guest_resources/nmag_examples.rst b/guest_resources/nmag_examples.rst index ee5f780..2565d8b 100644 --- a/guest_resources/nmag_examples.rst +++ b/guest_resources/nmag_examples.rst @@ -14,19 +14,11 @@ Example files can be found in:: ~/nmag-examples/ -A test suite is also available for the discerning user. To use the test suite, -configuration must first be performed:: - - sudo su # We need to run this as root for permissions purposes. - cd /opt/nmag/nmag-0.2.1/nsim/tests/config - PATH=$PATH:/opt/nmag/nmag-0.2.1/nsim/bin - bash find_nsim.sh - exit - -The tests are wrapped in a Makefile, and hence can only be run after the -configuration by commanding:: +The tests are wrapped in a Makefile, and can be run as root by commanding:: sudo su cd /opt/nmag/nmag-0.2.1/nsim/tests make exit + +Note that HLib is not installed, and so tests requiring HLib will fail. diff --git a/roles/fidimag/tasks/main.yml b/roles/fidimag/tasks/main.yml index bc20fbc..e7edc8f 100644 --- a/roles/fidimag/tasks/main.yml +++ b/roles/fidimag/tasks/main.yml @@ -5,3 +5,4 @@ - include: install_dependencies_from_packages.yml - include: make_fidimag.yml - include: set_paths.yml +- include: test.yml \ No newline at end of file diff --git a/roles/fidimag/tasks/test.yml b/roles/fidimag/tasks/test.yml new file mode 100644 index 0000000..3b09f82 --- /dev/null +++ b/roles/fidimag/tasks/test.yml @@ -0,0 +1,49 @@ +--- +# This Ansible playbook runs Fidimag tests. This works because pytest has a +# non-zero exit status if a test fails, and Make returns a non-zero exit status +# if a command returns a non-zero exit status. + +# The following task construction exists because XPRA sometimes fails silently, +# apparently stochastically. Hence we attempt to create a number of virtual +# displays using xpra, and test each one. If one of them exists, we continue +# with it. If they all fail, we exit. This is all done to ensure that the +# finmag tests pass, since some of them require a display. + +- name: Ensure that xpra is installed + apt: + pkg=xpra + state=latest + update_cache=yes + cache_valid_time=86400 + sudo: yes + +- name: Create multiple virtual displays and re-probe them. + shell: xpra start :{{ item }} && xpra list + with_items: XPRA_DISPLAYS + ignore_errors: yes + sudo: yes + +- name: Obtain the display ID of one successful live display. + shell: xpra list | grep -m 1 "LIVE.*" | grep -Go [0-9]*$ + register: successful_display + sudo: yes + +# Finally, run some tests. + +- name: Run tests. + command: make test + args: + chdir: "{{ FIDIMAG_INSTALL_PATH }}" + environment: + DISPLAY: ":{{ successful_display.stdout }}" + PYTHONPATH: "{{ FIDIMAG_INSTALL_PATH }}" + LD_LIBRARY_PATH: "{{ FIDIMAG_INSTALL_PATH }}/local/lib" + sudo: yes + +# Cleanup. + +- name: Stop xpra sessions + command: xpra stop :{{ item }} + with_items: XPRA_DISPLAYS + ignore_errors: yes + sudo: yes \ No newline at end of file diff --git a/roles/fidimag/vars/main.yml b/roles/fidimag/vars/main.yml index e7b50b3..ffe733f 100644 --- a/roles/fidimag/vars/main.yml +++ b/roles/fidimag/vars/main.yml @@ -1,4 +1,16 @@ --- FIDIMAG_REPO_URL: https://github.com/computationalmodelling/fidimag.git FIDIMAG_INSTALL_PATH: /opt/fidimag -FIDIMAG_VERSION: HEAD \ No newline at end of file +FIDIMAG_VERSION: HEAD + +XPRA_DISPLAYS: + - 25 + - 30 + - 36 + - 49 + - 50 + - 64 + - 75 + - 81 + - 90 + - 99 diff --git a/roles/nmag/tasks/compile_nmag.yml b/roles/nmag/tasks/compile_nmag.yml index ed0f49d..920e627 100644 --- a/roles/nmag/tasks/compile_nmag.yml +++ b/roles/nmag/tasks/compile_nmag.yml @@ -21,10 +21,26 @@ shell: make chdir={{ NMAG_INSTALL_PREFIX }}/{{ NMAG_EXTRACTED_DIR.stdout }} creates={{ NMAG_INSTALL_PREFIX }}/{{ NMAG_EXTRACTED_DIR.stdout }}/nsim/bin/nsim - #environment: - # NMAG_INSTALL_PREFIX: /usr/lib/{{ ARCH.stdout }}/tcl{{ TCLTKVERSION }}/tclConfig.sh sudo: yes - name: Set executable permissions for everyone on files which are executable for user command: find {{ NMAG_INSTALL_PREFIX }}/{{ NMAG_EXTRACTED_DIR.stdout }} -perm /u+x -exec chmod go+x {} \; sudo: yes + +# In order to use Nmag with MPI, a file must be present in all users' home +# directories. + +- name: Create mpd files for MPI execution. + lineinfile: + create: yes + dest: "{{ item.dest }}" + line: "MPD_SECRETWORD=generic-secr3t" + mode: 0600 + regexp: "MPD_SECRETWORD=generic-secr3t" + owner: "{{ item.owner }}" + state: present + sudo: yes + with_items: + - { dest: /etc/mpd.conf, owner: root } + - { dest: /home/vagrant/.mpd.conf, owner: vagrant } + - { dest: /etc/skel/.mpd.conf, owner: root } \ No newline at end of file diff --git a/roles/nmag/tasks/install_required_debian_packages.yml b/roles/nmag/tasks/install_required_debian_packages.yml index 524d47a..e771984 100644 --- a/roles/nmag/tasks/install_required_debian_packages.yml +++ b/roles/nmag/tasks/install_required_debian_packages.yml @@ -7,12 +7,13 @@ with_items: - dpkg-dev - g++ + - gawk - libblas-dev + - liblapack-dev - libreadline-dev - - make - m4 - - gawk - - zlib1g-dev + - make + - mpich - readline-common - - liblapack-dev + - zlib1g-dev sudo: yes \ No newline at end of file diff --git a/roles/nmag/tasks/main.yml b/roles/nmag/tasks/main.yml index 48fe1ab..9e6dc81 100644 --- a/roles/nmag/tasks/main.yml +++ b/roles/nmag/tasks/main.yml @@ -1,4 +1,8 @@ +--- +# This Ansible role installs Nmag on the virtual machine. + - include: install_required_debian_packages.yml - include: download_and_extract_nmag_tarball.yml - include: compile_nmag.yml - include: add_nmag_to_PATH.yml dest=/etc/profile.d/nmag.sh +- include: test.yml \ No newline at end of file diff --git a/roles/nmag/tasks/test.yml b/roles/nmag/tasks/test.yml new file mode 100644 index 0000000..f7fa687 --- /dev/null +++ b/roles/nmag/tasks/test.yml @@ -0,0 +1,26 @@ +--- +# This Ansible playbook runs Nmag tests. + +- name: Configure Nmag to run tests. + command: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/bin/nsim {{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests/config/setup.py" + args: + chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests/config" + sudo: yes + +- name: Run fast tests. + command: make check + args: + chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests" + sudo: yes + +- name: Run slow tests. + command: make checkslow + args: + chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests" + sudo: yes + +- name: Run MPI tests. + command: make checkmpi + args: + chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests" + sudo: yes \ No newline at end of file