Skip to content

Commit c01bccb

Browse files
committed
[#19] Build Device Communication API in GH Actions workflow.
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]>
1 parent e0ddd99 commit c01bccb

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ jobs:
3434
- name: Build Azure IoT Protocol Gateway Example
3535
working-directory: ./protocol-gateway/azure-mqtt-protocol-gateway
3636
run: mvn install -B -e -DcreateJavadoc=true
37+
- name: Build Device Communication API
38+
working-directory: ./device-communication
39+
run: mvn install -B -e -DcreateJavadoc=true

device-communication/README.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For more information please see resources/api/openApi file.
3232

3333
## Database
3434

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

3737
### Tables
3838

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

4444
### Migrations
4545

46-
When Applications starts tables will be created by the DatabaseSchemaCreator service.
46+
When Application starts, tables will be created by the DatabaseSchemaCreator service.
4747

48-
### Running postgresSQL container local
48+
### Running PostgreSQL container locally
4949

50-
For running the PostgresSQL Database local with docker run:
50+
For running the PostgreSQL Database locally with docker, run:
5151

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

61-
Default postgresSQl values:
61+
Default PostgreSQL values:
6262

6363
- userName = postgres
6464
- password = mysecretpassword
6565

6666
## Build and Push API Docker Image
6767

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

7070
````
7171
@@ -74,19 +74,17 @@ quarkus:
7474
builder: docker
7575
build: true
7676
push: true
77-
image: "gcr.io/sotec-iot-core-dev/hono-device-communication"
77+
image: "<registry>/<organization>/hono-device-communication"
7878
7979
````
8080

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

8584
## OpenApi Contract-first
8685

8786
For creating the endpoints, Vertx takes the openApi definition file and maps every endpoint operation-ID with a specific
88-
Handler
89-
function.
87+
Handler function.
9088

9189
## Handlers
9290

device-communication/mvnw

100644100755
-1
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,3 @@ exec "$JAVACMD" \
314314
"-Dmaven.home=${M2_HOME}" \
315315
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316316
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
317-

device-communication/src/main/java/org/eclipse/hono/communication/api/DeviceCommunicationHttpServer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void start() {
9797
})
9898
.onFailure(error -> {
9999
if (error != null) {
100-
log.error("Can not create Router {}", error.getMessage());
100+
log.error("Can not create Router: {}", error.getMessage());
101101
} else {
102102
log.error("Can not create Router");
103103
}

device-communication/src/main/resources/application.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ vertx:
3131
quarkus:
3232
container-image:
3333
builder: docker
34-
build: true
34+
build: false
3535
push: false
36-
image: "gcr.io/sotec-iot-core-dev/hono-device-communication"
36+
image: "eclipse/hono-device-communication"

device-communication/src/test/java/org/eclipse/hono/communication/api/DeviceCommunicationHttpServerTest.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ void startSucceeded() {
174174
verify(serverConfigMock, times(1)).getBasePath();
175175
verify(mockedCommandService, times(1)).addRoutes(routerBuilderMock);
176176
verify(serverConfigMock, times(1)).getOpenApiFilePath();
177-
verify(routerMock, times(1)).errorHandler(eq(400), any());
178-
verify(routerMock, times(1)).errorHandler(eq(404), any());
179177
verify(routerMock, times(2)).get(anyString());
180178
verify(routeMock, times(2)).handler(any());
181179
verify(routerMock, times(1)).route(anyString());
@@ -247,7 +245,7 @@ void createServerFailed() {
247245
when(routeMock.handler(any())).thenReturn(routeMock);
248246
when(vertxMock.createHttpServer(any(HttpServerOptions.class))).thenReturn(httpServerMock);
249247
when(httpServerMock.requestHandler(routerMock)).thenReturn(httpServerMock);
250-
when(httpServerMock.listen()).thenReturn(Future.failedFuture(new Throwable()));
248+
when(httpServerMock.listen()).thenReturn(Future.failedFuture(new Throwable("Test error on listen()")));
251249
when(serverConfigMock.getOpenApiFilePath()).thenReturn("/myPath");
252250
when(serverConfigMock.getBasePath()).thenReturn("/basePath");
253251
when(routerMock.route(any())).thenReturn(routeMock);
@@ -274,8 +272,6 @@ void createServerFailed() {
274272
verify(serverConfigMock, times(1)).getLivenessPath();
275273
verify(serverConfigMock, times(1)).getReadinessPath();
276274
verify(serverConfigMock, times(1)).getBasePath();
277-
verify(routerMock, times(1)).errorHandler(eq(400), any());
278-
verify(routerMock, times(1)).errorHandler(eq(404), any());
279275
verify(routerMock, times(2)).get(anyString());
280276
verify(routeMock, times(2)).handler(any());
281277
verify(routeMock, times(1)).subRouter(any());

0 commit comments

Comments
 (0)