Skip to content

Commit c9ee08f

Browse files
committed
e2e: add performance test
Add a test that captures timing measurements (in 'console.log()' printouts) for cloning various large repositories. The tests are divided into two example sets: one for tests that run on modern hardware with a good internet connection for a *total* of less than 15 minutes (currently take ~7 minutes), and the other for tests that take longer than that. The latter set is tagged with '@slow' and the 'default' profile is updated to skip them. Add an 'all' profile that runs these slow performance tests alongside the "regular" tests. Helped-by: Derrick Stolee <[email protected]> Signed-off-by: Victoria Dye <[email protected]>
1 parent 368fa56 commit c9ee08f

File tree

4 files changed

+60
-12
lines changed

4 files changed

+60
-12
lines changed

test/e2e/cucumber.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +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+
116
module.exports = {
217
default: {
3-
requireModule: ['ts-node/register'],
4-
require: ['features/**/*.ts'],
5-
publishQuiet: true,
6-
format: ['progress'],
7-
formatOptions: {
8-
snippetInterface: 'async-await'
9-
},
10-
worldParameters: {
11-
bundleServerCommand: '../../bin/git-bundle-server',
12-
bundleWebServerCommand: '../../bin/git-bundle-web-server',
13-
trashDirectoryBase: '../../_test/e2e'
14-
}
18+
...common,
19+
tags: 'not @slow',
20+
},
21+
all: {
22+
...common
1523
}
1624
}

test/e2e/features/classes/repository.ts

Lines changed: 3 additions & 0 deletions
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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
Scenario Outline: Comparing clone performance
7+
Given a remote repository '<repo>'
8+
Given the bundle server has been initialized with the remote repo
9+
When I clone from the remote repo with a bundle URI
10+
When another developer clones from the remote repo without a bundle URI
11+
Then I compare the clone execution times
12+
13+
Examples:
14+
| repo |
15+
| https://github.com/git/git.git |
16+
| https://github.com/kubernetes/kubernetes.git |
17+
18+
@slow
19+
Examples:
20+
| repo |
21+
| https://github.com/homebrew/homebrew-core |
22+
| https://github.com/torvalds/linux.git |

test/e2e/features/step_definitions/repository.ts

Lines changed: 15 additions & 0 deletions
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"))
@@ -107,3 +111,14 @@ Then('my repo\'s bundles {boolean} up-to-date with {string}',
107111
}
108112
}
109113
)
114+
115+
Then('I compare the clone execution times', async function (this: BundleServerWorld) {
116+
const myClone = this.getRepo(User.Me)
117+
const otherClone = this.getRepo(User.Another)
118+
119+
// Verify the clones succeeded
120+
utils.assertStatus(0, myClone.cloneResult)
121+
utils.assertStatus(0, otherClone.cloneResult)
122+
123+
console.log(`\nClone execution time for ${this.remote!.remoteUri}: ${(myClone.cloneTimeMs / 1000).toFixed(2)}s (bundle URI) vs. ${(otherClone.cloneTimeMs / 1000).toFixed(2)}s (no bundle URI)`)
124+
})

0 commit comments

Comments
 (0)