forked from goharbor/perf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// prepare projects | ||
import { Rate } from 'k6/metrics' | ||
import counter from 'k6/x/counter' | ||
import { Harbor } from 'k6/x/harbor' | ||
|
||
import { Settings } from '../config.js' | ||
import { numberToPadString } from '../helpers.js' | ||
|
||
const settings = Settings() | ||
|
||
const totalIterations = settings.ProjectsCount | ||
|
||
export let successRate = new Rate('success') | ||
|
||
export let options = { | ||
setupTimeout: '6h', | ||
duration: '24h', | ||
vus: Math.min(settings.VUS, totalIterations), | ||
iterations: totalIterations, | ||
thresholds: { | ||
'success': ['rate>=1'], | ||
'iteration_duration{scenario:default}': [ | ||
`max>=0`, | ||
], | ||
'iteration_duration{group:::setup}': [`max>=0`], | ||
} | ||
}; | ||
|
||
const harbor = new Harbor(settings.Harbor); | ||
|
||
export default function () { | ||
const suffix = numberToPadString(counter.up(), settings.ProjectsCount) | ||
|
||
try { | ||
harbor.deleteProject({ projectName: `${settings.ProjectPrefix}-${suffix}` }) | ||
successRate.add(true) | ||
} catch (e) { | ||
successRate.add(false) | ||
console.error(e.message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// prepare users | ||
import { Rate } from 'k6/metrics' | ||
import counter from 'k6/x/counter' | ||
import { Harbor } from 'k6/x/harbor' | ||
|
||
import { Settings } from '../config.js' | ||
import { numberToPadString } from '../helpers.js' | ||
|
||
const settings = Settings() | ||
|
||
const totalIterations = settings.UsersCount | ||
|
||
export let successRate = new Rate('success') | ||
|
||
export let options = { | ||
setupTimeout: '6h', | ||
duration: '24h', | ||
vus: Math.min(settings.VUS, totalIterations), | ||
iterations: totalIterations, | ||
thresholds: { | ||
'success': ['rate>=1'], | ||
'iteration_duration{scenario:default}': [ | ||
`max>=0`, | ||
], | ||
'iteration_duration{group:::setup}': [`max>=0`], | ||
} | ||
}; | ||
|
||
const harbor = new Harbor(settings.Harbor) | ||
|
||
export default function () { | ||
const suffix = numberToPadString(counter.up(), settings.UsersCount) | ||
|
||
try { | ||
harbor.deleteUser(`${settings.UserPrefix}-${suffix}`) | ||
successRate.add(true) | ||
} catch (e) { | ||
successRate.add(false) | ||
console.error(e.message) | ||
} | ||
} |