Skip to content

Commit

Permalink
[#19] Build Device Communication API in GH Actions workflow.
Browse files Browse the repository at this point in the history
Fix test error, apply minor corrections.
Also don't build docker-image by default and use
generic docker image name.

Signed-off-by: Carsten Lohmann <[email protected]>
  • Loading branch information
calohmn committed May 2, 2023
1 parent e0ddd99 commit c01bccb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ jobs:
- name: Build Azure IoT Protocol Gateway Example
working-directory: ./protocol-gateway/azure-mqtt-protocol-gateway
run: mvn install -B -e -DcreateJavadoc=true
- name: Build Device Communication API
working-directory: ./device-communication
run: mvn install -B -e -DcreateJavadoc=true
22 changes: 10 additions & 12 deletions device-communication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For more information please see resources/api/openApi file.

## Database

Application uses PostgresSQL database. All the database configurations can be found in application.yaml file.
Application uses PostgreSQL database. All the database configurations can be found in application.yaml file.

### Tables

Expand All @@ -43,11 +43,11 @@ Application uses PostgresSQL database. All the database configurations can be fo

### Migrations

When Applications starts tables will be created by the DatabaseSchemaCreator service.
When Application starts, tables will be created by the DatabaseSchemaCreator service.

### Running postgresSQL container local
### Running PostgreSQL container locally

For running the PostgresSQL Database local with docker run:
For running the PostgreSQL Database locally with docker, run:

``````
Expand All @@ -58,14 +58,14 @@ docker run -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=mysecretpasswo
After the container is running, log in to the container and with psql create the database. Then we have
to set the application settings.

Default postgresSQl values:
Default PostgreSQL values:

- userName = postgres
- password = mysecretpassword

## Build and Push API Docker Image

Mavens auto build and push functionality ca be enabled from application.yaml settings:
Mavens auto build and push functionality can be enabled from application.yaml settings:

````
Expand All @@ -74,19 +74,17 @@ quarkus:
builder: docker
build: true
push: true
image: "gcr.io/sotec-iot-core-dev/hono-device-communication"
image: "<registry>/<organization>/hono-device-communication"
````

By running maven package, install or deploy will automatically build the docker image and if push is enabled it will
push the image
to the given registry.
By running maven package, install or deploy, this will automatically build the docker image and if push is enabled it will
push the image to the given registry.

## OpenApi Contract-first

For creating the endpoints, Vertx takes the openApi definition file and maps every endpoint operation-ID with a specific
Handler
function.
Handler function.

## Handlers

Expand Down
1 change: 0 additions & 1 deletion device-communication/mvnw
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,3 @@ exec "$JAVACMD" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void start() {
})
.onFailure(error -> {
if (error != null) {
log.error("Can not create Router {}", error.getMessage());
log.error("Can not create Router: {}", error.getMessage());
} else {
log.error("Can not create Router");
}
Expand Down
4 changes: 2 additions & 2 deletions device-communication/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ vertx:
quarkus:
container-image:
builder: docker
build: true
build: false
push: false
image: "gcr.io/sotec-iot-core-dev/hono-device-communication"
image: "eclipse/hono-device-communication"
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ void startSucceeded() {
verify(serverConfigMock, times(1)).getBasePath();
verify(mockedCommandService, times(1)).addRoutes(routerBuilderMock);
verify(serverConfigMock, times(1)).getOpenApiFilePath();
verify(routerMock, times(1)).errorHandler(eq(400), any());
verify(routerMock, times(1)).errorHandler(eq(404), any());
verify(routerMock, times(2)).get(anyString());
verify(routeMock, times(2)).handler(any());
verify(routerMock, times(1)).route(anyString());
Expand Down Expand Up @@ -247,7 +245,7 @@ void createServerFailed() {
when(routeMock.handler(any())).thenReturn(routeMock);
when(vertxMock.createHttpServer(any(HttpServerOptions.class))).thenReturn(httpServerMock);
when(httpServerMock.requestHandler(routerMock)).thenReturn(httpServerMock);
when(httpServerMock.listen()).thenReturn(Future.failedFuture(new Throwable()));
when(httpServerMock.listen()).thenReturn(Future.failedFuture(new Throwable("Test error on listen()")));
when(serverConfigMock.getOpenApiFilePath()).thenReturn("/myPath");
when(serverConfigMock.getBasePath()).thenReturn("/basePath");
when(routerMock.route(any())).thenReturn(routeMock);
Expand All @@ -274,8 +272,6 @@ void createServerFailed() {
verify(serverConfigMock, times(1)).getLivenessPath();
verify(serverConfigMock, times(1)).getReadinessPath();
verify(serverConfigMock, times(1)).getBasePath();
verify(routerMock, times(1)).errorHandler(eq(400), any());
verify(routerMock, times(1)).errorHandler(eq(404), any());
verify(routerMock, times(2)).get(anyString());
verify(routeMock, times(2)).handler(any());
verify(routeMock, times(1)).subRouter(any());
Expand Down

0 comments on commit c01bccb

Please sign in to comment.