Skip to content

Commit b1d8e73

Browse files
authored
Merge pull request #20 from davidsilva/video-3-load-testing-optimistic-locking
Updates made during video recording.
2 parents 0fafd0a + daae7a3 commit b1d8e73

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Interview Prep
22

3-
[Video](https://youtu.be/e8xXtHpPZ_o)
3+
[Video](https://www.youtube.com/playlist?list=PL7FXjzyGAf4WDBzSv7eUO0vu8-nZV8kTr)
44

55
This project grew out of wanting to prepare for an interview for a job that would have focused on Angular. As I had been using React exclusively for several months, I needed to refresh my Angular skills. Then I began to add more things to make up for my focus on AWS Amplify. The result is in some ways the opposite of what I have in my previous videos:
66

@@ -10,10 +10,12 @@ This project grew out of wanting to prepare for an interview for a job that woul
1010
* REST (using a NodeJS/Express backend) vs GraphQL (using Amplify and AppSync)
1111
* This project has nothing in regard to authentication (yet), while the Amplify project implemented authentication right at the beginning.
1212
* AWS infrastructure is set up and maintained using Terraform. That is obviously different from the approach AWS Amplify takes.
13-
* CI/CD (continuous integration/continuous deployment) workflow.
13+
* CI/CD (continuous integration/continuous deployment) workflow using GitHub Actions.
1414

1515
Also, in the Amplify project I haven't yet implemented any automated testing but in this project I have unit and integration tests. I set up a GitHub Workflow with GitHub Actions to run the tests when there is a push to or a pull request on specified branches.
1616

17+
As of February 2025, there is a load testing using k6 in the GitHub workflow.
18+
1719
This project is Dockerized, and I developed it in a devcontainer.
1820

1921
## Devcontainer
@@ -130,6 +132,7 @@ A lot of `ci.yml` is self-explanatory but here are some notes to help clarify so
130132
* And finally zips up everything.
131133
* **Update Lambda migration function**: Updates the AWS Lambda function code for database migrations using the AWS CLI. The workflow waits for the update to be completed before the function is invoked.
132134
* **Build and push frontend Docker image**: Note that this step uses a Dockerfile in the root of the project, rather than the Dockerfile in the frontend directory. I wanted to keep the Dockerfile in the frontend directory for local development purposes, e.g., `frontend/Dockerfile` uses the Angular server and port 4200.
135+
* **Load testing**: using [k6](https://k6.io/).
133136

134137
## Infrastructure
135138

@@ -295,6 +298,7 @@ Assuming CWD is `backend`, `npx knex migrate:make <migration-file-name> --knexfi
295298

296299
### 0.1.3
297300
- Added optimistic locking. (Alternatives: Pessimistic Locking, Automatic Conflict Resolution, Eventual Consistency.)
301+
- Added load testing to the GitHub workflow.
298302

299303
### 0.1.2
300304
- Added Terraform configuration for managing AWS infrastructure.

backend/load-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import http from 'k6/http';
22
import { check, sleep } from 'k6';
33

44
// Possible test types include smoke, stress, spike, soak and load.
5-
// Smoke: verify system can habdle a minimal load w/o issues.
6-
// Stress: determine breaking point by increading number of VUs until the API starts returning errors or response times degrade significantly.
5+
// Smoke: verify system can handle a minimal load w/o issues.
6+
// Stress: determine breaking point by increasing number of VUs until the API starts returning errors or response times degrade significantly.
77
// Spike: test how the system handles sudden spikes in load. A sudden increase in the number of VUs to simulate a traffic spike, followed by a return to normal load.
88
// Soak (endurance): test the system's stability and performance over an extended period. Running a constant load for several hours or days to identify memory leaks or performance degradation over time.
99
// Load: test the system under expected peak load conditions. Running a constant load for a period of time to verify that the system can handle the expected number of users.

backend/src/__tests__/integration/products.integration.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ describe('PUT /api/v0/products/:id', () => {
184184

185185
const [createdProduct] = await db('products').insert(product).returning('*');
186186

187-
console.log('****** createdProduct:', createdProduct);
188-
189187
const firstUpdate: Partial<Product> = {
190188
...createdProduct,
191189
name: 'First Update',
@@ -195,8 +193,6 @@ describe('PUT /api/v0/products/:id', () => {
195193
.put(`${productsPath}/${createdProduct.id}`)
196194
.send(firstUpdate);
197195

198-
console.log('****** firstResponse:', firstResponse.body);
199-
200196
expect(firstResponse.status).toBe(200);
201197

202198
// Intentionally create a version mismatch

0 commit comments

Comments
 (0)