func buildSetup(t *testing.T) *itutils.DeisTestConfig { cfg := itutils.GetGlobalConfig() cfg.ExampleApp = itutils.GetRandomApp() cfg.AppName = "buildsample" cmd := itutils.GetCommand("auth", "login") itutils.Execute(t, cmd, cfg, false, "") cmd = itutils.GetCommand("git", "clone") itutils.Execute(t, cmd, cfg, false, "") cmd = itutils.GetCommand("apps", "create") cmd1 := itutils.GetCommand("git", "push") cmd2 := itutils.GetCommand("git", "add") cmd3 := itutils.GetCommand("git", "commit") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd, cfg, false, "") itutils.Execute(t, cmd1, cfg, false, "") if err := utils.CreateFile(cfg.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd2, cfg, false, "") itutils.Execute(t, cmd3, cfg, false, "") itutils.Execute(t, cmd1, cfg, false, "") if err := utils.Chdir(".."); err != nil { t.Fatalf("Failed:\n%v", err) } return cfg }
func configSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "configsample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") // ensure envvars with spaces work fine on `git push` // https://github.com/deis/deis/issues/2477 utils.Execute(t, configSet3Cmd, cfg, false, "the Deis team") // ensure custom buildpack URLs are in order url := buildpacks[cfg.ExampleApp] if url == "" { // set url anyway so example-dockerfile apps create a build url = buildpacks["example-go"] } cmd := strings.Replace(configSetBuildpackCmd, "$BUILDPACK_URL", url, 1) utils.Execute(t, cmd, cfg, false, url) utils.Execute(t, gitPushCmd, cfg, false, "") utils.CurlApp(t, *cfg) utils.CheckList(t, "run env --app={{.AppName}}", cfg, "DEIS_APP", false) utils.CheckList(t, "run env --app={{.AppName}}", cfg, "DEIS_RELEASE", false) if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func appsRunTest(t *testing.T, params *utils.DeisTestConfig) { cmd := appsRunCmd if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.CheckList(t, cmd, params, "Hello, 世界", false) utils.Execute(t, "apps:run env", params, true, "GIT_SHA") // Fleet/systemd unit files have a limit of 2048 characters per line or else one encounters // problems parsing the unit. To verify long log messages are truncated and do not crash // logspout (see https://github.com/deis/deis/issues/2046) we must issue a (relatively) short // command via `deis apps:run` that produces a LONG, but testable (predictable) log message we // can search for in the output of `deis logs`. // // The strategy for achieving this is to generate 1k random characters, then use that with a // command submitted via `deis apps:run` that will echo those 1k bytes 64x (on a single line). // Such a message is long enough to crash logspout if handled improperly and ALSO gives us a // large, distinct, and predictable string we can search for in the logs to assert success (and // assert that the message didn't crash logspout) WITHOUT ever needing to transmit such an // egregiously long command via `deis apps:run`. largeString := randomString(1024) utils.Execute(t, fmt.Sprintf("apps:run \"printf '%s%%.0s' {1..64}\"", largeString), params, false, largeString) // To assert the long message didn't crash logspout AND made it to the logger, we will search // the logs for a fragment of the long message-- specifically 2x the random string we generated. // This will help us ensure the actual log message made it through and not JUST the log message // that states the command being execured via `deis apps:run`. We want to find the former, not // the latter because the latter is too short a message to have possibly crashed logspout if // mishandled. utils.Execute(t, "logs", params, false, strings.Repeat(largeString, 2)) if err := utils.Chdir(".."); err != nil { t.Fatal(err) } utils.Execute(t, cmd, params, true, "Not found") }
// buildsScaleTest ensures that we can use a Procfile-based workflow for `deis pull`. func buildsScaleTest(t *testing.T, params *utils.DeisTestConfig) { if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, "scale worker=1 --app={{.AppName}}", params, false, "") utils.Execute(t, "logs --app={{.AppName}}", params, false, "hi") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } }
func appsRunTest(t *testing.T, params *utils.DeisTestConfig) { cmd := appsRunCmd if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, cmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } utils.Execute(t, cmd, params, true, "Not found") }
func appsDestroyTest(t *testing.T, params *utils.DeisTestConfig) { if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsDestroyCmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } if err := utils.Rmdir(params.ExampleApp); err != nil { t.Fatal(err) } }
func appsRunTest(t *testing.T, params *itutils.DeisTestConfig) { cmd := itutils.GetCommand("apps", "run") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd, params, true, "Could not find deis remote in `git remote -v`") }
func appsCreateTest(t *testing.T, params *itutils.DeisTestConfig) { cmd := itutils.GetCommand("apps", "create") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd, params, false, "") itutils.Execute(t, cmd, params, true, "Deis remote already exists") if err := utils.Chdir(".."); err != nil { t.Fatalf("Failed:\n%v", err) } }
func AppsDestroyTest(t *testing.T, params *DeisTestConfig) { cmd := GetCommand("apps", "destroy") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } Execute(t, cmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatalf("Failed:\n%v", err) } if err := utils.Rmdir(params.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } }
func appsLogsTest(t *testing.T, params *itutils.DeisTestConfig) { cmd := itutils.GetCommand("apps", "logs") cmd1 := itutils.GetCommand("git", "push") itutils.Execute(t, cmd, params, true, "204 NO CONTENT") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd1, params, false, "") itutils.Execute(t, cmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatalf("Failed:\n%v", err) } }
func configPushTest(t *testing.T, params *utils.DeisTestConfig) { if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } // create a .env in the project root if err := ioutil.WriteFile(".env", []byte("POWERED_BY=Deis"), 0664); err != nil { t.Fatal(err) } utils.Execute(t, "config:push --app {{.AppName}}", params, false, "Deis") utils.CheckList(t, appsInfoCmd, params, "(v7)", false) if err := utils.Chdir(".."); err != nil { t.Fatal(err) } }
func appsLogsTest(t *testing.T, params *utils.DeisTestConfig) { cmd := appsLogsCmd // test for application lifecycle logs utils.Execute(t, cmd, params, false, "204 NO CONTENT") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, gitPushCmd, params, false, "") utils.Curl(t, params) utils.Execute(t, cmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } }
func psSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "pssample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") utils.Execute(t, gitPushCmd, cfg, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func appsLogsTest(t *testing.T, params *utils.DeisTestConfig) { cmd := appsLogsCmd utils.Execute(t, cmd, params, true, "204 NO CONTENT") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, gitPushCmd, params, false, "") // TODO: nginx needs a few seconds to wake up here--fixme! time.Sleep(5000 * time.Millisecond) utils.Curl(t, params) utils.Execute(t, cmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } }
func appsRunTest(t *testing.T, params *utils.DeisTestConfig) { cmd := appsRunCmd if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.CheckList(t, cmd, params, "Hello, 世界", false) utils.Execute(t, "apps:run env", params, true, "GIT_SHA") // run a REALLY large command to test https://github.com/deis/deis/issues/2046 largeString := randomString(1024) utils.Execute(t, "apps:run echo "+largeString, params, false, largeString) if err := utils.Chdir(".."); err != nil { t.Fatal(err) } utils.Execute(t, cmd, params, true, "Not found") }
// buildsCreateTest uses the `deis builds:create` (or `deis pull`) command // to promote a build from an existing docker image. func buildsCreateTest(t *testing.T, params *utils.DeisTestConfig) { params.AppName = "deispullsample" params.ImageID = "deis/example-go:latest" params.ExampleApp = "example-deis-pull" if err := os.Mkdir(params.ExampleApp, 0755); err != nil { t.Fatal(err) } if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmdNoRemote, params, false, "") utils.Execute(t, buildsCreateCmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } }
func buildSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "buildsample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") utils.Execute(t, gitPushCmd, cfg, false, "") utils.Execute(t, "git commit --allow-empty -m bump", cfg, false, "") utils.Execute(t, gitPushCmd, cfg, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func appsLogsTest(t *testing.T, params *utils.DeisTestConfig) { cmd := appsLogsCmd // test for application lifecycle logs utils.Execute(t, cmd, params, false, "204 NO CONTENT") if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, gitPushCmd, params, false, "") utils.CurlApp(t, *params) utils.Execute(t, cmd, params, false, "created initial release") utils.Execute(t, cmd, params, false, "listening on 5000...") utils.Execute(t, appsLogsLimitCmd, params, false, "") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } }
func configSetup(t *testing.T) *utils.DeisTestConfig { cfg := utils.GetGlobalConfig() cfg.AppName = "configsample" utils.Execute(t, authLoginCmd, cfg, false, "") utils.Execute(t, gitCloneCmd, cfg, false, "") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatal(err) } utils.Execute(t, appsCreateCmd, cfg, false, "") // ensure envvars with spaces work fine on `git push` // https://github.com/deis/deis/issues/2477 utils.Execute(t, configSet3Cmd, cfg, false, "the Deis team") utils.Execute(t, gitPushCmd, cfg, false, "") utils.CurlWithFail(t, cfg, false, "the Deis team") if err := utils.Chdir(".."); err != nil { t.Fatal(err) } return cfg }
func appsCreateTest(t *testing.T, params *utils.DeisTestConfig) { wd, _ := os.Getwd() defer os.Chdir(wd) if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } cmd := appsCreateCmd utils.Execute(t, cmd, params, false, "") utils.Execute(t, cmd, params, true, "App with this Id already exists") }
func releasesSetup(t *testing.T) *itutils.DeisTestConfig { cfg := itutils.GetGlobalConfig() cfg.AppName = "releasessample" cmd := itutils.GetCommand("auth", "login") itutils.Execute(t, cmd, cfg, false, "") cmd = itutils.GetCommand("git", "clone") itutils.Execute(t, cmd, cfg, false, "") cmd = itutils.GetCommand("apps", "create") cmd1 := itutils.GetCommand("git", "push") if err := utils.Chdir(cfg.ExampleApp); err != nil { t.Fatalf("Failed:\n%v", err) } itutils.Execute(t, cmd, cfg, false, "") itutils.Execute(t, cmd1, cfg, false, "") if err := utils.Chdir(".."); err != nil { t.Fatalf("Failed:\n%v", err) } cmd = itutils.GetCommand("config", "set") itutils.Execute(t, cmd, cfg, false, "") return cfg }
func appsCreateTest(t *testing.T, params *utils.DeisTestConfig) { wd, _ := os.Getwd() defer os.Chdir(wd) if err := utils.Chdir(params.ExampleApp); err != nil { t.Fatal(err) } // TODO: move --buildpack to client unit tests utils.Execute(t, appsCreateCmdBuildpack, params, false, "BUILDPACK_URL") utils.Execute(t, appsDestroyCmdNoApp, params, false, "") utils.Execute(t, appsCreateCmd, params, false, "") utils.Execute(t, appsCreateCmd, params, true, "App with this Id already exists") }