From 3600841e2ba0f405e5000562854d8fb032a17de5 Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Tue, 20 Feb 2018 14:44:24 +0000 Subject: [PATCH] Clean up commented code --- cmd/runmqserver/logging.go | 1 - cmd/runmqserver/mirror.go | 8 ------ test/docker/docker_api_test.go | 38 ----------------------------- test/docker/docker_api_test_util.go | 12 --------- 4 files changed, 59 deletions(-) diff --git a/cmd/runmqserver/logging.go b/cmd/runmqserver/logging.go index 31c95ba..3235d7d 100644 --- a/cmd/runmqserver/logging.go +++ b/cmd/runmqserver/logging.go @@ -82,7 +82,6 @@ func mirrorLogs(ctx context.Context, wg *sync.WaitGroup, name string, fromStart return nil, err } f := filepath.Join(mqini.GetErrorLogDirectory(qm), "AMQERR01.json") - // f := fmt.Sprintf("/var/mqm/qmgrs/\"%v\"/errors/AMQERR01.json", name) if jsonLogs() { return mirrorLog(ctx, wg, f, fromStart, mirrorToStdout) } diff --git a/cmd/runmqserver/mirror.go b/cmd/runmqserver/mirror.go index 2afa6cb..5fd30b8 100644 --- a/cmd/runmqserver/mirror.go +++ b/cmd/runmqserver/mirror.go @@ -61,14 +61,6 @@ func mirrorAvailableMessages(f *os.File, mf mirrorFunc) { for scanner.Scan() { t := scanner.Text() mf(t) - // if strings.HasPrefix(t, "{") { - // // Assume JSON, so just print it - // fmt.Fprintln(w, t) - // } else if strings.HasPrefix(t, "AMQ") { - // // Only print MQ messages with AMQnnnn codes - // log.Println(t) - // //fmt.Fprintln(w, t) - // } count++ } log.Debugf("Mirrored %v log entries", count) diff --git a/test/docker/docker_api_test.go b/test/docker/docker_api_test.go index e6bd7fd..1eb1a5c 100644 --- a/test/docker/docker_api_test.go +++ b/test/docker/docker_api_test.go @@ -80,9 +80,6 @@ func TestGoldenPath(t *testing.T) { } containerConfig := container.Config{ Env: []string{"LICENSE=accept", "MQ_QMGR_NAME=qm1"}, - // ExposedPorts: nat.PortSet{ - // "1414/tcp": struct{}{}, - // }, } id := runContainer(t, cli, &containerConfig) defer cleanContainer(t, cli, id) @@ -97,15 +94,6 @@ func TestSecurityVulnerabilities(t *testing.T) { if err != nil { t.Fatal(err) } - // containerConfig := container.Config{ - // // Override the entrypoint to make "apt" only receive security updates, then check for updates - // Entrypoint: []string{"bash", "-c", "source /etc/os-release && echo \"deb http://security.ubuntu.com/ubuntu/ ${VERSION_CODENAME}-security main restricted\" > /etc/apt/sources.list && apt-get update 2>&1 >/dev/null && apt-get --simulate -qq upgrade"}, - // } - // id := runContainer(t, cli, &containerConfig) - // defer cleanContainer(t, cli, id) - // // rc is the return code from apt-get - // rc := waitForContainer(t, cli, id, 10) - rc, _ := runContainerOneShot(t, cli, "bash", "-c", "test -d /etc/apt") if rc != 0 { t.Skip("Skipping test because container is not Ubuntu-based") @@ -379,10 +367,6 @@ func TestReadiness(t *testing.T) { } const numQueues = 3 var buf bytes.Buffer - // fmt.Fprintf(&b, "world!") - - // b := make([]byte, 32768) - // buf := bytes.NewBuffer(b) for i := 1; i <= numQueues; i++ { fmt.Fprintf(&buf, "* Defining queue test %v\nDEFINE QLOCAL(test%v)\n", i, i) } @@ -423,10 +407,7 @@ func countLines(t *testing.T, r io.Reader) int { scanner := bufio.NewScanner(r) count := 0 for scanner.Scan() { - // if scanner.Text() != "" { count++ - // fmt.Printf("%v: %v\n", count, scanner.Text()) - // } } err := scanner.Err() if err != nil { @@ -438,7 +419,6 @@ func countLines(t *testing.T, r io.Reader) int { func countTarLines(t *testing.T, b []byte) int { r := bytes.NewReader(b) tr := tar.NewReader(r) - // totals := make([]int, 3) total := 0 for { _, err := tr.Next() @@ -450,7 +430,6 @@ func countTarLines(t *testing.T, b []byte) int { t.Fatal(err) } total += countLines(t, tr) - // totals = append(totals, countLines(t, tr)) } return total } @@ -494,8 +473,6 @@ func TestErrorLogRotation(t *testing.T) { out := execContainerWithOutput(t, cli, id, "root", []string{"ls", "-l", dir}) t.Log(out) stopContainer(t, cli, id) - // Wait to allow the logs to be mirrored - //time.Sleep(5 * time.Second) b := copyFromContainer(t, cli, id, filepath.Join(dir, "AMQERR01.json")) amqerr01 := countTarLines(t, b) b = copyFromContainer(t, cli, id, filepath.Join(dir, "AMQERR02.json")) @@ -513,24 +490,9 @@ func TestErrorLogRotation(t *testing.T) { if err != nil { t.Fatal(err) } - // log := strings.Split(inspectLogs(t, cli, id), "\n") - // total := 0 - // for _, v := range totals { - // total += v - // } - //log := countLines(t, []byte(inspectLogs(t, cli, id))) total := amqerr01 + amqerr02 + amqerr03 - //total := len(amqerr01) + len(amqerr02) + len(amqerr03) - // totalMirrored := 0 - // for _, line := range log { - // // Look for something which is only in the MQ log lines, and not those from runmqserver - // if strings.Contains(line, "ibm_threadId") { - // totalMirrored++ - // } - // } if totalMirrored != total { t.Fatalf("Expected %v (%v + %v + %v) mirrored log entries; got %v", total, amqerr01, amqerr02, amqerr03, totalMirrored) - //t.Fatalf("Expected %v mirrored log entries; got %v (AMQERR01=%v entries; AMQERR02=%v entries; AMQERR03=%v entries)", total, totalMirrored, totals[0], totals[1], totals[2]) } else { t.Logf("Found %v (%v + %v + %v) mirrored log entries", totalMirrored, amqerr01, amqerr02, amqerr03) } diff --git a/test/docker/docker_api_test_util.go b/test/docker/docker_api_test_util.go index d88a37e..8d0a3e8 100644 --- a/test/docker/docker_api_test_util.go +++ b/test/docker/docker_api_test_util.go @@ -117,14 +117,6 @@ func runContainer(t *testing.T, cli *client.Client, containerConfig *container.C // if coverage containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov") hostConfig := container.HostConfig{ - // PortBindings: nat.PortMap{ - // "1414/tcp": []nat.PortBinding{ - // { - // HostIP: "0.0.0.0", - // HostPort: "1414", - // }, - // }, - // }, Binds: []string{ coverageBind(t), }, @@ -191,8 +183,6 @@ func getCoverageExitCode(t *testing.T, orig int64) int64 { // waitForContainer waits until a container has exited func waitForContainer(t *testing.T, cli *client.Client, ID string, timeout int64) int64 { - //ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second) - //defer cancel() rc, err := cli.ContainerWait(context.Background(), ID) if coverage() { @@ -202,11 +192,9 @@ func waitForContainer(t *testing.T, cli *client.Client, ID string, timeout int64 rc = getCoverageExitCode(t, rc) } - // err := <-errC if err != nil { t.Fatal(err) } - // wait := <-waitC return rc }