OpenClinica User Manual/SettingUpATestEnvironment

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Setting up a test-environment[edit | edit source]

Every once in a while you need to test something for OpenClinica and you don't want to clutter your production database, so you decide you need a test-environment. Here is how to do that, plus instructions how to clean up after your testing.

It takes four steps to create your test-environment:

  1. create a new database
  2. make a copy of the web-app
  3. make a data directory
  4. edit datainfo.properties

Create a new database[edit | edit source]

In this example we'll name the test environment octest. Login to your server and go to the dir with psql and start it:

cd /usr/bin 
sudo -u postgres ./psql
CREATE DATABASE octest WITH ENCODING='UTF8' OWNER=clinica;

Check if the database was created correctly with "\list" (or just "\l" will do) and quit psql with "\q"

Make a copy of the web-app[edit | edit source]

Change to the tomcat webapps directory and copy the OpenClinica structure:

cd /usr/local/tomcat/webapps
sudo -u tomcat cp -r OpenClinica octest

Make a data directory[edit | edit source]

Change to directory /usr/local/tomcat and create a data directory and give tomcat all rights:

cd /usr/local/tomcat/
sudo mkdir octest.data 
sudo chown tomcat octest.data 
sudo chgrp tomcat octest.data

Edit datainfo.properties[edit | edit source]

The last thing to do is edit the file datainfo.properties. Go to the right directory and start your favourite editor:

cd /usr/local/tomcat/webapps/octest/WEB-INF/classes
sudo -u tomcat vi datainfo.properties

Change:
filePath=/usr/local/tomcat/openclinica.data/
into:
filePath=/usr/local/tomcat/octest.data/

url=jdbc:postgresql://localhost:5432/openclinica
into:
url=jdbc:postgresql://localhost:5432/octest

sysURL=http://localhost:8080/OpenClinica/MainMenu
into:
sysURL.base=http://localhost:8080/octest/MainMenu

You are now ready to deploy your octest-app and you do this by stopping and starting tomcat.

cd /etc/init.d
sudo ./tomcat stop
sudo ./tomcat start

Cleaning up[edit | edit source]

After testing you should clean up the database and the app and you do this by:

stopping tomcat:

cd /etc/init.d
sudo ./tomcatd stop

removing the app-directory:

sudo rm -r /usr/local/tomcat/webapps/octest

removing the data-directory:

sudo rm -r /usr/local/tomcat/octest.data

starting psql and removing the database:

cd /usr/bin
sudo -u postgres ./psql
drop database octest;
\q

starting tomcat:

cd /etc/init.d
sudo ./tomcatd start