Clean up commented code
This commit is contained in:
@@ -82,7 +82,6 @@ func mirrorLogs(ctx context.Context, wg *sync.WaitGroup, name string, fromStart
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
f := filepath.Join(mqini.GetErrorLogDirectory(qm), "AMQERR01.json")
|
f := filepath.Join(mqini.GetErrorLogDirectory(qm), "AMQERR01.json")
|
||||||
// f := fmt.Sprintf("/var/mqm/qmgrs/\"%v\"/errors/AMQERR01.json", name)
|
|
||||||
if jsonLogs() {
|
if jsonLogs() {
|
||||||
return mirrorLog(ctx, wg, f, fromStart, mirrorToStdout)
|
return mirrorLog(ctx, wg, f, fromStart, mirrorToStdout)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,14 +61,6 @@ func mirrorAvailableMessages(f *os.File, mf mirrorFunc) {
|
|||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
t := scanner.Text()
|
t := scanner.Text()
|
||||||
mf(t)
|
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++
|
count++
|
||||||
}
|
}
|
||||||
log.Debugf("Mirrored %v log entries", count)
|
log.Debugf("Mirrored %v log entries", count)
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ func TestGoldenPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
containerConfig := container.Config{
|
containerConfig := container.Config{
|
||||||
Env: []string{"LICENSE=accept", "MQ_QMGR_NAME=qm1"},
|
Env: []string{"LICENSE=accept", "MQ_QMGR_NAME=qm1"},
|
||||||
// ExposedPorts: nat.PortSet{
|
|
||||||
// "1414/tcp": struct{}{},
|
|
||||||
// },
|
|
||||||
}
|
}
|
||||||
id := runContainer(t, cli, &containerConfig)
|
id := runContainer(t, cli, &containerConfig)
|
||||||
defer cleanContainer(t, cli, id)
|
defer cleanContainer(t, cli, id)
|
||||||
@@ -97,15 +94,6 @@ func TestSecurityVulnerabilities(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
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")
|
rc, _ := runContainerOneShot(t, cli, "bash", "-c", "test -d /etc/apt")
|
||||||
if rc != 0 {
|
if rc != 0 {
|
||||||
t.Skip("Skipping test because container is not Ubuntu-based")
|
t.Skip("Skipping test because container is not Ubuntu-based")
|
||||||
@@ -379,10 +367,6 @@ func TestReadiness(t *testing.T) {
|
|||||||
}
|
}
|
||||||
const numQueues = 3
|
const numQueues = 3
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
// fmt.Fprintf(&b, "world!")
|
|
||||||
|
|
||||||
// b := make([]byte, 32768)
|
|
||||||
// buf := bytes.NewBuffer(b)
|
|
||||||
for i := 1; i <= numQueues; i++ {
|
for i := 1; i <= numQueues; i++ {
|
||||||
fmt.Fprintf(&buf, "* Defining queue test %v\nDEFINE QLOCAL(test%v)\n", i, 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)
|
scanner := bufio.NewScanner(r)
|
||||||
count := 0
|
count := 0
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
// if scanner.Text() != "" {
|
|
||||||
count++
|
count++
|
||||||
// fmt.Printf("%v: %v\n", count, scanner.Text())
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
err := scanner.Err()
|
err := scanner.Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -438,7 +419,6 @@ func countLines(t *testing.T, r io.Reader) int {
|
|||||||
func countTarLines(t *testing.T, b []byte) int {
|
func countTarLines(t *testing.T, b []byte) int {
|
||||||
r := bytes.NewReader(b)
|
r := bytes.NewReader(b)
|
||||||
tr := tar.NewReader(r)
|
tr := tar.NewReader(r)
|
||||||
// totals := make([]int, 3)
|
|
||||||
total := 0
|
total := 0
|
||||||
for {
|
for {
|
||||||
_, err := tr.Next()
|
_, err := tr.Next()
|
||||||
@@ -450,7 +430,6 @@ func countTarLines(t *testing.T, b []byte) int {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
total += countLines(t, tr)
|
total += countLines(t, tr)
|
||||||
// totals = append(totals, countLines(t, tr))
|
|
||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
@@ -494,8 +473,6 @@ func TestErrorLogRotation(t *testing.T) {
|
|||||||
out := execContainerWithOutput(t, cli, id, "root", []string{"ls", "-l", dir})
|
out := execContainerWithOutput(t, cli, id, "root", []string{"ls", "-l", dir})
|
||||||
t.Log(out)
|
t.Log(out)
|
||||||
stopContainer(t, cli, id)
|
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"))
|
b := copyFromContainer(t, cli, id, filepath.Join(dir, "AMQERR01.json"))
|
||||||
amqerr01 := countTarLines(t, b)
|
amqerr01 := countTarLines(t, b)
|
||||||
b = copyFromContainer(t, cli, id, filepath.Join(dir, "AMQERR02.json"))
|
b = copyFromContainer(t, cli, id, filepath.Join(dir, "AMQERR02.json"))
|
||||||
@@ -513,24 +490,9 @@ func TestErrorLogRotation(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
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 := 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 {
|
if totalMirrored != total {
|
||||||
t.Fatalf("Expected %v (%v + %v + %v) mirrored log entries; got %v", total, amqerr01, amqerr02, amqerr03, totalMirrored)
|
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 {
|
} else {
|
||||||
t.Logf("Found %v (%v + %v + %v) mirrored log entries", totalMirrored, amqerr01, amqerr02, amqerr03)
|
t.Logf("Found %v (%v + %v + %v) mirrored log entries", totalMirrored, amqerr01, amqerr02, amqerr03)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,14 +117,6 @@ func runContainer(t *testing.T, cli *client.Client, containerConfig *container.C
|
|||||||
// if coverage
|
// if coverage
|
||||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||||
hostConfig := container.HostConfig{
|
hostConfig := container.HostConfig{
|
||||||
// PortBindings: nat.PortMap{
|
|
||||||
// "1414/tcp": []nat.PortBinding{
|
|
||||||
// {
|
|
||||||
// HostIP: "0.0.0.0",
|
|
||||||
// HostPort: "1414",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
Binds: []string{
|
Binds: []string{
|
||||||
coverageBind(t),
|
coverageBind(t),
|
||||||
},
|
},
|
||||||
@@ -191,8 +183,6 @@ func getCoverageExitCode(t *testing.T, orig int64) int64 {
|
|||||||
|
|
||||||
// waitForContainer waits until a container has exited
|
// waitForContainer waits until a container has exited
|
||||||
func waitForContainer(t *testing.T, cli *client.Client, ID string, timeout int64) int64 {
|
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)
|
rc, err := cli.ContainerWait(context.Background(), ID)
|
||||||
|
|
||||||
if coverage() {
|
if coverage() {
|
||||||
@@ -202,11 +192,9 @@ func waitForContainer(t *testing.T, cli *client.Client, ID string, timeout int64
|
|||||||
rc = getCoverageExitCode(t, rc)
|
rc = getCoverageExitCode(t, rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// err := <-errC
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// wait := <-waitC
|
|
||||||
return rc
|
return rc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user