Build, deploy and test a Redis based Java application using Oracle Cloud
This blog will demonstrate how to get started with a Redis based Java application
- Run it on Oracle Application Container cloud and CI/CD using Oracle Developer cloud
- Execute Integration tests using NoSQLUnit
- Our Redis instance will run in a Docker container on Oracle Container cloud
Application
Here is a summary of the what the application is about
- Exposes REST endpoints using Jersey
- Uses Redis as the data store
- Jedis is used as the Java client for Redis
- NoSQLUnit is the framework used for integration testing
NoSQLunit
NoSQLUnit is an open source testing framework for applications which use NoSQL databases. It works on the concept of (JUnit) Rules and a couple of annotations. These rules are meant for both database lifecycle (start/stop) as well as state (seeding/deleting test data) management. In the sample application, we use it for state management for Redis instance i.e.
- with the help of a json file, we define test data which will be seeded to Redis before our tests start and then
- use the annotation (@UsingDataSet) to specify the our modus operandi (in this case — its clean and insert)
Our test dataset in json format
NoSQLUnit in action
Setup
Redis on Oracle Container Cloud
- Use the existing service or create your own (make sure you expose the default Redis port to the host IP) — documentation here
- Start the deployment — documentation here
- Note down the host IP of the worker node on which the Redis container is running
Configure Oracle Developer Cloud
We’ll start with bootstrapping the application in Oracle Developer Cloud. Check this section for reference Project & code repository creation. Once this is done, we can now start configuring our Build which is in the form of a pipeline consisting of the build, deployment, integration test and tear down phases
Build & deploy phase
The code is built and deployed on Oracle Application Container cloud. Please note that we are skipping the unit test part in order to keep things concise
Build step
Post-build (deploy)
Deployment
At the end of this phase, our application will be deployed to Application Container Cloud — its time to configure the integration tests
Integration test phase
Our integration tests will run directly against the deployed application using the Redis instance (on Oracle Container Cloud which we had setup earlier). For this
- we define another build job and
- make sure that it’s triggered after the build + deployment phase completes
Integration build job
Define the dependency
Tear Down phase
Thanks to Oracle Developer Cloud integration with Oracle PaaS Service Manager (PSM), it’s easy to add a PSMcli build step that invokes Oracle PaaS Service Manager command line interface (CLI) command to stop our ACCS application once the pipeline has been executed. More details in the documentation
We covered the following
- Built a Java application on top of Redis
- Orchestrated its build, deployment and integration test using Oracle Developer Cloud and Oracle Application Container Cloud
- In the process, we also saw how its possible to treat our infrastructure as code and utilize our cloud services efficiently
Don’t forget to…
- check out the tutorials for Oracle Application Container Cloud — there is something for every runtime !
- other blogs on Application Container Cloud
The views expressed in this post are my own and do not necessarily reflect the views of Oracle.