Skip to content

Commit ba48093

Browse files
committed
alpha 1
1 parent f2dc208 commit ba48093

File tree

9 files changed

+272
-97
lines changed

9 files changed

+272
-97
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.1.1</Version>
3+
<Version>0.1.6</Version>
44
</PropertyGroup>
55
</Project>
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
[
2+
{
3+
"BasePath": "https://qatoolkitapi.azurewebsites.net/",
4+
"Path": "/api/bicycles",
5+
"OperationId": "GetAllBikes",
6+
"Method": {
7+
"Method": "GET"
8+
},
9+
"Summary": "Get all bikes by filter",
10+
"Description": "Get all bikes",
11+
"Tags": [
12+
"Public"
13+
],
14+
"Parameters": [
15+
{
16+
"Name": "bicycleType",
17+
"Type": "integer",
18+
"Nullable": false,
19+
"Value": null,
20+
"Required": false,
21+
"Location": 2
22+
},
23+
{
24+
"Name": "api-version",
25+
"Type": "string",
26+
"Nullable": false,
27+
"Value": "1",
28+
"Required": false,
29+
"Location": 2
30+
},
31+
{
32+
"Name": "X-version",
33+
"Type": "string",
34+
"Nullable": false,
35+
"Value": null,
36+
"Required": false,
37+
"Location": 3
38+
}
39+
],
40+
"RequestBodies": [],
41+
"Responses": [
42+
{
43+
"StatusCode": 400,
44+
"Type": 2,
45+
"Properties": [
46+
{
47+
"Name": "statusCode",
48+
"Description": null,
49+
"Format": "int32",
50+
"Type": "integer",
51+
"Value": null,
52+
"Required": false,
53+
"Properties": null
54+
},
55+
{
56+
"Name": "statusDescription",
57+
"Description": null,
58+
"Format": null,
59+
"Type": "string",
60+
"Value": null,
61+
"Required": false,
62+
"Properties": null
63+
},
64+
{
65+
"Name": "message",
66+
"Description": null,
67+
"Format": null,
68+
"Type": "string",
69+
"Value": null,
70+
"Required": false,
71+
"Properties": null
72+
},
73+
{
74+
"Name": "errorCode",
75+
"Description": null,
76+
"Format": "int32",
77+
"Type": "integer",
78+
"Value": null,
79+
"Required": false,
80+
"Properties": null
81+
}
82+
]
83+
},
84+
{
85+
"StatusCode": 200,
86+
"Type": 3,
87+
"Properties": [
88+
{
89+
"Name": "id",
90+
"Description": null,
91+
"Format": "int32",
92+
"Type": "integer",
93+
"Value": null,
94+
"Required": false,
95+
"Properties": null
96+
},
97+
{
98+
"Name": "name",
99+
"Description": null,
100+
"Format": null,
101+
"Type": "string",
102+
"Value": null,
103+
"Required": false,
104+
"Properties": null
105+
},
106+
{
107+
"Name": "brand",
108+
"Description": null,
109+
"Format": null,
110+
"Type": "string",
111+
"Value": null,
112+
"Required": false,
113+
"Properties": null
114+
},
115+
{
116+
"Name": "BicycleType",
117+
"Description": null,
118+
"Format": "int32",
119+
"Type": "enum",
120+
"Value": null,
121+
"Required": false,
122+
"Properties": [
123+
{
124+
"Name": null,
125+
"Description": null,
126+
"Format": null,
127+
"Type": "string",
128+
"Value": "0",
129+
"Required": false,
130+
"Properties": null
131+
},
132+
{
133+
"Name": null,
134+
"Description": null,
135+
"Format": null,
136+
"Type": "string",
137+
"Value": "1",
138+
"Required": false,
139+
"Properties": null
140+
},
141+
{
142+
"Name": null,
143+
"Description": null,
144+
"Format": null,
145+
"Type": "string",
146+
"Value": "2",
147+
"Required": false,
148+
"Properties": null
149+
},
150+
{
151+
"Name": null,
152+
"Description": null,
153+
"Format": null,
154+
"Type": "string",
155+
"Value": "3",
156+
"Required": false,
157+
"Properties": null
158+
}
159+
]
160+
}
161+
]
162+
}
163+
],
164+
"TestTypes": [],
165+
"AuthenticationTypes": []
166+
}
167+
]

