Skip to content

Commit

Permalink
Merge pull request #25 from fangohr/feat-023
Browse files Browse the repository at this point in the history
Feat 023
  • Loading branch information
mvousden committed Mar 8, 2016
2 parents b38dbbc + dc03353 commit ea28f3a
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 18 deletions.
14 changes: 3 additions & 11 deletions guest_resources/nmag_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions roles/fidimag/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- include: install_dependencies_from_packages.yml
- include: make_fidimag.yml
- include: set_paths.yml
- include: test.yml
49 changes: 49 additions & 0 deletions roles/fidimag/tasks/test.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 13 additions & 1 deletion roles/fidimag/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
---
FIDIMAG_REPO_URL: https://github.com/computationalmodelling/fidimag.git
FIDIMAG_INSTALL_PATH: /opt/fidimag
FIDIMAG_VERSION: HEAD
FIDIMAG_VERSION: HEAD

XPRA_DISPLAYS:
- 25
- 30
- 36
- 49
- 50
- 64
- 75
- 81
- 90
- 99
20 changes: 18 additions & 2 deletions roles/nmag/tasks/compile_nmag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
9 changes: 5 additions & 4 deletions roles/nmag/tasks/install_required_debian_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions roles/nmag/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions roles/nmag/tasks/test.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ea28f3a

Please sign in to comment.