Skip to content

Commit

Permalink
Made the router test take Env variables to alter logging
Browse files Browse the repository at this point in the history
Added new environment variables to help with debugging:
 - OPENSHIFT_LOG_LEVEL: Defaults to 4, but sets the debug level to the given value
 - OPENSHIFT_GET_ALL_DOCKER_LOGS: A boolean that enables dumping of all container logs if any container failed (rather than just giving the logs from the failure)
  • Loading branch information
knobunc committed Sep 29, 2017
1 parent 0bc14df commit 9f2f273
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/end-to-end/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,10 +1348,15 @@ func createAndStartRouterContainerExtended(dockerCli *dockerClient.Client, maste
hostVols = append(hostVols, fmt.Sprintf("%[1]s:/usr/bin/openshift", binary))
}

logLevel := os.Getenv("OPENSHIFT_LOG_LEVEL")
if len(logLevel) == 0 {
logLevel = "4"
}

containerOpts := dockerClient.CreateContainerOptions{
Config: &dockerClient.Config{
Image: getRouterImage(),
Cmd: []string{"--master=" + masterIp, "--loglevel=4"},
Cmd: []string{"--master=" + masterIp, "--loglevel=" + logLevel},
Env: env,
ExposedPorts: exposedPorts,
VolumesFrom: vols,
Expand Down Expand Up @@ -1414,8 +1419,10 @@ func validateServer(server *tr.TestHttpService, t *testing.T) {

// cleanUp stops and removes the deployed router
func cleanUp(t *testing.T, dockerCli *dockerClient.Client, routerId string) {
getAllLogs, _ := strconv.ParseBool(os.Getenv("OPENSHIFT_GET_ALL_DOCKER_LOGS"))

dockerCli.StopContainer(routerId, 5)
if t.Failed() {
if t.Failed() || getAllLogs {
dockerCli.Logs(dockerClient.LogsOptions{
Container: routerId,
OutputStream: os.Stdout,
Expand Down

0 comments on commit 9f2f273

Please sign in to comment.