src/QAToolKit.Engine.Bombardier.Test/BombardierTestsGeneratorTests.cs

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public async Task GenerateBombardierTestWithOptionsVariation1Test_Successfull()
4646
Assert.Single(bombardierTests);
4747
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 --http2 --timeout=30s --duration=1s", bombardierTests.FirstOrDefault().Command);
4848
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
49-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
49+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
5050
}
5151

5252
[Fact]
@@ -81,7 +81,7 @@ public async Task GenerateBombardierTestWithOptionsVariation2Test_Successfull()
8181
Assert.Single(bombardierTests);
8282
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 --http2 --timeout=30s --duration=10s --insecure", bombardierTests.FirstOrDefault().Command);
8383
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
84-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
84+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
8585
}
8686

8787
[Fact]
@@ -105,7 +105,7 @@ public async Task GenerateBombardierTestWithOptionsVariation3Test_Successfull()
105105
Assert.Single(bombardierTests);
106106
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 --http1 --timeout=30s --duration=1s", bombardierTests.FirstOrDefault().Command);
107107
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
108-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
108+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
109109
}
110110

111111
[Fact]
@@ -130,7 +130,7 @@ public async Task GenerateBombardierTestWithOptionsVariation4Test_Successfull()
130130
Assert.Single(bombardierTests);
131131
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 --http2 --timeout=30s --duration=1s --rate=20", bombardierTests.FirstOrDefault().Command);
132132
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
133-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
133+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
134134
}
135135

136136
[Fact]
@@ -156,7 +156,7 @@ public async Task GenerateBombardierTestWithOptionsVariation5Test_Successfull()
156156
Assert.Single(bombardierTests);
157157
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 --http2 --timeout=30s --duration=1s --rate=20 --requests=22", bombardierTests.FirstOrDefault().Command);
158158
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
159-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
159+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
160160
}
161161

162162
[Fact]
@@ -183,7 +183,7 @@ public async Task GenerateBombardierTestWithOptionsApiKeyTest_Successfull()
183183
Assert.Single(bombardierTests);
184184
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 -H \"ApiKey: 1234\" --http2 --timeout=30s --duration=1s --rate=20 --requests=22", bombardierTests.FirstOrDefault().Command);
185185
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
186-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
186+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
187187
}
188188

189189
[Fact]
@@ -212,7 +212,7 @@ public async Task GenerateBombardierTestWithOptionsBasicAuthTest_Successfull()
212212
Assert.Single(bombardierTests);
213213
Assert.Contains($" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 -H \"Authorization: Basic {authHeader}\" --http2 --timeout=30s --duration=1s --rate=20 --requests=22", bombardierTests.FirstOrDefault().Command);
214214
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
215-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
215+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
216216
}
217217

218218
[Fact]
@@ -239,7 +239,7 @@ public async Task GenerateBombardierTestWithOptionsOAuth2Test_Successfull()
239239
Assert.Single(bombardierTests);
240240
Assert.Contains($" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 1 -H \"Authorization: Bearer 1234567890\" --http2 --timeout=30s --duration=1s --rate=20 --requests=22", bombardierTests.FirstOrDefault().Command);
241241
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
242-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
242+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
243243
}
244244

245245
[Fact]
@@ -257,7 +257,7 @@ public async Task GenerateBombardierTestDefaultBombardierOptionsTest_Successfull
257257
Assert.Single(bombardierTests);
258258
Assert.Contains($" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 3 --http2 --timeout=30s --duration=5s", bombardierTests.FirstOrDefault().Command);
259259
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
260-
Assert.Equal("/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
260+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
261261
}
262262

