Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Dockerized Database Integration Tests for Active Objects during Atlassian Plugin Development

License

Notifications You must be signed in to change notification settings

comsysto/poc-dockerized-database-integration-tests-atlassian-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proof of Concept: Dockerized Database Integration Tests

for Atlassian Server App

A simple Proof of Concept on how to run Database Integration Tests with real dockerized PostgreSQL or MySQL Databases during Atlassian JIRA Server App development. This PoC is based on UnitTests for Active Objects.

 

Prerequisites

  • Docker is installed and on PATH
  • Java 8 JDK is installed and on PATH
  • Atlassian Plugin SDK is installed and on PATH

 

Running the Tests

We can run the same test against different database engines.

 

Run tests against embedded HSQLDB
git clone https://github.com/comsysto/poc-dockerized-database-integration-tests-atlassian-plugin.git
cd poc-dockerized-database-integration-tests-atlassian-plugin

atlas-unit-test

 

Run tests against dockerized PostgreSQL

(1) Start dockerized PostgreSQL database

docker run --name postgres95 \
           -d --rm -p 5441:5432 \
           -e POSTGRES_PASSWORD=jira \
           -e POSTGRES_USER=jira \
           -e POSTGRES_DB=jira \
           postgres:9.5 \
           postgres -c 'log_statement=all'

(2) Run tests against it

atlas-unit-test -Dao.test.database=postgres \
                -Ddb.url=jdbc:postgresql://localhost:5441/jira  \
                -Ddb.schema=public \
                -Ddb.username=jira \
                -Ddb.password=jira

We can see the tables and indexes:

(3) See logged queries

docker logs postgres95

(4) Shutdown dockerized PostgreSQL database.

docker kill postgres95

 

Run tests against dockerized MySQL

(1) Start dockerized MySQL database

docker run --name mysql56 \
           -d --rm \
           -p 3316:3306 \
           -e MYSQL_RANDOM_ROOT_PASSWORD=true \
           -e MYSQL_USER=jira  \
           -e MYSQL_PASSWORD=jira  \
           -e MYSQL_DATABASE=jira  \
           mysql:5.6 \
             --innodb-lock-wait-timeout=800 \
             --transaction-isolation=READ-COMMITTED

(2) Run tests against it

atlas-unit-test -Dao.test.database=mysql \
                -Ddb.url=jdbc:mysql://localhost:3316/jira?autoReconnect=true  \
                -Ddb.username=jira \
                -Ddb.password=jira
  • Note that MySQL uses no so called "schema". So we skip the definition.

(3) Shutdown dockerized MySQL database.

docker kill mysql56

 

Run tests against Oracle 12c on AWS RDS

 

Run tests against Microsoft SQL Server 2012 on AWS RDS

 


 

Classes and Tests

 

Distinctions

  • Why not atlas-integration-test?
    • Because even though it is named 'integration-test' it starts a full JIRA instance and runs tests against it. We only want to instantiate Active Objects with a real database and not the whole JIRA context. That is why we use the atlas-unit-test command.
  • Why not use @ManyToOne Annotations?
    • You can do that if you want a Left Join
    • The PoC wants to show how to perform an Inner Join

 

License

MIT © Comsysto Reply GmbH