Skip to content

Commit c77f762

Browse files
committed
e2e: add performance test
Signed-off-by: Victoria Dye <[email protected]>
1 parent 3a93da2 commit c77f762

File tree

6 files changed

+61
-17
lines changed

6 files changed

+61
-17
lines changed

test/e2e/cucumber.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const common = {
2+
requireModule: ['ts-node/register'],
3+
require: ['features/**/*.ts'],
4+
publishQuiet: true,
5+
format: ['progress'],
6+
formatOptions: {
7+
snippetInterface: 'async-await'
8+
},
9+
worldParameters: {
10+
bundleServerCommand: '../../bin/git-bundle-server',
11+
bundleWebServerCommand: '../../bin/git-bundle-web-server',
12+
trashDirectoryBase: '../../_test/e2e'
13+
}
14+
}
15+
16+
module.exports = {
17+
default: {
18+
...common,
19+
tags: 'not @slow',
20+
},
21+
all: {
22+
...common
23+
}
24+
}

test/e2e/cucumber.json

-16
This file was deleted.

test/e2e/features/classes/repository.ts

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class ClonedRepository {
88
private remote: RemoteRepo | undefined
99

1010
cloneResult: child_process.SpawnSyncReturns<Buffer>
11+
cloneTimeMs: number
1112

1213
constructor(remote: RemoteRepo, root: string, bundleUri?: string) {
1314
this.initialized = false
@@ -21,7 +22,9 @@ export class ClonedRepository {
2122
}
2223
args.push(this.remote.remoteUri, this.root)
2324

25+
const timer = performance.now()
2426
this.cloneResult = child_process.spawnSync("git", args)
27+
this.cloneTimeMs = performance.now() - timer
2528
if (!this.cloneResult.error) {
2629
this.initialized = true
2730
}

test/e2e/features/performance.feature

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Bundle server performance
2+
3+
Background: The bundle web server is running
4+
Given the bundle web server was started at port 8080
5+
6+
@slow
7+
Scenario Outline: Comparing clone performance
8+
Given a remote repository '<repo>'
9+
Given the bundle server has been initialized with the remote repo
10+
When I clone from the remote repo with a bundle URI
11+
When another developer clones from the remote repo without a bundle URI
12+
Then I compare the clone execution times
13+
14+
Examples:
15+
| repo |
16+
| https://github.com/git/git.git | # takes ~2 minutes
17+
| https://github.com/torvalds/linux.git | # takes ~30(!) minutes

test/e2e/features/step_definitions/repository.ts

+15
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ When('I clone from the remote repo with a bundle URI', async function (this: Bun
5050
this.cloneRepositoryFor(User.Me, this.bundleServer.bundleUri())
5151
})
5252

53+
When('another developer clones from the remote repo without a bundle URI', async function (this: BundleServerWorld) {
54+
this.cloneRepositoryFor(User.Another)
55+
})
56+
5357
When('I fetch from the remote', async function (this: BundleServerWorld) {
5458
const clonedRepo = this.getRepo(User.Me)
5559
utils.assertStatus(0, clonedRepo.runGit("fetch", "origin"))
@@ -108,3 +112,14 @@ Then('my repo\'s bundles {boolean} up-to-date with {string}',
108112
}
109113
}
110114
)
115+
116+
Then('I compare the clone execution times', async function (this: BundleServerWorld) {
117+
const myClone = this.getRepo(User.Me)
118+
const otherClone = this.getRepo(User.Another)
119+
120+
// Verify the clones succeeded
121+
utils.assertStatus(0, myClone.cloneResult)
122+
utils.assertStatus(0, otherClone.cloneResult)
123+
124+
console.log(`\nClone execution time for ${this.remote!.remoteUri}: ${myClone.cloneTimeMs / 1000}s (bundle URI) vs. ${otherClone.cloneTimeMs / 1000}s (no bundle URI)`)
125+
})

test/e2e/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"description": "",
66
"main": "index.js",
77
"scripts": {
8-
"test": "cucumber-js"
8+
"test": "cucumber-js --config cucumber.js",
9+
"test-all": "cucumber-js -p all"
910
},
1011
"license": "MIT",
1112
"devDependencies": {

0 commit comments

Comments
 (0)