Skip to content

Commit fdce832

Browse files
authored
Dev (#15)
* - cleanup test code * - add more test assertions - add test coverage to MapPatch method of EndpointConfigurator * -update README to include AddModEndpointsFromAssemblyContaining<T> DI method - utilize AddModEndpointsFromAssemblyContaining<T> method in BenchmarkWebApi project * - organize benchmark endpoints, tests and result files - update README
1 parent 3896783 commit fdce832

34 files changed

+217
-679
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The request is processed in 'HandleAsync' method which returns a strongly typed
4444

4545
### Service Registration
4646

47-
Use AddModEndpointsFromAssembly extension method to register all endpoints defined in an assembly.
47+
Use AddModEndpointsFromAssembly or AddModEndpointsFromAssemblyContaining<T> extension method to register all endpoints defined in an assembly.
4848

4949
Optional: Use FluentValidation.DependencyInjectionExtensions package to add FluentValidation validators to dependency injection for request validation.
5050

@@ -55,7 +55,7 @@ These methods register and map services required for all endpoint types.
5555
``` csharp
5656
var builder = WebApplication.CreateBuilder(args);
5757

58-
builder.Services.AddModEndpointsFromAssembly(typeof(MyEndpoint).Assembly);
58+
builder.Services.AddModEndpointsFromAssemblyContaining<MyEndpoint>();
5959
//Validation
6060
builder.Services.AddValidatorsFromAssemblyContaining<MyValidator>(includeInternalTypes: true);
6161

@@ -353,7 +353,7 @@ MinimalEndpoints perform about same as regular Minimal Apis.
353353

354354
The web apis called for tests, perform only in-process operations like resolving dependency, validating input, calling local methods with no network or disk I/O.
355355

356-
See [test results](./samples/BenchmarkWebApi/BenchmarkFiles/inprocess_benchmark_results.txt) under [BenchmarkFiles](https://github.com/modabas/ModEndpoints/tree/main/samples/BenchmarkWebApi/BenchmarkFiles) folder of BenchmarkWebApi project for detailed results and test scripts.
356+
See [test results](./samples/BenchmarkWebApi/BenchmarkFiles/Results/0.6.5/inprocess_benchmark_results.txt) under [BenchmarkFiles](https://github.com/modabas/ModEndpoints/tree/main/samples/BenchmarkWebApi/BenchmarkFiles) folder of BenchmarkWebApi project for detailed results and test scripts.
357357

358358
## Endpoint Types
359359

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
 k6  .\k6 run minimal_api_basic.js
2+
3+
/\ Grafana /‾‾/
4+
/\ / \ |\ __ / /
5+
/ \/ \ | |/ / / ‾‾\
6+
/ \ | ( | (‾) |
7+
/ __________ \ |_|\_\ \_____/
8+
9+
execution: local
10+
script: minimal_api_basic.js
11+
output: -
12+
13+
scenarios: (100.00%) 1 scenario, 100 max VUs, 2m20s max duration (incl. graceful stop):
14+
* default: Up to 100 looping VUs for 1m50s over 3 stages (gracefulRampDown: 30s, gracefulStop: 30s)
15+
16+
17+
✓ status was 200
18+
19+
checks.........................: 100.00% 8240792 out of 8240792
20+
data_received..................: 1.4 GB 13 MB/s
21+
data_sent......................: 841 MB 7.6 MB/s
22+
http_req_blocked...............: avg=3.22µs min=0s med=0s max=38.46ms p(90)=0s p(95)=0s
23+
http_req_connecting............: avg=7ns min=0s med=0s max=2.54ms p(90)=0s p(95)=0s
24+
✓ http_req_duration..............: avg=921.27µs min=0s med=999.6µs max=73.43ms p(90)=1.99ms p(95)=2.05ms
25+
{ expected_response:true }...: avg=921.27µs min=0s med=999.6µs max=73.43ms p(90)=1.99ms p(95)=2.05ms
26+
http_req_failed................: 0.00% 0 out of 8240792
27+
http_req_receiving.............: avg=31.91µs min=0s med=0s max=70.47ms p(90)=0s p(95)=0s
28+
http_req_sending...............: avg=10.25µs min=0s med=0s max=58.65ms p(90)=0s p(95)=0s
29+
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
30+
http_req_waiting...............: avg=879.1µs min=0s med=999.4µs max=73.43ms p(90)=1.87ms p(95)=2.02ms
31+
http_reqs......................: 8240792 74916.177037/s
32+
iteration_duration.............: avg=1.01ms min=0s med=1ms max=80.43ms p(90)=2ms p(95)=2.32ms
33+
iterations.....................: 8240792 74916.177037/s
34+
vus............................: 1 min=1 max=100
35+
vus_max........................: 100 min=100 max=100
36+
37+
38+
running (1m50.0s), 000/100 VUs, 8240792 complete and 0 interrupted iterations
39+
default ✓ [======================================] 000/100 VUs 1m50s
40+
41+
42+
 k6  .\k6 run minimal_endpoint_basic.js
43+
44+
/\ Grafana /‾‾/
45+
/\ / \ |\ __ / /
46+
/ \/ \ | |/ / / ‾‾\
47+
/ \ | ( | (‾) |
48+
/ __________ \ |_|\_\ \_____/
49+
50+
execution: local
51+
script: minimal_endpoint_basic.js
52+
output: -
53+
54+
scenarios: (100.00%) 1 scenario, 100 max VUs, 2m20s max duration (incl. graceful stop):
55+
* default: Up to 100 looping VUs for 1m50s over 3 stages (gracefulRampDown: 30s, gracefulStop: 30s)
56+
57+
58+
✓ status was 200
59+
60+
checks.........................: 100.00% 8101231 out of 8101231
61+
data_received..................: 1.4 GB 13 MB/s
62+
data_sent......................: 867 MB 7.9 MB/s
63+
http_req_blocked...............: avg=3.13µs min=0s med=0s max=53.35ms p(90)=0s p(95)=0s
64+
http_req_connecting............: avg=10ns min=0s med=0s max=15.67ms p(90)=0s p(95)=0s
65+
✓ http_req_duration..............: avg=942.4µs min=0s med=1ms max=79.74ms p(90)=1.9ms p(95)=2.2ms
66+
{ expected_response:true }...: avg=942.4µs min=0s med=1ms max=79.74ms p(90)=1.9ms p(95)=2.2ms
67+
http_req_failed................: 0.00% 0 out of 8101231
68+
http_req_receiving.............: avg=31.66µs min=0s med=0s max=49.47ms p(90)=0s p(95)=0s
69+
http_req_sending...............: avg=9.95µs min=0s med=0s max=45.94ms p(90)=0s p(95)=0s
70+
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
71+
http_req_waiting...............: avg=900.79µs min=0s med=1ms max=79.19ms p(90)=1.8ms p(95)=2.14ms
72+
http_reqs......................: 8101231 73647.482907/s
73+
iteration_duration.............: avg=1.03ms min=0s med=1.01ms max=79.74ms p(90)=2ms p(95)=2.36ms
74+
iterations.....................: 8101231 73647.482907/s
75+
vus............................: 1 min=1 max=100
76+
vus_max........................: 100 min=100 max=100
77+
78+
79+
running (1m50.0s), 000/100 VUs, 8101231 complete and 0 interrupted iterations
80+
default ✓ [======================================] 000/100 VUs 1m50s
81+
82+
83+
 k6  .\k6 run webresult_endpoint_basic.js
84+
85+
/\ Grafana /‾‾/
86+
/\ / \ |\ __ / /
87+
/ \/ \ | |/ / / ‾‾\
88+
/ \ | ( | (‾) |
89+
/ __________ \ |_|\_\ \_____/
90+
91+
execution: local
92+
script: webresult_endpoint_basic.js
93+
output: -
94+
95+
scenarios: (100.00%) 1 scenario, 100 max VUs, 2m20s max duration (incl. graceful stop):
96+
* default: Up to 100 looping VUs for 1m50s over 3 stages (gracefulRampDown: 30s, gracefulStop: 30s)
97+
98+
99+
✓ status was 200
100+
101+
checks.........................: 100.00% 7848931 out of 7848931
102+
data_received..................: 1.3 GB 12 MB/s
103+
data_sent......................: 856 MB 7.8 MB/s
104+
http_req_blocked...............: avg=3.26µs min=0s med=0s max=61.26ms p(90)=0s p(95)=0s
105+
http_req_connecting............: avg=8ns min=0s med=0s max=2.36ms p(90)=0s p(95)=0s
106+
✓ http_req_duration..............: avg=974.65µs min=0s med=1ms max=98.18ms p(90)=1.99ms p(95)=2.04ms
107+
{ expected_response:true }...: avg=974.65µs min=0s med=1ms max=98.18ms p(90)=1.99ms p(95)=2.04ms
108+
http_req_failed................: 0.00% 0 out of 7848931
109+
http_req_receiving.............: avg=32.4µs min=0s med=0s max=56.13ms p(90)=0s p(95)=0s
110+
http_req_sending...............: avg=10.34µs min=0s med=0s max=56.72ms p(90)=0s p(95)=0s
111+
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
112+
http_req_waiting...............: avg=931.89µs min=0s med=999.8µs max=98.18ms p(90)=1.99ms p(95)=2.02ms
113+
http_reqs......................: 7848931 71353.491423/s
114+
iteration_duration.............: avg=1.06ms min=0s med=1ms max=100.18ms p(90)=2ms p(95)=2.24ms
115+
iterations.....................: 7848931 71353.491423/s
116+
vus............................: 1 min=1 max=100
117+
vus_max........................: 100 min=100 max=100
118+
119+
120+
running (1m50.0s), 000/100 VUs, 7848931 complete and 0 interrupted iterations
121+
default ✓ [======================================] 000/100 VUs 1m50s
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
 k6  .\k6 run regular_endpoint_inprocess.js
1+
 k6  .\k6 run minimal_api_inprocess.js
22

33
/\ Grafana /‾‾/
44
/\ / \ |\ __ / /
@@ -7,7 +7,7 @@
77
/ __________ \ |_|\_\ \_____/
88

99
execution: local
10-
script: regular_endpoint_inprocess.js
10+
script: minimal_api_inprocess.js
1111
output: -
1212

1313
scenarios: (100.00%) 1 scenario, 100 max VUs, 2m20s max duration (incl. graceful stop):
@@ -16,26 +16,26 @@
1616

1717
✓ status was 200
1818

19-
checks.........................: 100.00% 5737012 out of 5737012
19+
checks.........................: 100.00% 5752768 out of 5752768
2020
data_received..................: 1.1 GB 9.8 MB/s
2121
data_sent......................: 1.4 GB 13 MB/s
22-
http_req_blocked...............: avg=4.24µs min=0s med=0s max=40.69ms p(90)=0s p(95)=0s
23-
http_req_connecting............: avg=14ns min=0s med=0s max=6.32ms p(90)=0s p(95)=0s
24-
✓ http_req_duration..............: avg=1.31ms min=0s med=1.01ms max=138.53ms p(90)=2.23ms p(95)=2.67ms
25-
{ expected_response:true }...: avg=1.31ms min=0s med=1.01ms max=138.53ms p(90)=2.23ms p(95)=2.67ms
26-
http_req_failed................: 0.00% 0 out of 5737012
27-
http_req_receiving.............: avg=48.01µs min=0s med=0s max=105.22ms p(90)=0s p(95)=0s
28-
http_req_sending...............: avg=19.74µs min=0s med=0s max=113.35ms p(90)=0s p(95)=0s
22+
http_req_blocked...............: avg=3.98µs min=0s med=0s max=47.4ms p(90)=0s p(95)=0s
23+
http_req_connecting............: avg=13ns min=0s med=0s max=3.4ms p(90)=0s p(95)=0s
24+
✓ http_req_duration..............: avg=1.31ms min=0s med=1.04ms max=103.01ms p(90)=2.18ms p(95)=2.55ms
25+
{ expected_response:true }...: avg=1.31ms min=0s med=1.04ms max=103.01ms p(90)=2.18ms p(95)=2.55ms
26+
http_req_failed................: 0.00% 0 out of 5752768
27+
http_req_receiving.............: avg=45.46µs min=0s med=0s max=70.56ms p(90)=0s p(95)=0s
28+
http_req_sending...............: avg=19µs min=0s med=0s max=62.5ms p(90)=0s p(95)=0s
2929
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
30-
http_req_waiting...............: avg=1.24ms min=0s med=1.01ms max=115.25ms p(90)=2.15ms p(95)=2.58ms
31-
http_reqs......................: 5737012 52154.385571/s
32-
iteration_duration.............: avg=1.46ms min=0s med=1.13ms max=142.44ms p(90)=2.49ms p(95)=3ms
33-
iterations.....................: 5737012 52154.385571/s
30+
http_req_waiting...............: avg=1.25ms min=0s med=1.01ms max=100.94ms p(90)=2.11ms p(95)=2.52ms
31+
http_reqs......................: 5752768 52297.803382/s
32+
iteration_duration.............: avg=1.46ms min=0s med=1.27ms max=103.01ms p(90)=2.43ms p(95)=2.89ms
33+
iterations.....................: 5752768 52297.803382/s
3434
vus............................: 1 min=1 max=100
3535
vus_max........................: 100 min=100 max=100
3636

3737

38-
running (1m50.0s), 000/100 VUs, 5737012 complete and 0 interrupted iterations
38+
running (1m50.0s), 000/100 VUs, 5752768 complete and 0 interrupted iterations
3939
default ✓ [======================================] 000/100 VUs 1m50s
4040

4141

@@ -57,26 +57,26 @@ default ✓ [======================================] 000/100 VUs 1m50s
5757

5858
✓ status was 200
5959

60-
checks.........................: 100.00% 5724672 out of 5724672
60+
checks.........................: 100.00% 5719673 out of 5719673
6161
data_received..................: 1.1 GB 9.7 MB/s
6262
data_sent......................: 1.4 GB 13 MB/s
63-
http_req_blocked...............: avg=4.26µs min=0s med=0s max=37.67ms p(90)=0s p(95)=0s
64-
http_req_connecting............: avg=13ns min=0s med=0s max=2.6ms p(90)=0s p(95)=0s
65-
✓ http_req_duration..............: avg=1.31ms min=0s med=1.01ms max=94.15ms p(90)=2.26ms p(95)=2.67ms
66-
{ expected_response:true }...: avg=1.31ms min=0s med=1.01ms max=94.15ms p(90)=2.26ms p(95)=2.67ms
67-
http_req_failed................: 0.00% 0 out of 5724672
68-
http_req_receiving.............: avg=46.72µs min=0s med=0s max=75.82ms p(90)=0s p(95)=0s
69-
http_req_sending...............: avg=19.92µs min=0s med=0s max=64.82ms p(90)=0s p(95)=0s
70-
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
71-
http_req_waiting...............: avg=1.25ms min=0s med=1.01ms max=94.15ms p(90)=2.18ms p(95)=2.58ms
72-
http_reqs......................: 5724672 52042.396935/s
73-
iteration_duration.............: avg=1.47ms min=0s med=1.2ms max=95.15ms p(90)=2.5ms p(95)=2.99ms
74-
iterations.....................: 5724672 52042.396935/s
63+
http_req_blocked...............: avg=4.16µs min=0s med=0s max=32.38ms p(90)=0s p(95)=0s
64+
http_req_connecting............: avg=13ns min=0s med=0s max=2.05ms p(90)=0s p(95)=0s
65+
✓ http_req_duration..............: avg=1.31ms min=0s med=1.01ms max=104.59ms p(90)=2.21ms p(95)=2.59ms
66+
{ expected_response:true }...: avg=1.31ms min=0s med=1.01ms max=104.59ms p(90)=2.21ms p(95)=2.59ms
67+
http_req_failed................: 0.00% 0 out of 5719673
68+
http_req_receiving.............: avg=46.32µs min=0s med=0s max=84.82ms p(90)=0s p(95)=0s
69+
http_req_sending...............: avg=19.39µs min=0s med=0s max=65.45ms p(90)=0s p(95)=0s
70+
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
71+
http_req_waiting...............: avg=1.25ms min=0s med=1.01ms max=78.82ms p(90)=2.12ms p(95)=2.54ms
72+
http_reqs......................: 5719673 51996.796171/s
73+
iteration_duration.............: avg=1.47ms min=0s med=1.21ms max=107.83ms p(90)=2.5ms p(95)=2.99ms
74+
iterations.....................: 5719673 51996.796171/s
7575
vus............................: 1 min=1 max=100
7676
vus_max........................: 100 min=100 max=100
7777

7878

79-
running (1m50.0s), 000/100 VUs, 5724672 complete and 0 interrupted iterations
79+
running (1m50.0s), 000/100 VUs, 5719673 complete and 0 interrupted iterations
8080
default ✓ [======================================] 000/100 VUs 1m50s
8181

8282

@@ -98,24 +98,24 @@ default ✓ [======================================] 000/100 VUs 1m50s
9898

9999
✓ status was 200
100100

101-
checks.........................: 100.00% 5690098 out of 5690098
102-
data_received..................: 1.1 GB 9.7 MB/s
101+
checks.........................: 100.00% 5601694 out of 5601694
102+
data_received..................: 1.0 GB 9.5 MB/s
103103
data_sent......................: 1.4 GB 13 MB/s
104-
http_req_blocked...............: avg=4.12µs min=0s med=0s max=50.53ms p(90)=0s p(95)=0s
105-
http_req_connecting............: avg=13ns min=0s med=0s max=3.95ms p(90)=0s p(95)=0s
106-
✓ http_req_duration..............: avg=1.32ms min=0s med=1.02ms max=102.88ms p(90)=2.3ms p(95)=2.7ms
107-
{ expected_response:true }...: avg=1.32ms min=0s med=1.02ms max=102.88ms p(90)=2.3ms p(95)=2.7ms
108-
http_req_failed................: 0.00% 0 out of 5690098
109-
http_req_receiving.............: avg=45.89µs min=0s med=0s max=94.8ms p(90)=0s p(95)=0s
110-
http_req_sending...............: avg=19.48µs min=0s med=0s max=58.27ms p(90)=0s p(95)=0s
104+
http_req_blocked...............: avg=4.23µs min=0s med=0s max=32.32ms p(90)=0s p(95)=0s
105+
http_req_connecting............: avg=14ns min=0s med=0s max=7.35ms p(90)=0s p(95)=0s
106+
✓ http_req_duration..............: avg=1.34ms min=0s med=1.08ms max=105.89ms p(90)=2.27ms p(95)=2.62ms
107+
{ expected_response:true }...: avg=1.34ms min=0s med=1.08ms max=105.89ms p(90)=2.27ms p(95)=2.62ms
108+
http_req_failed................: 0.00% 0 out of 5601694
109+
http_req_receiving.............: avg=50.15µs min=0s med=0s max=79.29ms p(90)=0s p(95)=0s
110+
http_req_sending...............: avg=20.22µs min=0s med=0s max=60.37ms p(90)=0s p(95)=0s
111111
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
112-
http_req_waiting...............: avg=1.26ms min=0s med=1.01ms max=91.25ms p(90)=2.22ms p(95)=2.59ms
113-
http_reqs......................: 5690098 51727.985927/s
114-
iteration_duration.............: avg=1.47ms min=0s med=1.24ms max=103.39ms p(90)=2.51ms p(95)=2.99ms
115-
iterations.....................: 5690098 51727.985927/s
112+
http_req_waiting...............: avg=1.27ms min=0s med=1.02ms max=105.89ms p(90)=2.19ms p(95)=2.56ms
113+
http_reqs......................: 5601694 50924.317396/s
114+
iteration_duration.............: avg=1.5ms min=0s med=1.33ms max=105.89ms p(90)=2.5ms p(95)=2.99ms
115+
iterations.....................: 5601694 50924.317396/s
116116
vus............................: 1 min=1 max=100
117117
vus_max........................: 100 min=100 max=100
118118

119119

120-
running (1m50.0s), 000/100 VUs, 5690098 complete and 0 interrupted iterations
120+
running (1m50.0s), 000/100 VUs, 5601694 complete and 0 interrupted iterations
121121
default ✓ [======================================] 000/100 VUs 1m50s

samples/BenchmarkWebApi/BenchmarkFiles/regular_endpoint_basic.js renamed to samples/BenchmarkWebApi/BenchmarkFiles/Tests/minimal_api_basic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const options = {
1717

1818
// Simulated user behavior
1919
export default function () {
20-
let res = http.get("http://localhost:5102/RegularEndpoints/BasicTest/");
20+
let res = http.get("http://localhost:5102/MinimalApis/BasicTest/");
2121
// Validate response status
2222
check(res, { "status was 200": (r) => r.status == 200 });
2323
}

samples/BenchmarkWebApi/BenchmarkFiles/regular_endpoint_inprocess.js renamed to samples/BenchmarkWebApi/BenchmarkFiles/Tests/minimal_api_inprocess.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function () {
2525
timeout: 2000,
2626
};
2727
let data = { name: 'Elizabeth' };
28-
let res = http.post("http://localhost:5102/RegularEndpoints/InProcessTest/2f81c55e-22e7-4410-96de-8a8559cec357", JSON.stringify(data), params);
28+
let res = http.post("http://localhost:5102/MinimalApis/InProcessTest/2f81c55e-22e7-4410-96de-8a8559cec357", JSON.stringify(data), params);
2929
// Validate response status
3030
check(res, { "status was 200": (r) => r.status == 200 });
3131
}

0 commit comments

Comments
 (0)