mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 14:22:33 +03:00
trying vegeta load testing
This commit is contained in:
parent
50138c2551
commit
e7cb6bd176
5
.gitignore
vendored
5
.gitignore
vendored
@ -25,3 +25,8 @@ uploads/
|
|||||||
.env
|
.env
|
||||||
|
|
||||||
*.bin
|
*.bin
|
||||||
|
|
||||||
|
tests/metrics.json
|
||||||
|
tests/plot.html
|
||||||
|
|
||||||
|
.DS_Store
|
12
db/db.go
12
db/db.go
@ -49,11 +49,11 @@ func Migrate() {
|
|||||||
if !isMigrationInDb {
|
if !isMigrationInDb {
|
||||||
sql := Files.ReadFileText(m)
|
sql := Files.ReadFileText(m)
|
||||||
runMigration(id, name, sql)
|
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) {
|
func runMigration(mid int, mname, msql string) {
|
||||||
@ -72,11 +72,11 @@ func runMigration(mid int, mname, msql string) {
|
|||||||
func getDbMigrations() MigrationsMap {
|
func getDbMigrations() MigrationsMap {
|
||||||
sql := `SELECT id, name FROM migrations`
|
sql := `SELECT id, name FROM migrations`
|
||||||
rows, err := Pool.Query(context.TODO(), sql)
|
rows, err := Pool.Query(context.TODO(), sql)
|
||||||
if err != nil {
|
if err != nil && isNotNonExistentMigrationsTable(err) {
|
||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rows.Err() != nil {
|
if rows.Err() != nil && isNotNonExistentMigrationsTable(rows.Err()) {
|
||||||
log.Panicln(rows.Err())
|
log.Panicln(rows.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,3 +93,7 @@ func getDbMigrations() MigrationsMap {
|
|||||||
|
|
||||||
return migrationsMap
|
return migrationsMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isNotNonExistentMigrationsTable(err error) bool {
|
||||||
|
return err.Error() != `ERROR: relation "migrations" does not exist (SQLSTATE 42P01)`
|
||||||
|
}
|
||||||
|
@ -111,5 +111,5 @@ func seedDb() {
|
|||||||
|
|
||||||
func Seed() {
|
func Seed() {
|
||||||
seedDb()
|
seedDb()
|
||||||
log.Println("mocks - online")
|
log.Println("seeds - online")
|
||||||
}
|
}
|
||||||
|
@ -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]"
|
||||||
|
Loading…
Reference in New Issue
Block a user