Table of Contents

Manual testing with oardocker

Set user:

APIUSER=docker:docker

or to get access to privileged commands

APIUSER=oar:oar

Then set the URL API:

OARAPI=http://$APIUSER@localhost:46668/oarapi-priv
OARAPI=http://$APIUSER@localhost:6668/oarapi-priv

Example of GET request:

curl -i -X GET $OARAPI/jobs/1/details.json

or

curl -i -X GET $OARAPI/jobs/1/details -H'Content-Type: application/json'

Example of POST request:

curl -i -X POST $OARAPI/jobs/1.json -d '{"method":"delete"}'

or

curl -i -X POST $OARAPI/jobs/1 -H'Content-Type: application/json' -d '{"method":"delete"}'

Rspec tests in oardocker

Supposing you installed oar-docker, launching the API tests is as simple as:

cd ~/src/oar
oardocker init -e jessie
oardocker build install . start -v $PWD:/home/docker/oar
oardocker connect frontend
cd oar/tests/rspec
# workaround for bad apache init
systemctl restart oardocker-apache.service
make APIURI=http://docker:docker@localhost:6668/oarapi-priv/

WARNING: for the Rspec tests to success, OAR must have at least 4 * 2 cores.

Rspec tests in oar-vagrant

Follow the instructions from the oar-vagrant page. Set up a 2 nodes cluster with:

OARVAGRANT_NODES_COUNT=2 vagrant up

Connection

To get root access on the VMs, you'll have to connect with the vagrant user:

vagrant ssh frontend -- -l vagrant
vagrant@frontend: /home/vagrant $ sudo su -
root@frontend: /root # 

Debian dependencies

If you run a Debian appliance:

root@frontend:~# apt-get install ruby-rspec ruby-rest-client
root@frontend:~# apt-get install libdbd-pg-ruby oar-admin

Centos dependencies

If you run a Centos appliance:

* Install RPM dependencies

yum install rubygems

* Install a recent ruby version, using RVM

curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements
rvm install 1.9.3
rvm use 1.9.3 --default

* Install required gems

gem install rspec rest_client json

Running the tests

# From your local host, inside the vagrant directory, supposing you have OAR sources into ~/git/oar:
[bzizou@bart|oar-vagrant]$ cp -a ~/git/oar/tests/rspec .
# Copy/paste this in a root session on the frontend
oarnodesetting -s Dead -h node-2
ssh server oarremoveresource 2
oarnodesetting -a -h node-1 -p cpu=0 -p core=1 -p cpuset=0
oarnodesetting -a -h node-1 -p cpu=1 -p core=2 -p cpuset=0
oarnodesetting -a -h node-1 -p cpu=1 -p core=3 -p cpuset=0
oarnodesetting -a -h node-2 -p cpu=2 -p core=4 -p cpuset=0
oarnodesetting -a -h node-2 -p cpu=2 -p core=5 -p cpuset=0
oarnodesetting -a -h node-2 -p cpu=3 -p core=6 -p cpuset=0
oarnodesetting -a -h node-2 -p cpu=3 -p core=7 -p cpuset=0
[user1@frontend|rspec]$ source /etc/profile.d/rvm.sh
[user1@frontend|rspec]$ cd /vagrant/rspec
[user1@frontend|rspec]$ make APIURI=http://localhost:6668/oarapi/

Warning! Don't forget the trailing slash at “/localhost/oarapi/”!

[user1@frontend|rspec]$ su -
root@frontend:~# su - oar
[oar@frontend|rspec]$ cd /vagrant/rspec
[oar@frontend|rspec]$ make resources_creation APIURI=http://localhost/oarapi/

Warning! Don't forget the trailing slash at “/localhost/oarapi/”!