trying vegeta load testing

This commit is contained in:
Yanislav Igonin 2022-05-18 10:23:35 +03:00
parent 50138c2551
commit e7cb6bd176
4 changed files with 20 additions and 7 deletions

5
.gitignore vendored
View File

@ -25,3 +25,8 @@ uploads/
.env
*.bin
tests/metrics.json
tests/plot.html
.DS_Store

View File

@ -49,11 +49,11 @@ func Migrate() {
if !isMigrationInDb {
sql := Files.ReadFileText(m)
runMigration(id, name, sql)
log.Println("database migration - " + name + " - online")
log.Println("migration - " + name + " - online")
}
}
log.Println("database migrations - online")
log.Println("migrations - online")
}
func runMigration(mid int, mname, msql string) {
@ -72,11 +72,11 @@ func runMigration(mid int, mname, msql string) {
func getDbMigrations() MigrationsMap {
sql := `SELECT id, name FROM migrations`
rows, err := Pool.Query(context.TODO(), sql)
if err != nil {
if err != nil && isNotNonExistentMigrationsTable(err) {
log.Panicln(err)
}
if rows.Err() != nil {
if rows.Err() != nil && isNotNonExistentMigrationsTable(rows.Err()) {
log.Panicln(rows.Err())
}
@ -93,3 +93,7 @@ func getDbMigrations() MigrationsMap {
return migrationsMap
}
func isNotNonExistentMigrationsTable(err error) bool {
return err.Error() != `ERROR: relation "migrations" does not exist (SQLSTATE 42P01)`
}

View File

@ -111,5 +111,5 @@ func seedDb() {
func Seed() {
seedDb()
log.Println("mocks - online")
log.Println("seeds - online")
}

View File

@ -1 +1,5 @@
autocannon localhost:3000
echo "GET https://micrach.igonin.dev" | vegeta attack -rate 100 -duration=120s | tee results.bin | vegeta report
# vegeta report -type=json results.bin > metrics.json
cat results.bin | vegeta plot > plot.html
open plot.html
# cat results.bin | vegeta report -type="hist[0,100ms,200ms,300ms]"