Skip to content

Commit c25671e

Browse files
Merge pull request #4 from mohamed-taman/feature/Adding_APIs_manual_testing_script
Feature/adding apis manual testing script
2 parents 6de3768 + 16c91e6 commit c25671e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+448
-1963
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ build/
5353

5454
### VS Code ###
5555
.vscode/
56+
57+
## Drawio source files ##
58+
*.drawio

README.md

Lines changed: 218 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,223 @@
11
# Springy Store μServices
22

33
- This project is a development of a small set of Spring Boot based Microservices projects, that implement cloud-native intuitive, design patterns and coding best practices.
4+
- The project follows [**CloudNative**](https://www.cncf.io/) recommendations and The [**twelve-factor app**](https://12factor.net/) methodology for building *software-as-a-service apps* to show how μServices should be built and deployed.
5+
- The project is using cutting edge technologies like Docker, Kubernetes, Elasticsearch Stack for logging and monitoring, Java SE 14, MySQL database, MongoDB, TDD, unit, integration & performance testing and Reactive Programming, and many more.
46

5-
- The project follows [**CloudNative**](https://www.cncf.io/) recommendations and The [**twelve-factor app**](https://12factor.net/) methodology for building *software-as-a-service apps* to show how μServices should be built and deplyed.
7+
------
68

7-
- The project is using cutting edge technologies like Docker, Kubernetes, Elasticsearch Stack for logging and monitoring, Java SE 14, MySQL database, MongoDB, TDD, unit, integration & performance testing and Reactive Programming, and many more.
9+
I am developing this project as stages, and all such stages are documented under project **Springy Store μServices** [wiki page](https://github.com/mohamed-taman/Springy-Store-Microservices/wiki). each such stage will be a release so you can go back and forward between releases to see the differences and how adding things solve specific problems we face.
10+
11+
For example; in the first stage (1st release) I just created project structure, basic services skeleton, integration between them, and finally write integration testing as well as semi-automated testing for the whole services functionality.
12+
13+
At 1st stage the **recommendation** and **review** microservices generate local in-memory data and **product composite service** calls the other three services (*product*, *recommendation*, and *review*) statically to generate client aggregate response for a specific product. Therefore in:
14+
15+
- The second stage I will introduce **database integration**, then in
16+
- The third stage I will introduce **Dockerization** of our services and **docker-compose**, and in
17+
- The fourth stage I will introduce **service discovery**, and so on.
18+
19+
## Getting started
20+
21+
The first stage aka (**Release v1.0**) is about creating and implementing a set of project Microservices.
22+
23+
### Creating a Set of Cooperating Microservices
24+
25+
The following topics are covered in this 1st stage (other stages topics will be documented in a project wiki):
26+
27+
- Introducing the microservice landscape.
28+
- Generating skeleton microservices.
29+
- Adding RESTful APIs.
30+
- Adding a **product composite**, **product**, **recommendation**, and **review** microservices.
31+
- Adding error handling.
32+
- Testing the APIs manually.
33+
- Adding automated tests of microservices in isolation.
34+
- Adding semi-automated tests to a microservice landscape.
35+
36+
### System Boundary - μServices Landscape![](docs/stage1/Springy Store Application MS Landscape.png)
37+
38+
### Required software
39+
40+
The following software pieces are initially required:
41+
42+
1. **Git**: it can be downloaded and installed from https://git-scm.com/downloads.
43+
44+
2. **Java 14**: it can be downloaded and installed from https://www.oracle.com/technetwork/java/javase/downloads/index.html.
45+
46+
3. **curl**: this command-line tool for testing HTTP-based APIs can be downloaded and installed from https://curl.haxx.se/download.html.
47+
48+
4. **jq**: This command-line JSON processor can be downloaded and installed from https://stedolan.github.io/jq/download/.
49+
50+
5. Spring Boot Initializer: This *Initializer* generates *spring* boot project with just what you need to start quickly! start from here https://start.spring.io/.
51+
52+
> For each future stage, I will list the newly required software.
53+
54+
Follow the installation guide for each software website and check your software versions from the command line to verify that they are installed correctly.
55+
56+
## Using an IDE
57+
58+
I recommend that you work with your Java code using an IDE that supports the development of Spring Boot applications such as Spring Tool Suite or IntelliJ IDEA Ultimate Edition. So you can use the Spring Boot Dashboard to run the services, run each microservice test case and many more.
59+
60+
All that you want to do is just fire up your IDE **->** open or import the parent folder `springy-store-microservices` and everything will be ready for you.
61+
62+
## Playing With Spring Store Project
63+
64+
### Cloning It
65+
66+
First open **git bash** command line, then simply you can clone the project under any of your favorite places as the following:
67+
68+
```bash
69+
> git clone https://github.com/mohamed-taman/Springy-Store-Microservices.git
70+
```
71+
72+
### Build & Test Them In Isolation
73+
74+
To build and run test cases for each service & shared modules in the project we need to do the following:
75+
76+
#### First: Build & Install Shared Dependencies
77+
78+
> This is done for the first time only or any new version of shared modules..
79+
80+
To build and install `store-utils`, `store-api`, `store-chassis` libraries, from the root folder `springy-store-microservices` run the following commands:
81+
82+
```bash
83+
mohamed.taman@DTLNV8 ~/springy-store-microservices
84+
λ ./setup.sh
85+
```
86+
87+
and you should expect output like this:
88+
89+
```bash
90+
mohamed.taman@DTLNV8 ~/Springy Store Microservices
91+
λ ./setup.sh
92+
93+
Installing all Springy store core shared modules
94+
................................................
95+
96+
1- Installing shared [Utilities] module...
97+
Done successfully.
98+
99+
2- Installing shared [APIs] module...
100+
Done successfully.
101+
102+
3- Installing [parent project] module...
103+
Done successfully.
104+
105+
Wooohooo, building & installing all project modules are finished successfully.
106+
and the project is ready for the next step. :)
107+
```
108+
109+
#### Second: Build & Test Microservices
110+
111+
Now it is time to build our **4 microservices** and run each service integration test in isolation by running the following commands:
112+
113+
```bash
114+
mohamed.taman@DTLNV8 ~/springy-store-microservices
115+
λ cd store-chassis
116+
mohamed.taman@DTLNV8 ~/springy-store-microservices/store-chassis
117+
λ mvn clean verify
118+
```
119+
120+
All build commands and test suite for each microservice should run successfully and the final output should be like this:
121+
122+
```bash
123+
[INFO] ------------------------------------------------------------------------
124+
[INFO] Reactor Summary:
125+
[INFO]
126+
[INFO] Springy Store APIs 1.0-SNAPSHOT .................... SUCCESS [ 3.048 s]
127+
[INFO] Springy Store Utils 1.0-SNAPSHOT ................... SUCCESS [ 2.107 s]
128+
[INFO] Springy Store Chassis 0.0.1-SNAPSHOT ............... SUCCESS [ 0.865 s]
129+
[INFO] Product Composite Service 0.0.1-SNAPSHOT ........... SUCCESS [ 11.086 s]
130+
[INFO] Product Service 0.0.1-SNAPSHOT ..................... SUCCESS [ 9.795 s]
131+
[INFO] Review Service 0.0.1-SNAPSHOT ...................... SUCCESS [ 9.214 s]
132+
[INFO] Recommendation Service 0.0.1-SNAPSHOT .............. SUCCESS [ 9.288 s]
133+
[INFO] ------------------------------------------------------------------------
134+
[INFO] BUILD SUCCESS
135+
[INFO] ------------------------------------------------------------------------
136+
[INFO] Total time: 46.006 s
137+
[INFO] Finished at: 2020-04-01T17:07:52+02:00
138+
[INFO] ------------------------------------------------------------------------
139+
```
140+
141+
### Running Them
142+
143+
Now it is time to run all of them, and it is very simple just run the following two commands:
144+
145+
```bash
146+
mohamed.taman@DTLNV8 ~/springy-store-microservices/store-chassis
147+
λ cd ..
148+
mohamed.taman@DTLNV8 ~/springy-store-microservices
149+
λ ./run-em-all.sh
150+
```
151+
152+
All the services will run in parallel and their output will be printed to the console.
153+
154+
### Testing Them All
155+
156+
Now it is time to test all functionality of the application as one part. and to do so just run the following automation test script:
157+
158+
```bash
159+
mohamed.taman@DTLNV8 ~/springy-store-microservices
160+
λ ./test-em-all.sh
161+
```
162+
163+
The result should be something like this:
164+
165+
```bash
166+
Starting [Springy Store] full functionality testing....
167+
168+
HOST=localhost
169+
PORT=9080
170+
Test OK (HTTP Code: 200)
171+
Test OK (actual value: 1)
172+
Test OK (actual value: 3)
173+
Test OK (actual value: 3)
174+
Test OK (HTTP Code: 404, {"httpStatus":"NOT_FOUND","message":"No product found for productId: 13","path":"/product-composite/13","time":"2020-04-01@14:51:48.812+0200"})
175+
Test OK (HTTP Code: 200)
176+
Test OK (actual value: 113)
177+
Test OK (actual value: 0)
178+
Test OK (actual value: 3)
179+
Test OK (HTTP Code: 200)
180+
Test OK (actual value: 213)
181+
Test OK (actual value: 3)
182+
Test OK (actual value: 0)
183+
Test OK (HTTP Code: 422, {"httpStatus":"UNPROCESSABLE_ENTITY","message":"Invalid productId: -1","path":"/product-composite/-1","time":"2020-04-01@14:51:49.763+0200"})
184+
Test OK (actual value: "Invalid productId: -1")
185+
Test OK (HTTP Code: 400, {"timestamp":"2020-04-01T12:51:49.965+0000","path":"/product-composite/invalidProductId","status":400,"error":"Bad Request","message":"Type mismatch."})
186+
Test OK (actual value: "Type mismatch.")
187+
```
188+
189+
### Closing The Story
190+
191+
And to close the story, we will need to shutdown Microservices manually service by service, hahaha just kidding, run the following script to shutdown them all:
192+
193+
```bash
194+
mohamed.taman@DTLNV8 ~/springy-store-microservices
195+
λ ./stop-em-all.sh
196+
```
197+
198+
and the output should be as the following:
199+
200+
```bash
201+
Stopping [Springy Store] μServices ....
202+
---------------------------------------
203+
204+
Stopping Microservice at port 9080 ....
205+
{"message":"Shutting down, bye..."}
206+
Microservice at port 9080 stopped successfully ....
207+
208+
Stopping Microservice at port 9081 ....
209+
{"message":"Shutting down, bye..."}
210+
Microservice at port 9081 stopped successfully ....
211+
212+
Stopping Microservice at port 9082 ....
213+
{"message":"Shutting down, bye..."}
214+
Microservice at port 9082 stopped successfully ....
215+
216+
Stopping Microservice at port 9083 ....
217+
{"message":"Shutting down, bye..."}
218+
Microservice at port 9083 stopped successfully ....
219+
```
220+
221+
### The End
222+
223+
Happy coding :)
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mxfile host="Electron" modified="2020-04-01T16:42:39.773Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.9.3 Chrome/80.0.3987.158 Electron/8.2.0 Safari/537.36" etag="fDBcLv3HnAtoRhQ4TFjc" version="12.9.3" type="device"><diagram id="_t4D4tSkYDaTQ3sDm7r4" name="Page-1">7VpZk6M2EP41fvQUh8H249ieTVI1W7W1diXZfZOhObICESF85NdHAmHAgA3seDxJ2fMwqLt19PV1I3ukL4PDLxRF3mdiAx5pin0Y6auRpqmKNuH/BOWYUYy5lhFc6ttSqCCs/X8gnympiW9DXBFkhGDmR1WiRcIQLFahIUrJvirmEFzdNUIu1AhrC+E69Q/fZp6kqua8YPwKvuvJrWfaNGMEKBeWmsQessm+RNJfRvqSEsKyp+CwBCyMl9slm/ephXs6GIWQdZnAQjc8qG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nJUHSUIy5DE4rCETAt+2U3RsKjxVxCynw0yOP8nGY/U7UBuF6Eb99WxSLzhGQ5bot8qS/EcI5SwxFutjzCDg5IUwFOL7GKsP67oGV5U9OpHjEnxODfF3G5dO8hJecqna5FLtZi7V2oFP6/yOILw7lo4ScGFxewAdADs1VBWxbHR94Wp/rxC9Wu0roYj6oSu8s+Y1VsDRcxRhHltnN1Y9vhUU8FWzWtSxflzUdHLp1q0zijeu8pzwHpBmEp+JhwKeMJqyQQHqYIVooLb3UpanfZx2TkJkpz4pvVR8M1ATBZwHHycYxWiTduDj1CpNaEY49jg4/fWXx1GPv88OQDizjnBm+qlD7Q0AT6u/M+lqA96pan/A48Pid3Apr/RrQv3lXw==</diagram></mxfile>
File renamed without changes.
File renamed without changes.

product-composite-service/.gitignore

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)