OpenLiberty / sample-getting-started

Getting started sample
https://openliberty.io/start/
Other
13 stars 118 forks source link

Open Liberty logo

Open Liberty Getting Started sample

Overview

The sample application provides a simple example of how to get started with Open Liberty. It provides a REST API that retrieves the system properties in the JVM and a web based UI for viewing them. It also uses MicroProfile Config, MicroProfile Health and MicroProfile Metrics to demonstrate how to use these specifications in an application that maybe deployed to kubernetes.

Project structure

Build and Run the Sample locally

Clone the project

git clone https://github.com/OpenLiberty/sample-getting-started.git

then build and run it using Liberty dev mode:

mvnw liberty:dev

if you just want to build it run:

mvnw package

Build container image from Dockerfile and run locally

To build the container image from Dockerfile and run locally using docker:

docker build --platform=linux/amd64 -t openliberty-gettingstarted:<TAG> .
docker images --filter reference=openliberty-gettingstarted
sudo docker run --platform=linux/amd64 -t -i -p 127.0.0.1:9080:9080 openliberty-gettingstarted:<TAG> 

To build the container image from Dockerfile and run locally using podman:

podman build --platform=linux/amd64 -t openliberty-gettingstarted:<TAG> .
podman images --filter reference=openliberty-gettingstarted
sudo podman run --platform=linux/amd64 -t -i -p 127.0.0.1:9080:9080 openliberty-gettingstarted:<TAG> 

Access the application

Open a browser to http://localhost:9080

Run the Sample in a container

To run the sample using docker run:

docker run -p 9080:9080 icr.io/appcafe/open-liberty/samples/getting-started

To run the sample using podman run:

podman run -p 9080:9080 icr.io/appcafe/open-liberty/samples/getting-started

Access the application

Open a browser to http://localhost:9080

image

Run the functional tests

The test cases uses JUnit 5 and Maven Failsafe Plugin defined in pom.xml.

Note: Sample appplication must be running on http://localhost before running the test cases.
See HealthUtilIT.java to change the change the sample application target URL.

To run the test cases against a running sample application, use the following command

mvnw failsafe:integration-test

To view the test results, look at the console output or look under directory target/failsafe-reports