Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests: don't hard-code MySQL in some tests #709

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions tests/history_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ func BenchmarkHistory(b *testing.B) {
}

func benchmarkHistory(b *testing.B, numComments int64) {
m := it.MysqlDatabase()
defer m.Cleanup()
m.ImportIcingaDbSchema()

rdb := getDatabase(b)
r := it.RedisServer()
defer r.Cleanup()
n := it.Icinga2Node("master")
Expand All @@ -39,8 +36,8 @@ func benchmarkHistory(b *testing.B, numComments int64) {
err := n.Reload()
require.NoError(b, err, "icinga2 should reload without error")

db, err := sqlx.Connect("mysql", m.DSN())
require.NoError(b, err, "connecting to mysql")
db, err := sqlx.Connect(rdb.Driver(), rdb.DSN())
require.NoError(b, err, "connecting to database")
defer func() { _ = db.Close() }()

redisClient := r.Open()
Expand Down Expand Up @@ -97,7 +94,7 @@ func benchmarkHistory(b *testing.B, numComments int64) {
b.Logf("current stream length: %d", lastPending)

b.StartTimer()
idb := it.IcingaDbInstance(r, m)
idb := it.IcingaDbInstance(r, rdb)
defer idb.Cleanup()

ticker := time.NewTicker(5 * time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion tests/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func testHistory(t *testing.T, numNodes int) {
}, 15*time.Second, 200*time.Millisecond)

db, err := sqlx.Connect(rdb.Driver(), rdb.DSN())
require.NoError(t, err, "connecting to mysql")
require.NoError(t, err, "connecting to database")
t.Cleanup(func() { _ = db.Close() })

client := nodes[0].IcingaClient
Expand Down
13 changes: 6 additions & 7 deletions tests/sla_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import (
)

func TestSla(t *testing.T) {
m := it.MysqlDatabaseT(t)
m.ImportIcingaDbSchema()
rdb := getDatabase(t)

r := it.RedisServerT(t)
i := it.Icinga2NodeT(t, "master")
i.EnableIcingaDb(r)
err := i.Reload()
require.NoError(t, err, "icinga2 should reload without error")
it.IcingaDbInstanceT(t, r, m)
it.IcingaDbInstanceT(t, r, rdb)

client := i.ApiClient()

Expand Down Expand Up @@ -109,8 +108,8 @@ func TestSla(t *testing.T) {

assert.Equal(t, 3, len(stateChanges), "there should be three hard state changes")

db, err := sqlx.Connect("mysql", m.DSN())
require.NoError(t, err, "connecting to mysql")
db, err := sqlx.Connect(rdb.Driver(), rdb.DSN())
require.NoError(t, err, "connecting to database")
defer func() { _ = db.Close() }()

type Row struct {
Expand Down Expand Up @@ -248,8 +247,8 @@ func TestSla(t *testing.T) {
End int64 `db:"downtime_end"`
}

db, err := sqlx.Connect("mysql", m.DSN())
require.NoError(t, err, "connecting to mysql")
db, err := sqlx.Connect(rdb.Driver(), rdb.DSN())
require.NoError(t, err, "connecting to database")
defer func() { _ = db.Close() }()

if !o.Fixed {
Expand Down
Loading