263263
[Fact]
@@ -287,7 +287,7 @@ public async Task GenerateBombardierTestPostTest_Successfull()
287287
Assert.Single(bombardierTests);
288288
Assert.Contains($@" -m POST https://petstore3.swagger.io/api/v3/pet -c 3 -H ""Content-Type: application/json"" -b ""{{\""id\"":1000,\""name\"":\""MJ\""}}"" --http2 --timeout=30s --duration=5s", bombardierTests.FirstOrDefault().Command);
289289
Assert.Equal(HttpMethod.Post, bombardierTests.FirstOrDefault().Method);
290-
Assert.Equal("/pet", bombardierTests.FirstOrDefault().Url.ToString());
290+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet", bombardierTests.FirstOrDefault().Url.ToString());
291291
}
292292

293293
[Fact]
@@ -317,7 +317,78 @@ public async Task GenerateBombardierTestPostWithExampleValuesTest_Successfull()
317317
Assert.Single(bombardierTests);
318318
Assert.Contains($@" -m POST https://petstore3.swagger.io/api/v3/pet -c 3 -H ""Content-Type: application/json"" -b ""{{\""id\"":999,\""name\"":\""my pet 999\""}}"" --http2 --timeout=30s --duration=5s", bombardierTests.FirstOrDefault().Command);
319319
Assert.Equal(HttpMethod.Post, bombardierTests.FirstOrDefault().Method);
320-
Assert.Equal("/pet", bombardierTests.FirstOrDefault().Url.ToString());
320+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet", bombardierTests.FirstOrDefault().Url.ToString());
321+
}
322+
323+
[Fact]
324+
public async Task GenerateBombardierTestGetBikesReplacementTest_Successfull()
325+
{
326+
var bombardierTestsGenerator = new BombardierTestsGenerator(options =>
327+
{
328+
options.AddReplacementValues(new ReplacementValue[] {
329+
new ReplacementValue(){
330+
Key = "api-version",
331+
Value = "2"
332+
}
333+
});
334+
});
335+
336+
var content = File.ReadAllText("Assets/GetAllBikes.json");
337+
var httpRequest = JsonConvert.DeserializeObject<IList<HttpRequest>>(content);
338+
339+
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
340+
341+
Assert.NotNull(bombardierTests);
342+
Assert.Single(bombardierTests);
343+
Assert.Contains($@" -m GET https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=2 -c 3 --http2 --timeout=30s --duration=5s", bombardierTests.FirstOrDefault().Command);
344+
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
345+
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=2", bombardierTests.FirstOrDefault().Url.ToString());
346+
}
347+
348+
[Fact]
349+
public async Task GenerateBombardierTestGetBikesExampleTest_Successfull()
350+
{
351+
var bombardierTestsGenerator = new BombardierTestsGenerator();
352+
353+
var content = File.ReadAllText("Assets/GetAllBikes.json");
354+
var httpRequest = JsonConvert.DeserializeObject<IList<HttpRequest>>(content);
355+
356+
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
357+
358+
Assert.NotNull(bombardierTests);
359+
Assert.Single(bombardierTests);
360+
Assert.Contains($@" -m GET https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1 -c 3 --http2 --timeout=30s --duration=5s", bombardierTests.FirstOrDefault().Command);
361+
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
362+
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1", bombardierTests.FirstOrDefault().Url.ToString());
363+
}
364+
365+
[Fact]
366+
public async Task GenerateBombardierTestGetBikesExampleWithFilterTest_Successfull()
367+
{
368+
var bombardierTestsGenerator = new BombardierTestsGenerator(options =>
369+
{
370+
options.AddReplacementValues(new ReplacementValue[] {
371+
new ReplacementValue(){
372+
Key = "api-version",
373+
Value = "2"
374+
},
375+
new ReplacementValue(){
376+
Key = "bicycleType",
377+
Value = "1"
378+
}
379+
});
380+
});
381+
382+
var content = File.ReadAllText("Assets/GetAllBikes.json");
383+
var httpRequest = JsonConvert.DeserializeObject<IList<HttpRequest>>(content);
384+
385+
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
386+
387+
Assert.NotNull(bombardierTests);
388+
Assert.Single(bombardierTests);
389+
Assert.Contains($@" -m GET https://qatoolkitapi.azurewebsites.net/api/bicycles?bicycleType=1&api-version=2 -c 3 --http2 --timeout=30s --duration=5s", bombardierTests.FirstOrDefault().Command);
390+
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
391+
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?bicycleType=1&api-version=2", bombardierTests.FirstOrDefault().Url.ToString());
321392
}
322393
}
323394
}

