Skip to content

Commit ea28f3a

Browse files
committed
Merge pull request #25 from fangohr/feat-023
Feat 023
2 parents b38dbbc + dc03353 commit ea28f3a

File tree

8 files changed

+119
-18
lines changed

8 files changed

+119
-18
lines changed

guest_resources/nmag_examples.rst

+3-11
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,11 @@ Example files can be found in::
1414

1515
~/nmag-examples/
1616

17-
A test suite is also available for the discerning user. To use the test suite,
18-
configuration must first be performed::
19-
20-
sudo su # We need to run this as root for permissions purposes.
21-
cd /opt/nmag/nmag-0.2.1/nsim/tests/config
22-
PATH=$PATH:/opt/nmag/nmag-0.2.1/nsim/bin
23-
bash find_nsim.sh
24-
exit
25-
26-
The tests are wrapped in a Makefile, and hence can only be run after the
27-
configuration by commanding::
17+
The tests are wrapped in a Makefile, and can be run as root by commanding::
2818

2919
sudo su
3020
cd /opt/nmag/nmag-0.2.1/nsim/tests
3121
make
3222
exit
23+
24+
Note that HLib is not installed, and so tests requiring HLib will fail.

roles/fidimag/tasks/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- include: install_dependencies_from_packages.yml
66
- include: make_fidimag.yml
77
- include: set_paths.yml
8+
- include: test.yml

roles/fidimag/tasks/test.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
# This Ansible playbook runs Fidimag tests. This works because pytest has a
3+
# non-zero exit status if a test fails, and Make returns a non-zero exit status
4+
# if a command returns a non-zero exit status.
5+
6+
# The following task construction exists because XPRA sometimes fails silently,
7+
# apparently stochastically. Hence we attempt to create a number of virtual
8+
# displays using xpra, and test each one. If one of them exists, we continue
9+
# with it. If they all fail, we exit. This is all done to ensure that the
10+
# finmag tests pass, since some of them require a display.
11+
12+
- name: Ensure that xpra is installed
13+
apt:
14+
pkg=xpra
15+
state=latest
16+
update_cache=yes
17+
cache_valid_time=86400
18+
sudo: yes
19+
20+
- name: Create multiple virtual displays and re-probe them.
21+
shell: xpra start :{{ item }} && xpra list
22+
with_items: XPRA_DISPLAYS
23+
ignore_errors: yes
24+
sudo: yes
25+
26+
- name: Obtain the display ID of one successful live display.
27+
shell: xpra list | grep -m 1 "LIVE.*" | grep -Go [0-9]*$
28+
register: successful_display
29+
sudo: yes
30+
31+
# Finally, run some tests.
32+
33+
- name: Run tests.
34+
command: make test
35+
args:
36+
chdir: "{{ FIDIMAG_INSTALL_PATH }}"
37+
environment:
38+
DISPLAY: ":{{ successful_display.stdout }}"
39+
PYTHONPATH: "{{ FIDIMAG_INSTALL_PATH }}"
40+
LD_LIBRARY_PATH: "{{ FIDIMAG_INSTALL_PATH }}/local/lib"
41+
sudo: yes
42+
43+
# Cleanup.
44+
45+
- name: Stop xpra sessions
46+
command: xpra stop :{{ item }}
47+
with_items: XPRA_DISPLAYS
48+
ignore_errors: yes
49+
sudo: yes

roles/fidimag/vars/main.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
---
22
FIDIMAG_REPO_URL: https://github.com/computationalmodelling/fidimag.git
33
FIDIMAG_INSTALL_PATH: /opt/fidimag
4-
FIDIMAG_VERSION: HEAD
4+
FIDIMAG_VERSION: HEAD
5+
6+
XPRA_DISPLAYS:
7+
- 25
8+
- 30
9+
- 36
10+
- 49
11+
- 50
12+
- 64
13+
- 75
14+
- 81
15+
- 90
16+
- 99

roles/nmag/tasks/compile_nmag.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,26 @@
2121
shell: make
2222
chdir={{ NMAG_INSTALL_PREFIX }}/{{ NMAG_EXTRACTED_DIR.stdout }}
2323
creates={{ NMAG_INSTALL_PREFIX }}/{{ NMAG_EXTRACTED_DIR.stdout }}/nsim/bin/nsim
24-
#environment:
25-
# NMAG_INSTALL_PREFIX: /usr/lib/{{ ARCH.stdout }}/tcl{{ TCLTKVERSION }}/tclConfig.sh
2624
sudo: yes
2725

2826
- name: Set executable permissions for everyone on files which are executable for user
2927
command: find {{ NMAG_INSTALL_PREFIX }}/{{ NMAG_EXTRACTED_DIR.stdout }} -perm /u+x -exec chmod go+x {} \;
3028
sudo: yes
29+
30+
# In order to use Nmag with MPI, a file must be present in all users' home
31+
# directories.
32+
33+
- name: Create mpd files for MPI execution.
34+
lineinfile:
35+
create: yes
36+
dest: "{{ item.dest }}"
37+
line: "MPD_SECRETWORD=generic-secr3t"
38+
mode: 0600
39+
regexp: "MPD_SECRETWORD=generic-secr3t"
40+
owner: "{{ item.owner }}"
41+
state: present
42+
sudo: yes
43+
with_items:
44+
- { dest: /etc/mpd.conf, owner: root }
45+
- { dest: /home/vagrant/.mpd.conf, owner: vagrant }
46+
- { dest: /etc/skel/.mpd.conf, owner: root }

roles/nmag/tasks/install_required_debian_packages.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
with_items:
88
- dpkg-dev
99
- g++
10+
- gawk
1011
- libblas-dev
12+
- liblapack-dev
1113
- libreadline-dev
12-
- make
1314
- m4
14-
- gawk
15-
- zlib1g-dev
15+
- make
16+
- mpich
1617
- readline-common
17-
- liblapack-dev
18+
- zlib1g-dev
1819
sudo: yes

roles/nmag/tasks/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
---
2+
# This Ansible role installs Nmag on the virtual machine.
3+
14
- include: install_required_debian_packages.yml
25
- include: download_and_extract_nmag_tarball.yml
36
- include: compile_nmag.yml
47
- include: add_nmag_to_PATH.yml dest=/etc/profile.d/nmag.sh
8+
- include: test.yml

roles/nmag/tasks/test.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# This Ansible playbook runs Nmag tests.
3+
4+
- name: Configure Nmag to run tests.
5+
command: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/bin/nsim {{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests/config/setup.py"
6+
args:
7+
chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests/config"
8+
sudo: yes
9+
10+
- name: Run fast tests.
11+
command: make check
12+
args:
13+
chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests"
14+
sudo: yes
15+
16+
- name: Run slow tests.
17+
command: make checkslow
18+
args:
19+
chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests"
20+
sudo: yes
21+
22+
- name: Run MPI tests.
23+
command: make checkmpi
24+
args:
25+
chdir: "{{ NMAG_INSTALL_PREFIX }}/{{ NMAG_VERSION }}/nsim/tests"
26+
sudo: yes

0 commit comments

Comments
 (0)