Skip to content

Commit dbd89b5

Browse files
authored
Update performance test to use python application and distro (#86)
In this commit we are removing the old logic for using a java application and agent and adding in logic to use a python application (VehicleInventory) and the ADOT distro. A few other relevant changes: * All results (final and intermediary) now go to results folder, which is added to gitignore * Update postgres container to use v14.0 for application compatibility * Commented out jfr-related code (heap stats, warm up, start recording) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent cf461ed commit dbd89b5

20 files changed

+296
-530
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,7 @@ target
6464
.gradle
6565
**/build/
6666
**/generated/
67-
examples/**/build/
67+
examples/**/build/
68+
69+
# Performance test results
70+
**/performance-tests/results/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Use an official Python runtime as a parent image
5+
FROM python:3.10
6+
7+
# Set environment variables
8+
ENV PIP_ROOT_USER_ACTION=ignore
9+
ENV PYTHONDONTWRITEBYTECODE 1
10+
ENV PYTHONUNBUFFERED 1
11+
12+
# Set the working directory
13+
WORKDIR /image-service-app
14+
15+
# Copy the project code into the container
16+
COPY ./sample-applications/vehicle-dealership-sample-app/ImageServiceApp/. /image-service-app/
17+
18+
# Install dependencies
19+
RUN pip install --upgrade pip && pip install -r requirements.txt
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Use an official Python runtime as a parent image
5+
FROM python:3.10
6+
7+
# Set up args
8+
ARG DISTRO
9+
10+
# Set environment variables
11+
ENV PIP_ROOT_USER_ACTION=ignore
12+
ENV PYTHONDONTWRITEBYTECODE 1
13+
ENV PYTHONUNBUFFERED 1
14+
15+
# Set the working directory
16+
WORKDIR /vehicle-inventory-app
17+
18+
# Copy the project code and distro file into the container
19+
COPY ./sample-applications/vehicle-dealership-sample-app/VehicleInventoryApp /vehicle-inventory-app/
20+
COPY ./dist/$DISTRO /vehicle-inventory-app/
21+
22+
# Install dependencies and distro
23+
RUN pip install --upgrade pip && pip install -r requirements.txt && pip install ${DISTRO} --force-reinstall

performance-tests/Dockerfile-petclinic-base

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

performance-tests/k6/basic.js

Lines changed: 36 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,43 @@
11
import http from "k6/http";
22
import {check} from "k6";
3-
import names from "./names.js";
43

5-
const baseUri = `http://petclinic:9966/petclinic/api`;
4+
const baseUri = `http://vehicle-service:8001/vehicle-inventory/`;
65

76
export default function() {
8-
const specialtiesUrl = `${baseUri}/specialties`;
9-
const specialtiesResponse = http.get(specialtiesUrl);
10-
const specialties = JSON.parse(specialtiesResponse.body);
11-
12-
// Add a new vet to the list
13-
const newVet = names.randomVet(specialties);
14-
const response = http.post(`${baseUri}/vets`, JSON.stringify(newVet),
15-
{ headers: { 'Content-Type': 'application/json' } });
16-
// we don't guard against dupes, so this could fail on occasion
17-
check(response, { "create vet status 201": (r) => r.status === 201 });
18-
19-
// make sure we can fetch that vet back out
20-
const vetId = JSON.parse(response.body).id;
21-
const vetUrl = `${baseUri}/vets/${vetId}`
22-
const vetResponse = http.get(vetUrl);
23-
check(vetResponse, { "fetch vet status 200": r => r.status === 200 });
24-
25-
// add a new owner
26-
const newOwner = names.randomOwner();
27-
const newOwnerResponse = http.post(`${baseUri}/owners`, JSON.stringify(newOwner),
28-
{ headers: { 'Content-Type': 'application/json' } });
29-
check(newOwnerResponse, { "new owner status 201": r => r.status === 201});
30-
31-
// make sure we can fetch that owner back out
32-
const ownerId = JSON.parse(newOwnerResponse.body).id;
33-
const ownerResponse = http.get(`${baseUri}/owners/${ownerId}`);
34-
check(ownerResponse, { "fetch new owner status 200": r => r.status === 200});
35-
const owner = JSON.parse(ownerResponse.body);
36-
37-
// get the list of all pet types
38-
const petTypes = JSON.parse(http.get(`${baseUri}/pettypes`).body);
39-
const owners = JSON.parse(http.get(`${baseUri}/owners`).body);
40-
41-
// create a 3 new random pets
42-
const pet1 = names.randomPet(petTypes, owner);
43-
const pet2 = names.randomPet(petTypes, owner);
44-
const pet3 = names.randomPet(petTypes, owner);
45-
46-
const petsUrl = `${baseUri}/pets`;
47-
const newPetResponses = http.batch([
48-
["POST", petsUrl, JSON.stringify(pet1), { headers: { 'Content-Type': 'application/json' } } ],
49-
["POST", petsUrl, JSON.stringify(pet2), { headers: { 'Content-Type': 'application/json' } } ],
50-
["POST", petsUrl, JSON.stringify(pet3), { headers: { 'Content-Type': 'application/json' } } ],
51-
]);
52-
check(newPetResponses[0], { "pet status 201": r => r.status === 201});
53-
check(newPetResponses[1], { "pet status 201": r => r.status === 201});
54-
check(newPetResponses[2], { "pet status 201": r => r.status === 201});
55-
56-
const responses = http.batch([
57-
["GET", `${baseUri}/pets/${JSON.parse(newPetResponses[0].body).id}`],
58-
["GET", `${baseUri}/pets/${JSON.parse(newPetResponses[1].body).id}`],
59-
["GET", `${baseUri}/pets/${JSON.parse(newPetResponses[2].body).id}`]
60-
]);
61-
check(responses[0], { "pet exists 200": r => r.status === 200});
62-
check(responses[1], { "pet exists 200": r => r.status === 200});
63-
check(responses[2], { "pet exists 200": r => r.status === 200});
64-
65-
// Clean up after ourselves.
66-
// Delete pets
67-
const petDeletes = http.batch([
68-
["DELETE", `${baseUri}/pets/${JSON.parse(newPetResponses[0].body).id}`],
69-
["DELETE", `${baseUri}/pets/${JSON.parse(newPetResponses[1].body).id}`],
70-
["DELETE", `${baseUri}/pets/${JSON.parse(newPetResponses[2].body).id}`]
71-
]);
72-
73-
check(petDeletes[0], { "pet deleted 204": r => r.status === 204});
74-
check(petDeletes[1], { "pet deleted 204": r => r.status === 204});
75-
check(petDeletes[2], { "pet deleted 204": r => r.status === 204});
76-
77-
// Delete owner
78-
const delOwner = http.del(`${baseUri}/owners/${ownerId}`);
79-
check(delOwner, { "owner deleted 204": r => r.status === 204});
80-
81-
// Delete vet
82-
const delVet = http.del(`${baseUri}/vets/${vetId}`);
83-
check(delVet, { "owner deleted 204": r => r.status === 204});
84-
85-
//TODO: Set up a visit or two
86-
//TODO: Fetch out the owner again because their model has been updated.
877

8+
/**
9+
* TODO: Test all APIs
10+
* * Some invalid API
11+
* * GET /vehicle-inventory/
12+
* * POST /vehicle-inventory/
13+
* * GET /vehicle-inventory/<int>
14+
* * DELETE /vehicle-inventory/<int>
15+
* * GET /vehicle-inventory/name/<str>
16+
* * GET /vehicle-inventory/<int>/image
17+
* * GET /vehicle-inventory/image/<image_name>
18+
* * POST /vehicle-inventory/image/<image_name>
19+
* * GET /vehicle-inventory/history/
20+
* * POST /vehicle-inventory/history/
21+
* * GET /vehicle-inventory/history/<int>
22+
* * DELETE /vehicle-inventory/history/<int>
23+
* * GET /vehicle-inventory/history/<int>/vehicle
24+
*
25+
* Below tests are basic and non-comprehensive.
26+
*/
27+
28+
const inventoryUrl = `${baseUri}`;
29+
const inventoryResponse = http.get(inventoryUrl);
30+
check(inventoryResponse, { "getInventory 2XX": r => isStatus2XX(r)});
31+
32+
const imageUrl = `${baseUri}image/fake-image`;
33+
const imageResponse = http.get(imageUrl);
34+
check(imageResponse, { "getImage 4XX": r => isStatus4XX(r)});
35+
36+
function isStatus2XX (response) {
37+
return response.status >= 200 && response.status <= 399
38+
}
39+
40+
function isStatus4XX (response) {
41+
return response.status >= 400 && response.status <= 499
42+
}
8843
};

performance-tests/k6/names.js

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

0 commit comments

Comments
 (0)