src/QAToolKit.Engine.Bombardier.Test/BombardierTestsRunnerTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public async Task BombardierGetTestWithOptionsTest_Successfull()
5454
Assert.True(bombardierResults.FirstOrDefault().Counter3xx == 0);
5555
Assert.True(bombardierResults.FirstOrDefault().Counter4xx == 0);
5656
Assert.True(bombardierResults.FirstOrDefault().Counter5xx == 0);
57-
Assert.True(bombardierResults.FirstOrDefault().AverageLatency > 0);
58-
Assert.True(bombardierResults.FirstOrDefault().MaxLatency > 0);
59-
Assert.True(bombardierResults.FirstOrDefault().StdevLatency > 0);
60-
Assert.True(bombardierResults.FirstOrDefault().AverageRequestsPerSecond > 0);
61-
Assert.True(bombardierResults.FirstOrDefault().MaxRequestsPerSecond > 0);
62-
Assert.True(bombardierResults.FirstOrDefault().StdevRequestsPerSecond > 0);
57+
Assert.True(bombardierResults.FirstOrDefault().AverageLatency >= 0);
58+
Assert.True(bombardierResults.FirstOrDefault().MaxLatency >= 0);
59+
Assert.True(bombardierResults.FirstOrDefault().StdevLatency >= 0);
60+
Assert.True(bombardierResults.FirstOrDefault().AverageRequestsPerSecond >= 0);
61+
Assert.True(bombardierResults.FirstOrDefault().MaxRequestsPerSecond >= 0);
62+
Assert.True(bombardierResults.FirstOrDefault().StdevRequestsPerSecond >= 0);
6363
Assert.True(bombardierResults.FirstOrDefault().TestStart.AddMinutes(60) > DateTime.Now);
6464
Assert.True(bombardierResults.FirstOrDefault().TestStop.AddMinutes(60) > DateTime.Now);
6565
Assert.True(bombardierResults.FirstOrDefault().TestStop.Subtract(bombardierResults.FirstOrDefault().TestStart).TotalSeconds == bombardierResults.FirstOrDefault().Duration);

src/QAToolKit.Engine.Bombardier.Test/QAToolKit.Engine.Bombardier.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<None Update="Assets\addPet.json">
3030
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3131
</None>
32+
<None Update="Assets\GetAllBikes.json">
33+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
34+
</None>
3235
<None Update="Assets\getPetById.json">
3336
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3437
</None>

src/QAToolKit.Engine.Bombardier/BombardierTestsGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public BombardierTestsGenerator(Action<BombardierGeneratorOptions> options = nul
3131
/// Generate a Bombardier script from requests
3232
/// </summary>
3333
/// <returns></returns>
34+
/// <param name="restRequests"></param>
3435
public async Task<IEnumerable<BombardierTest>> Generate(IList<HttpRequest> restRequests)
3536
{
3637
var bombardierTests = new List<BombardierTest>();
@@ -64,7 +65,7 @@ public async Task<IEnumerable<BombardierTest>> Generate(IList<HttpRequest> restR
6465

6566
bombardierTests.Add(new BombardierTest()
6667
{
67-
Url = new Uri(request.Path, UriKind.RelativeOrAbsolute),
68+
Url = new Uri(HttpUrlHelper.GenerateUrlParameters(request, _bombardierGeneratorOptions), UriKind.Absolute),
6869
Method = request.Method,
6970
Command = scriptBuilder.ToString()
7071
});

0 commit comments

Comments
 (0)