mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 23:14:32 +02:00
test: run integration tests on random ports and speed up slow tests (#39842)
Integration test processes now get their own work directory, config file and random ports, so several runs can execute in parallel on one machine. The slowest tests also lose fixed sleeps and needlessly expensive setup, with their assertions kept. - Batch PostgreSQL sequence resets, the main per-test fixture cost there - Cheap hashing params in hash and OAuth2 fixture tests, full-cost vectors stay - Single fetch for negative Actions runner assertions instead of 1s polls - Queue flushes and backdated timestamps instead of sleeps - In-memory SQLite test journal, tmpfs for PostgreSQL in CI - E2E instance writes SSH keys into its work directory instead of `~/.ssh/authorized_keys`
This commit is contained in:
1 parent
d0c35bcd58
commit
1031e34987
42 files changed
+219
-179
No files matched your search
@@ -3,7 +3,7 @@
|
||||
uid: 1
|
||||
name: "Test"
|
||||
client_id: "da7da3ba-9a13-4167-856f-3899de0b0138"
|
||||
client_secret: "$2a$10$UYRgUSgekzBp6hYe8pAdc.cgB4Gn06QRKsORUnIYTYQADs.YR/uvi" # bcrypt of "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=
|
||||
client_secret: "$2a$04$fk.C0LyaUcmxOFLcfcXUDO084yIA9o0nRwkSHSZb/tvZkCzLZjRea" # bcrypt of "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=
|
||||
redirect_uris: '["https://example.com"]'
|
||||
created_unix: 1546869730
|
||||
updated_unix: 1546869730
|
||||
@@ -13,7 +13,7 @@
|
||||
uid: 2
|
||||
name: "Test native app"
|
||||
client_id: "ce5a1322-42a7-11ed-b878-0242ac120002"
|
||||
client_secret: "$2a$10$UYRgUSgekzBp6hYe8pAdc.cgB4Gn06QRKsORUnIYTYQADs.YR/uvi" # bcrypt of "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=
|
||||
client_secret: "$2a$04$VvPoNpflYJB94T8seLcZnOCTtQtB3Q2wXw7ZgrWIi2Oix3VWL8s7i" # bcrypt of "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=
|
||||
redirect_uris: '["http://127.0.0.1"]'
|
||||
created_unix: 1546869730
|
||||
updated_unix: 1546869730
|
||||
|
||||
@@ -51,12 +51,15 @@ func loadFixtureResetSeqPgsql(e *xorm.Engine) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate sequence update: %w", err)
|
||||
}
|
||||
for _, r := range results {
|
||||
for _, value := range r {
|
||||
_, err = e.Exec(value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update sequence: %s, error: %w", value, err)
|
||||
}
|
||||
var statements []string
|
||||
for _, result := range results {
|
||||
for _, statement := range result {
|
||||
statements = append(statements, statement)
|
||||
}
|
||||
}
|
||||
if len(statements) > 0 {
|
||||
if _, err := e.Exec(strings.Join(statements, "\n")); err != nil {
|
||||
return fmt.Errorf("loadFixtureResetSeqPgsql: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -206,7 +206,7 @@ type FixturesOptions struct {
|
||||
|
||||
// CreateTestEngine creates a test database and loads the fixture data from fixturesDir
|
||||
func CreateTestEngine(testSQLiteFile string, opts FixturesOptions) error {
|
||||
driver, connStr, err := db.ConnStr(db.ConnOptions{Type: setting.DatabaseTypeSQLite3, SQLitePath: testSQLiteFile, SQLiteBusyTimeout: setting.DefaultSQLiteBusyTimeout})
|
||||
driver, connStr, err := db.ConnStr(db.ConnOptions{Type: setting.DatabaseTypeSQLite3, SQLitePath: testSQLiteFile, SQLiteBusyTimeout: setting.DefaultSQLiteBusyTimeout, SQLiteJournalMode: "MEMORY"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user