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

Function TestDdevStartMultipleHostnames

pkg/ddevapp/ddevapp_test.go:735–808  ·  view source on GitHub ↗

TestDdevStartMultipleHostnames tests start with multiple hostnames

(t *testing.T)

Source from the content-addressed store, hash-verified

733
734// TestDdevStartMultipleHostnames tests start with multiple hostnames
735func TestDdevStartMultipleHostnames(t *testing.T) {
736 assert := asrt.New(t)
737 app := &ddevapp.DdevApp{}
738
739 for i, site := range TestSites {
740 if site.Disable {
741 t.Logf("Skipping TestSite %s=%d because disabled", site.Name, i)
742 continue
743 }
744
745 runTime := util.TimeTrackC(fmt.Sprintf("%s DdevStartMultipleHostnames", site.Name))
746 testcommon.ClearDockerEnv()
747
748 err := app.Init(site.Dir)
749 assert.NoError(err)
750
751 // site.Name is explicitly added because if not removed in GetHostNames() it will cause ddev-router failure
752 // "a" is repeated for the same reason; a user error of this type should not cause a failure; GetHostNames()
753 // should uniqueify them.
754 app.AdditionalHostnames = []string{"sub1." + site.Name, "sub2." + site.Name, "subname.sub3." + site.Name, site.Name, site.Name, site.Name}
755
756 // sub1.<sitename>.ddev.site and sitename.ddev.site are deliberately included to prove they don't
757 // cause ddev-router failures"
758 // Note that these AdditionalFQDNs require sudo privileges, which the test runners
759 // don't typically have.
760 app.AdditionalFQDNs = []string{"one.example.com", "two.example.com", "a.one.example.com", site.Name + "." + app.ProjectTLD, "sub1." + site.Name + "." + app.ProjectTLD}
761
762 err = app.WriteConfig()
763 assert.NoError(err)
764
765 err = app.StartAndWait(5)
766 require.NoError(t, err)
767 if err != nil && strings.Contains(err.Error(), "db container failed") {
768 c, err := app.FindContainerByType("db")
769 assert.NoError(err)
770 out, err := exec.RunHostCommand("docker", "logs", c.Names[0])
771 assert.NoError(err)
772 t.Logf("DB Logs after app.Start: \n%s\n== END DB LOGS ==", out)
773 }
774
775 // Ensure .ddev/docker-compose*.yaml exists inside .ddev site folder
776 composeFile := fileutil.FileExists(app.DockerComposeYAMLPath())
777 assert.True(composeFile)
778
779 for _, containerType := range []string{"web", "db"} {
780 containerName, err := constructContainerName(containerType, app)
781 assert.NoError(err)
782 check, err := testcommon.ContainerCheck(containerName, "running")
783 assert.NoError(err)
784 assert.True(check, "Container check on %s failed", containerType)
785 }
786
787 httpURLs, _, urls := app.GetAllURLs()
788 if globalconfig.GetCAROOT() == "" {
789 urls = httpURLs
790 }
791 t.Logf("Testing these URLs: %v", urls)
792 for _, testURL := range urls {

Callers

nothing calls this directly

Calls 15

InitMethod · 0.95
WriteConfigMethod · 0.95
StartAndWaitMethod · 0.95
FindContainerByTypeMethod · 0.95
DockerComposeYAMLPathMethod · 0.95
GetAllURLsMethod · 0.95
StopMethod · 0.95
TimeTrackCFunction · 0.92
ClearDockerEnvFunction · 0.92
RunHostCommandFunction · 0.92
FileExistsFunction · 0.92
ContainerCheckFunction · 0.92

Tested by

no test coverage detected