Skip to content

Commit 0d2d0b9

Browse files
authored
WIP:CB 32 fixes and updates (#809)
* readme updates * Customer jdbcclient service * customer 32 changes * Fixes for ObaaS deployment * POST location fix, swagger and more. * API docs using Spring docs * Fix transfer endpoint * API doc * Remove debug info * Fix OTEL env variable, corrected PUT endpoint * endpoint updates and README update * Readme and updates * README and deploy update
1 parent bdef2d0 commit 0d2d0b9

File tree

34 files changed

+1211
-70
lines changed

34 files changed

+1211
-70
lines changed

cloudbank-v32/README.md

Lines changed: 197 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,50 @@
11
# CloudBank Version 3.2
22

3-
**Note:** this version will not work on the `1.1.0` version of OBaaS due to JIB problems. THe service `obaas-admin` must be modified to be able to deploy CloudBank version 3.2.
4-
53
Version 3.2 of CloudBank is under development. This document and application is WIP.
64

75
## Build CloudBank
86

9-
`mvn clean package`
7+
1. Clone the source repository
108

11-
```text
12-
[INFO] ------------------------------------------------------------------------
13-
[INFO] Reactor Summary for cloudbank 0.0.1-SNAPSHOT:
14-
[INFO]
15-
[INFO] cloudbank .......................................... SUCCESS [ 0.734 s]
16-
[INFO] account ............................................ SUCCESS [ 2.511 s]
17-
[INFO] customer ........................................... SUCCESS [ 1.046 s]
18-
[INFO] creditscore ........................................ SUCCESS [ 0.815 s]
19-
[INFO] transfer ........................................... SUCCESS [ 0.427 s]
20-
[INFO] testrunner ......................................... SUCCESS [ 0.884 s]
21-
[INFO] checks ............................................. SUCCESS [ 0.912 s]
22-
[INFO] ------------------------------------------------------------------------
23-
[INFO] BUILD SUCCESS
24-
[INFO] ------------------------------------------------------------------------
25-
[INFO] Total time: 7.586 s
26-
[INFO] Finished at: 2023-12-25T17:50:52-06:00
27-
[INFO] ------------------------------------------------------------------------
28-
```
9+
```shell
10+
git clone https://github.com/oracle/microservices-datadriven.git
11+
```
12+
13+
1. Got to the `CloudBank` directory
14+
15+
```shell
16+
cd microservices-datadriven/cloudbank-v32
17+
```
18+
19+
1. Build CloudBank
20+
21+
```shell
22+
mvn clean package
23+
```
2924

30-
## Deploying Cloudbank
25+
Output should look similar to this:
26+
27+
```text
28+
[INFO] ------------------------------------------------------------------------
29+
[INFO] Reactor Summary for CloudBank 0.0.1-SNAPSHOT:
30+
[INFO]
31+
[INFO] CloudBank .......................................... SUCCESS [ 0.950 s]
32+
[INFO] account ............................................ SUCCESS [ 2.904 s]
33+
[INFO] checks ............................................. SUCCESS [ 1.168 s]
34+
[INFO] customer ........................................... SUCCESS [ 1.198 s]
35+
[INFO] customer32 ......................................... SUCCESS [ 1.133 s]
36+
[INFO] creditscore ........................................ SUCCESS [ 0.956 s]
37+
[INFO] transfer ........................................... SUCCESS [ 0.463 s]
38+
[INFO] testrunner ......................................... SUCCESS [ 1.009 s]
39+
[INFO] ------------------------------------------------------------------------
40+
[INFO] BUILD SUCCESS
41+
[INFO] ------------------------------------------------------------------------
42+
[INFO] Total time: 10.160 s
43+
[INFO] Finished at: 2024-01-12T10:41:10-06:00
44+
[INFO] ------------------------------------------------------------------------
45+
```
46+
47+
## Establish connection with OBaaS Admin service
3148

3249
1. Start the tunnel
3350

@@ -63,14 +80,106 @@ Version 3.2 of CloudBank is under development. This document and application is
6380
oractl:>
6481
```
6582
66-
## Test Cloudbank Services
83+
## Deploy CloudBank
84+
85+
CloudBank can be deployed using the `--script` command in `oractl`. CloudBank will be deployed in the namespace `cb32`. You are going to be asked for passwords when the `bind` command executes.
86+
87+
```text
88+
oractl:>script --file deploy-cmds/deploy-cb32.txt
89+
```
90+
91+
The output should look similar to this:
6792
68-
1. Test account service
93+
```text
94+
application/namespace created successfully and image pull secret (registry-auth) created successfully and database TNSAdmin/wallet secret created successfully
95+
Database/Service Password: *************
96+
Schema {account} was successfully Created and Kubernetes Secret {cb32/account} was successfully Created.
97+
Database/Service Password: *************
98+
Schema {account} was successfully Not_Modified and Kubernetes Secret {cb32/checks} was successfully Created.
99+
Database/Service Password: *************
100+
Schema {customer} was successfully Created and Kubernetes Secret {cb32/customer} was successfully Created.
101+
Database/Service Password: *************
102+
Schema {customer} was successfully Not_Modified and Kubernetes Secret {cb32/customer32} was successfully Created.
103+
Database/Service Password: *************
104+
Schema {account} was successfully Not_Modified and Kubernetes Secret {cb32/testrunner} was successfully Created.
105+
uploading: account/target/account-0.0.1-SNAPSHOT.jar
106+
building and pushing image...
107+
108+
creating deployment and service...
109+
obaas-cli [deploy]: Application was successfully deployed.
110+
NOTICE: service not accessible outside K8S
111+
uploading: checks/target/checks-0.0.1-SNAPSHOT.jar
112+
building and pushing image...
113+
114+
creating deployment and service...
115+
obaas-cli [deploy]: Application was successfully deployed.
116+
NOTICE: service not accessible outside K8S
117+
uploading: customer/target/customer-0.0.1-SNAPSHOT.jar
118+
building and pushing image...
119+
120+
creating deployment and service...
121+
obaas-cli [deploy]: Application was successfully deployed.
122+
NOTICE: service not accessible outside K8S
123+
uploading: customer32/target/customer32-0.0.1-SNAPSHOT.jar
124+
building and pushing image...
125+
126+
creating deployment and service...
127+
obaas-cli [deploy]: Application was successfully deployed.
128+
NOTICE: service not accessible outside K8S
129+
uploading: creditscore/target/creditscore-0.0.1-SNAPSHOT.jar
130+
building and pushing image...
131+
132+
creating deployment and service...
133+
obaas-cli [deploy]: Application was successfully deployed.
134+
NOTICE: service not accessible outside K8S
135+
uploading: testrunner/target/testrunner-0.0.1-SNAPSHOT.jar
136+
building and pushing image...
137+
138+
creating deployment and service...
139+
obaas-cli [deploy]: Application was successfully deployed.
140+
NOTICE: service not accessible outside K8S
141+
uploading: transfer/target/transfer-0.0.1-SNAPSHOT.jar
142+
building and pushing image...
143+
144+
creating deployment and service...
145+
obaas-cli [deploy]: Application was successfully deployed.
146+
NOTICE: service not accessible outside K8S
147+
```
148+
149+
The following commands are executed:
150+
151+
```script
152+
create --app-name cb32
153+
bind --app-name cb32 --service-name account
154+
bind --app-name cb32 --service-name checks --username account
155+
bind --app-name cb32 --service-name customer
156+
bind --app-name cb32 --service-name customer32 --username customer
157+
bind --app-name cb32 --service-name testrunner --username account
158+
deploy --app-name cb32 --service-name account --artifact-path account/target/account-0.0.1-SNAPSHOT.jar --image-version 0.0.1 --liquibase-db admin
159+
deploy --app-name cb32 --service-name checks --artifact-path checks/target/checks-0.0.1-SNAPSHOT.jar --image-version 0.0.1
160+
deploy --app-name cb32 --service-name customer --artifact-path customer/target/customer-0.0.1-SNAPSHOT.jar --image-version 0.0.1 --liquibase-db admin
161+
deploy --app-name cb32 --service-name customer32 --artifact-path customer32/target/customer32-0.0.1-SNAPSHOT.jar --image-version 0.0.1 --liquibase-db admin
162+
deploy --app-name cb32 --service-name creditscore --artifact-path creditscore/target/creditscore-0.0.1-SNAPSHOT.jar --image-version 0.0.1
163+
deploy --app-name cb32 --service-name testrunner --artifact-path testrunner/target/testrunner-0.0.1-SNAPSHOT.jar --image-version 0.0.1
164+
deploy --app-name cb32 --service-name transfer --artifact-path transfer/target/transfer-0.0.1-SNAPSHOT.jar --image-version 0.0.1
165+
```
166+
167+
## OpenAPI
168+
169+
All services has OpenAPI documentation and can be reached via the Swagger UI. For example after starting a port forward to anyone of the services you can got to the URL http://localhost:\<port\>/swagger-ui/index.html to see the documentation. Replace \<port\> with the port used in the port forward command.
170+
171+
This is an example of the `customer32` application:
172+
173+
![Eureka Dashboard Login](images/swagger-example.png " ")
174+
175+
## Test CloudBank Services
176+
177+
1. Test `account` service
69178
70179
1. Port forward
71180
72181
```shell
73-
kubectl port-forward -n application svc/account 8081:8080
182+
kubectl port-forward -n cb32 svc/account 8081:8080
74183
```
75184
76185
1. Rest endpoint
@@ -96,15 +205,15 @@ Version 3.2 of CloudBank is under development. This document and application is
96205
]
97206
```
98207
99-
1. Test customer service
208+
1. Test `customer` service
100209
101210
1. Port forward
102211
103212
```shell
104-
kubectl port-forward -n application svc/customer 8082:8080
213+
kubectl port-forward -n cb32 svc/customer 8082:8080
105214
```
106215
107-
1. Rest endpoint
216+
1. REST endpoint
108217
109218
```shell
110219
curl -s http://localhost:8082/api/v1/customer | jq
@@ -126,15 +235,42 @@ Version 3.2 of CloudBank is under development. This document and application is
126235
]
127236
```
128237
129-
1. Test creditscore service
238+
1. Test `customer32` service
239+
240+
1. Port forward
241+
242+
```shell
243+
kubectl port-forward -n cb32 svc/customer32 9000:8080
244+
```
245+
246+
1. REST endpoint
247+
248+
```shell
249+
curl -s http://localhost:8082/api/v1/customer | jq
250+
```
251+
252+
Should return:
253+
254+
```json
255+
[
256+
{
257+
"email": "andy@andy.com",
258+
"id": "qwertysdwr",
259+
"name": "Andy"
260+
},
261+
{...}
262+
]
263+
```
264+
265+
1. Test `creditscore` service
130266
131267
1. Port forward
132268
133269
```shell
134-
kubectl port-forward -n application svc/creditscore 8083:8080
270+
kubectl port-forward -n cb32 svc/creditscore 8083:8080
135271
``````
136272
137-
1. Rest endpoint
273+
1. REST endpoint
138274
139275
```shell
140276
curl -s http://localhost:8083/api/v1/creditscore | jq
@@ -149,15 +285,15 @@ Version 3.2 of CloudBank is under development. This document and application is
149285
}
150286
```
151287
152-
1. Test check service
288+
1. Test `check` service
153289
154290
1. Port forward
155291
156292
```shell
157-
kubectl -n application port-forward svc/testrunner 8084:8080
293+
kubectl -n cb32 port-forward svc/testrunner 8084:8080
158294
```
159295
160-
1. Rest endpoint - deposit check. Make sure you use an existing account number
296+
1. REST endpoint - deposit check. Make sure you use an existing account number
161297
162298
```shell
163299
curl -i -X POST -H 'Content-Type: application/json' -d '{"accountId": 2, "amount": 256}' http://localhost:8084/api/v1/testrunner/deposit
@@ -174,10 +310,10 @@ Version 3.2 of CloudBank is under development. This document and application is
174310
{"accountId":21,"amount":256}
175311
```
176312
177-
1. Check service logs
313+
1. Check application log
178314
179315
```shell
180-
kubectl -n application logs svc/checks
316+
kubectl -n cb32 logs svc/checks
181317
```
182318
183319
Should contain:
@@ -220,10 +356,10 @@ Version 3.2 of CloudBank is under development. This document and application is
220356
{"journalId":7}
221357
```
222358
223-
1. Check logs
359+
1. Check application log
224360
225361
```shell
226-
kubectl -n application logs svc/checks
362+
kubectl -n cb32 logs svc/checks
227363
```
228364
229365
Output should be similar to:
@@ -256,7 +392,7 @@ Version 3.2 of CloudBank is under development. This document and application is
256392
1. Port forward
257393
258394
```shell
259-
kubectl -n application port-forward svc/transfer 8085:8080
395+
kubectl -n cb32 port-forward svc/transfer 8085:8080
260396
```
261397
262398
1. Check account balances. Note that the account numbers 21 and 22 can be different in your environment
@@ -329,10 +465,10 @@ Version 3.2 of CloudBank is under development. This document and application is
329465
}
330466
```
331467
332-
1. Check the log file to confirm
468+
1. Check the application log to confirm
333469
334470
```shell
335-
kubectl -n application logs svc/transfer
471+
kubectl -n cb32 logs svc/transfer
336472
```
337473
338474
Output should look similar to this:
@@ -350,7 +486,9 @@ Version 3.2 of CloudBank is under development. This document and application is
350486
2023-12-26T16:50:45.233Z INFO 1 --- [transfer] [io-8080-exec-10] [] com.example.transfer.TransferService : Process confirm for transfer : http://otmm-tcs.otmm.svc.cluster.local:9000/api/v1/lra-coordinator/ea98ebae-2358-4dd1-9d7c-09f4550d7567
351487
```
352488
353-
1. Check Eureka
489+
## Observability and Tracing
490+
491+
1. Check Eureka dashbaord
354492
355493
1. Port forward
356494
@@ -362,7 +500,7 @@ Version 3.2 of CloudBank is under development. This document and application is
362500
363501
![Eureka Dashboard Login](images/eureka.png " ")
364502
365-
1. Check Jaeger
503+
1. Check Jaeger dashbaord
366504
367505
1. Port forward
368506
@@ -373,3 +511,19 @@ Version 3.2 of CloudBank is under development. This document and application is
373511
1. Open <http://localhost:16686> in a browser and verify that all services are registered
374512
375513
![Jaeger Dashboard Login](images/jaeger.png " ")
514+
515+
1. Choose `customer32` Service and click *Find Traces*
516+
517+
![Customer32](images/j-traces.png " ")
518+
519+
1. Check the Grafana Dashboard
520+
521+
1. Port forward
522+
523+
```shell
524+
kubectl -n grafana port-forward svc/grafana 7070:80
525+
```
526+
527+
1. Open <http://localhost:7070> in a browser and verify that all services are registered and you can see some data (you may have to select the dashboard you want to see)
528+
529+
![Grafana](images/grafana-dashboard.png " ")

