Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
WIP:CB 32 fixes and updates (oracle#809)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andytael authored Jan 12, 2024
1 parent bdef2d0 commit 0d2d0b9
Show file tree
Hide file tree
Showing 34 changed files with 1,211 additions and 70 deletions.
240 changes: 197 additions & 43 deletions cloudbank-v32/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
# CloudBank Version 3.2

**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.

Version 3.2 of CloudBank is under development. This document and application is WIP.

## Build CloudBank

`mvn clean package`
1. Clone the source repository

```text
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for cloudbank 0.0.1-SNAPSHOT:
[INFO]
[INFO] cloudbank .......................................... SUCCESS [ 0.734 s]
[INFO] account ............................................ SUCCESS [ 2.511 s]
[INFO] customer ........................................... SUCCESS [ 1.046 s]
[INFO] creditscore ........................................ SUCCESS [ 0.815 s]
[INFO] transfer ........................................... SUCCESS [ 0.427 s]
[INFO] testrunner ......................................... SUCCESS [ 0.884 s]
[INFO] checks ............................................. SUCCESS [ 0.912 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.586 s
[INFO] Finished at: 2023-12-25T17:50:52-06:00
[INFO] ------------------------------------------------------------------------
```
```shell
git clone https://github.com/oracle/microservices-datadriven.git
```

1. Got to the `CloudBank` directory

```shell
cd microservices-datadriven/cloudbank-v32
```

1. Build CloudBank

```shell
mvn clean package
```

## Deploying Cloudbank
Output should look similar to this:

```text
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for CloudBank 0.0.1-SNAPSHOT:
[INFO]
[INFO] CloudBank .......................................... SUCCESS [ 0.950 s]
[INFO] account ............................................ SUCCESS [ 2.904 s]
[INFO] checks ............................................. SUCCESS [ 1.168 s]
[INFO] customer ........................................... SUCCESS [ 1.198 s]
[INFO] customer32 ......................................... SUCCESS [ 1.133 s]
[INFO] creditscore ........................................ SUCCESS [ 0.956 s]
[INFO] transfer ........................................... SUCCESS [ 0.463 s]
[INFO] testrunner ......................................... SUCCESS [ 1.009 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.160 s
[INFO] Finished at: 2024-01-12T10:41:10-06:00
[INFO] ------------------------------------------------------------------------
```

## Establish connection with OBaaS Admin service

1. Start the tunnel

Expand Down Expand Up @@ -63,14 +80,106 @@ Version 3.2 of CloudBank is under development. This document and application is
oractl:>
```
## Test Cloudbank Services
## Deploy CloudBank
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.
```text
oractl:>script --file deploy-cmds/deploy-cb32.txt
```
The output should look similar to this:
1. Test account service
```text
application/namespace created successfully and image pull secret (registry-auth) created successfully and database TNSAdmin/wallet secret created successfully
Database/Service Password: *************
Schema {account} was successfully Created and Kubernetes Secret {cb32/account} was successfully Created.
Database/Service Password: *************
Schema {account} was successfully Not_Modified and Kubernetes Secret {cb32/checks} was successfully Created.
Database/Service Password: *************
Schema {customer} was successfully Created and Kubernetes Secret {cb32/customer} was successfully Created.
Database/Service Password: *************
Schema {customer} was successfully Not_Modified and Kubernetes Secret {cb32/customer32} was successfully Created.
Database/Service Password: *************
Schema {account} was successfully Not_Modified and Kubernetes Secret {cb32/testrunner} was successfully Created.
uploading: account/target/account-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
uploading: checks/target/checks-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
uploading: customer/target/customer-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
uploading: customer32/target/customer32-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
uploading: creditscore/target/creditscore-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
uploading: testrunner/target/testrunner-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
uploading: transfer/target/transfer-0.0.1-SNAPSHOT.jar
building and pushing image...
creating deployment and service...
obaas-cli [deploy]: Application was successfully deployed.
NOTICE: service not accessible outside K8S
```
The following commands are executed:
```script
create --app-name cb32
bind --app-name cb32 --service-name account
bind --app-name cb32 --service-name checks --username account
bind --app-name cb32 --service-name customer
bind --app-name cb32 --service-name customer32 --username customer
bind --app-name cb32 --service-name testrunner --username account
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
deploy --app-name cb32 --service-name checks --artifact-path checks/target/checks-0.0.1-SNAPSHOT.jar --image-version 0.0.1
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
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
deploy --app-name cb32 --service-name creditscore --artifact-path creditscore/target/creditscore-0.0.1-SNAPSHOT.jar --image-version 0.0.1
deploy --app-name cb32 --service-name testrunner --artifact-path testrunner/target/testrunner-0.0.1-SNAPSHOT.jar --image-version 0.0.1
deploy --app-name cb32 --service-name transfer --artifact-path transfer/target/transfer-0.0.1-SNAPSHOT.jar --image-version 0.0.1
```
## OpenAPI
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.
This is an example of the `customer32` application:
![Eureka Dashboard Login](images/swagger-example.png " ")
## Test CloudBank Services
1. Test `account` service
1. Port forward
```shell
kubectl port-forward -n application svc/account 8081:8080
kubectl port-forward -n cb32 svc/account 8081:8080
```
1. Rest endpoint
Expand All @@ -96,15 +205,15 @@ Version 3.2 of CloudBank is under development. This document and application is
]
```
1. Test customer service
1. Test `customer` service
1. Port forward
```shell
kubectl port-forward -n application svc/customer 8082:8080
kubectl port-forward -n cb32 svc/customer 8082:8080
```
1. Rest endpoint
1. REST endpoint
```shell
curl -s http://localhost:8082/api/v1/customer | jq
Expand All @@ -126,15 +235,42 @@ Version 3.2 of CloudBank is under development. This document and application is
]
```
1. Test creditscore service
1. Test `customer32` service
1. Port forward
```shell
kubectl port-forward -n cb32 svc/customer32 9000:8080
```
1. REST endpoint
```shell
curl -s http://localhost:8082/api/v1/customer | jq
```
Should return:
```json
[
{
"email": "[email protected]",
"id": "qwertysdwr",
"name": "Andy"
},
{...}
]
```
1. Test `creditscore` service
1. Port forward
```shell
kubectl port-forward -n application svc/creditscore 8083:8080
kubectl port-forward -n cb32 svc/creditscore 8083:8080
``````
1. Rest endpoint
1. REST endpoint
```shell
curl -s http://localhost:8083/api/v1/creditscore | jq
Expand All @@ -149,15 +285,15 @@ Version 3.2 of CloudBank is under development. This document and application is
}
```
1. Test check service
1. Test `check` service
1. Port forward
```shell
kubectl -n application port-forward svc/testrunner 8084:8080
kubectl -n cb32 port-forward svc/testrunner 8084:8080
```
1. Rest endpoint - deposit check. Make sure you use an existing account number
1. REST endpoint - deposit check. Make sure you use an existing account number
```shell
curl -i -X POST -H 'Content-Type: application/json' -d '{"accountId": 2, "amount": 256}' http://localhost:8084/api/v1/testrunner/deposit
Expand All @@ -174,10 +310,10 @@ Version 3.2 of CloudBank is under development. This document and application is
{"accountId":21,"amount":256}
```
1. Check service logs
1. Check application log
```shell
kubectl -n application logs svc/checks
kubectl -n cb32 logs svc/checks
```
Should contain:
Expand Down Expand Up @@ -220,10 +356,10 @@ Version 3.2 of CloudBank is under development. This document and application is
{"journalId":7}
```
1. Check logs
1. Check application log
```shell
kubectl -n application logs svc/checks
kubectl -n cb32 logs svc/checks
```
Output should be similar to:
Expand Down Expand Up @@ -256,7 +392,7 @@ Version 3.2 of CloudBank is under development. This document and application is
1. Port forward
```shell
kubectl -n application port-forward svc/transfer 8085:8080
kubectl -n cb32 port-forward svc/transfer 8085:8080
```
1. Check account balances. Note that the account numbers 21 and 22 can be different in your environment
Expand Down Expand Up @@ -329,10 +465,10 @@ Version 3.2 of CloudBank is under development. This document and application is
}
```
1. Check the log file to confirm
1. Check the application log to confirm
```shell
kubectl -n application logs svc/transfer
kubectl -n cb32 logs svc/transfer
```
Output should look similar to this:
Expand All @@ -350,7 +486,9 @@ Version 3.2 of CloudBank is under development. This document and application is
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
```
1. Check Eureka
## Observability and Tracing
1. Check Eureka dashbaord
1. Port forward
Expand All @@ -362,7 +500,7 @@ Version 3.2 of CloudBank is under development. This document and application is
![Eureka Dashboard Login](images/eureka.png " ")
1. Check Jaeger
1. Check Jaeger dashbaord
1. Port forward
Expand All @@ -373,3 +511,19 @@ Version 3.2 of CloudBank is under development. This document and application is
1. Open <http://localhost:16686> in a browser and verify that all services are registered
![Jaeger Dashboard Login](images/jaeger.png " ")
1. Choose `customer32` Service and click *Find Traces*
![Customer32](images/j-traces.png " ")
1. Check the Grafana Dashboard
1. Port forward
```shell
kubectl -n grafana port-forward svc/grafana 7070:80
```
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)
![Grafana](images/grafana-dashboard.png " ")
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.example.accounts.controller;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand All @@ -20,6 +21,7 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

@RestController
@RequestMapping("/api/v1")
Expand Down Expand Up @@ -51,9 +53,14 @@ public List<Account> getAllAccounts() {
public ResponseEntity<Account> createAccount(@RequestBody Account account) {
try {
Account newAccount = accountRepository.saveAndFlush(account);
return new ResponseEntity<>(newAccount, HttpStatus.CREATED);
URI location = ServletUriComponentsBuilder
.fromCurrentRequest()
.path("/{id}")
.buildAndExpand(newAccount.getAccountId())
.toUri();
return ResponseEntity.created(location).build();
} catch (Exception e) {
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>(account, HttpStatus.INTERNAL_SERVER_ERROR);
}
}

Expand Down
Loading

0 comments on commit 0d2d0b9

Please sign in to comment.