MCPcopy Create free account
hub / github.com/ddev/ddev / TestWebserverMariaMySQLDBClient

Function TestWebserverMariaMySQLDBClient

pkg/ddevapp/ddevapp_test.go:2119–2285  ·  view source on GitHub ↗

TestWebserverMariaMySQLDBClient tests functionality of mysql/mariadb database clients in the ddev-webserver

(t *testing.T)

Source from the content-addressed store, hash-verified

2117// TestWebserverMariaMySQLDBClient tests functionality of mysql/mariadb
2118// database clients in the ddev-webserver
2119func TestWebserverMariaMySQLDBClient(t *testing.T) {
2120 // Don't run this unless GOTEST_SHORT is unset; it doesn't need to be run everywhere.
2121 if os.Getenv("GOTEST_SHORT") != "" {
2122 t.Skip("Skip because GOTEST_SHORT is set")
2123 }
2124
2125 assert := asrt.New(t)
2126
2127 serverVersions := []string{"mysql:5.7", "mysql:8.0", "mysql:8.4", "mariadb:10.11", "mariadb:10.6", "mariadb:11.4", "mariadb:11.8"}
2128
2129 if dockerutil.IsPodman() || dockerutil.IsDockerRootless() {
2130 // Works locally but fails in CI.
2131 // mysql:5.7 error
2132 // [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.
2133 // mariadb:10.4 error
2134 // [ERROR] Can't start server : Bind on unix socket: Permission denied
2135 // [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
2136 exclusions := []string{"mysql:5.7", "mariadb:10.4"}
2137 serverVersions = util.SubtractSlices(serverVersions, exclusions)
2138 }
2139
2140 app := &ddevapp.DdevApp{}
2141 origDir, _ := os.Getwd()
2142
2143 site := TestSites[0]
2144 runTime := util.TimeTrackC(fmt.Sprintf("%s %s", site.Name, t.Name()))
2145
2146 testcommon.ClearDockerEnv()
2147 err := app.Init(site.Dir)
2148 assert.NoError(err)
2149
2150 err = app.Stop(true, false)
2151 require.NoError(t, err)
2152
2153 // Existing DB type in volume should be empty
2154 dbType, err := app.GetExistingDBType()
2155 assert.NoError(err)
2156 assert.Equal("", strings.Trim(dbType, " \n\r\t"))
2157
2158 // Make sure there isn't an old db laying around
2159 _ = dockerutil.RemoveVolume(app.Name + "-mariadb")
2160 t.Cleanup(func() {
2161 err = app.Stop(true, false)
2162 assert.NoError(err)
2163 err = os.RemoveAll(app.GetConfigPath("db_snapshots"))
2164 assert.NoError(err)
2165 _ = os.RemoveAll(filepath.Join(app.AppRoot, "users.sql"))
2166 _ = os.RemoveAll(filepath.Join(app.AppRoot, "dbdump.sql"))
2167 // Make sure we leave the config.yaml in expected state
2168 app.Database.Type = nodeps.MariaDB
2169 app.Database.Version = nodeps.MariaDBDefaultVersion
2170 err = app.WriteConfig()
2171 assert.NoError(err)
2172 err = os.Chdir(origDir)
2173 assert.NoError(err)
2174 })
2175
2176 for _, dbTypeVersion := range serverVersions {

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
MutagenSyncFlushMethod · 0.95
GetDBClientCommandMethod · 0.95
GetDBDumpCommandMethod · 0.95
IsPodmanFunction · 0.92
IsDockerRootlessFunction · 0.92

Tested by

no test coverage detected