cloudbank-v32/account/src/main/java/com/example/accounts/controller/AccountController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package com.example.accounts.controller;
55

6+
import java.net.URI;
67
import java.util.ArrayList;
78
import java.util.List;
89
import java.util.Optional;
@@ -20,6 +21,7 @@
2021
import org.springframework.web.bind.annotation.RequestBody;
2122
import org.springframework.web.bind.annotation.RequestMapping;
2223
import org.springframework.web.bind.annotation.RestController;
24+
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
2325

2426
@RestController
2527
@RequestMapping("/api/v1")
@@ -51,9 +53,14 @@ public List<Account> getAllAccounts() {
5153
public ResponseEntity<Account> createAccount(@RequestBody Account account) {
5254
try {
5355
Account newAccount = accountRepository.saveAndFlush(account);
54-
return new ResponseEntity<>(newAccount, HttpStatus.CREATED);
56+
URI location = ServletUriComponentsBuilder
57+
.fromCurrentRequest()
58+
.path("/{id}")
59+
.buildAndExpand(newAccount.getAccountId())
60+
.toUri();
61+
return ResponseEntity.created(location).build();
5562
} catch (Exception e) {
56-
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
63+
return new ResponseEntity<>(account, HttpStatus.INTERNAL_SERVER_ERROR);
5764
}
5865
}
5966

0 commit comments

Comments
 (0)