MCPcopy Index your code
hub / github.com/ddev/ddev / TestDdevAllDatabases

Function TestDdevAllDatabases

pkg/ddevapp/ddevapp_test.go:1690–1938  ·  view source on GitHub ↗

TestDdevAllDatabases tests db import/export/snapshot/restore/start with supported database versions

(t *testing.T)

Source from the content-addressed store, hash-verified

1688
1689// TestDdevAllDatabases tests db import/export/snapshot/restore/start with supported database versions
1690func TestDdevAllDatabases(t *testing.T) {
1691 // Don't run this unless GOTEST_SHORT is unset; it doesn't need to be run everywhere.
1692 if os.Getenv("GOTEST_SHORT") != "" {
1693 t.Skip("Skipping when GOTEST_SHORT unset")
1694 }
1695 assert := asrt.New(t)
1696
1697 dbVersions := nodeps.GetValidDatabaseVersions()
1698
1699 //Use a smaller list if GOTEST_SHORT
1700 if os.Getenv("GOTEST_SHORT") != "" {
1701 dbVersions = []string{"postgres:18", "postgres:17", "mariadb:11.8", "mariadb:11.4", "mariadb:10.11", "mariadb:10.6", "mysql:8.0", "mysql:8.4", "mysql:5.7"}
1702 t.Logf("Using limited set of database servers because GOTEST_SHORT is set (%v)", dbVersions)
1703 }
1704
1705 if dockerutil.IsPodman() || dockerutil.IsDockerRootless() {
1706 // Works locally but fails in CI.
1707 // [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.
1708 exclusions := []string{"mysql:5.7"}
1709 dbVersions = util.SubtractSlices(dbVersions, exclusions)
1710 t.Logf("Using limited set of database servers because IsPodman or IsDockerRootless (%v)", dbVersions)
1711 }
1712
1713 app := &ddevapp.DdevApp{}
1714 origDir, _ := os.Getwd()
1715
1716 site := TestSites[0]
1717 runTime := util.TimeTrackC(fmt.Sprintf("%s %s", site.Name, t.Name()))
1718
1719 testcommon.ClearDockerEnv()
1720 err := app.Init(site.Dir)
1721 assert.NoError(err)
1722
1723 err = app.Stop(true, false)
1724 require.NoError(t, err)
1725
1726 // Existing DB type in volume should be empty
1727 dbType, err := app.GetExistingDBType()
1728 assert.NoError(err)
1729 assert.Equal("", strings.Trim(dbType, " \n\r\t"))
1730
1731 // Make sure there isn't an old db laying around
1732 _ = dockerutil.RemoveVolume(app.Name + "-mariadb")
1733 t.Cleanup(func() {
1734 err = app.Stop(true, false)
1735 assert.NoError(err)
1736 err = os.RemoveAll(app.GetConfigPath("db_snapshots"))
1737 assert.NoError(err)
1738
1739 // Make sure we leave the config.yaml in expected state
1740 app.Database.Type = nodeps.MariaDB
1741 app.Database.Version = nodeps.MariaDBDefaultVersion
1742 err = app.WriteConfig()
1743 assert.NoError(err)
1744 err = os.Chdir(origDir)
1745 assert.NoError(err)
1746 })
1747

Callers

nothing calls this directly

Calls 15

InitMethod · 0.95
StopMethod · 0.95
GetExistingDBTypeMethod · 0.95
GetConfigPathMethod · 0.95
WriteConfigMethod · 0.95
StartMethod · 0.95
ExecMethod · 0.95
CaptureLogsMethod · 0.95
GetDBClientCommandMethod · 0.95
ImportDBMethod · 0.95
ExportDBMethod · 0.95
MutagenSyncFlushMethod · 0.95

Tested by

no test coverage detected