lundi 29 décembre 2014

Application testing: using multiple users in Oracle instead of mem H2. How to make it as fast as possible?


I decided to stop using H2 for obvious reasons (I have Oracle on production, compatibility mode is a fake). So, I wrote simple test framework which for each test in my application does the following:




  1. Generate random username (in example below it's test_user).




  2. Create new user and tablespace:



    create tablespace test_user_ts
    datafile 'test_user_tabspace.dat'
    size 10M reuse
    autoextend on next 500K;

    create temporary tablespace test_user_ts_tmp
    tempfile 'test_user.tabspace_temp.dat'
    size 10M reuse
    autoextend on next 500K;

    create user test_user
    identified by test_password
    default tablespace test_user_ts
    temporary tablespace test_user_ts_tmp;

    grant create session to test_user;

    grant all privileges to test_user;



  3. Populate database with test data.




  4. Run test.




  5. Clean up:



    drop user test_user cascade;
    drop tablespace test_user_ts_tmp;
    drop tablespace test_user_ts;



The problem is that stages 1-3 are slow. How can I make them as fast as possible? Is there maybe any way of copying existing db schema to another one?


Db version: Oracle 11g


I have full control over Oracle instance. It runs on a vagrant image on my dev machine.





Aucun commentaire:

Enregistrer un commentaire