Mqsc (#95)
* Change to using MQSC option on crtmqm * Fix docker tests * Remove function configureQueueManager
This commit is contained in:
committed by
GitHub Enterprise
parent
c64c6fe95d
commit
9b81aedd9a
@@ -227,14 +227,6 @@ func doMain() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if standby, _ := ready.IsRunningAsStandbyQM(name); !standby {
|
|
||||||
err = configureQueueManager()
|
|
||||||
if err != nil {
|
|
||||||
logTermination(err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enableMetrics := os.Getenv("MQ_ENABLE_METRICS")
|
enableMetrics := os.Getenv("MQ_ENABLE_METRICS")
|
||||||
if enableMetrics == "true" || enableMetrics == "1" {
|
if enableMetrics == "true" || enableMetrics == "1" {
|
||||||
go metrics.GatherMetrics(name, log)
|
go metrics.GatherMetrics(name, log)
|
||||||
|
|||||||
@@ -16,11 +16,9 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -125,61 +123,6 @@ func startQueueManager(name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureQueueManager() error {
|
|
||||||
const configDir string = "/etc/mqm"
|
|
||||||
files, err := ioutil.ReadDir(configDir)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, file := range files {
|
|
||||||
if strings.HasSuffix(file.Name(), ".mqsc") {
|
|
||||||
abs := filepath.Join(configDir, file.Name())
|
|
||||||
// #nosec G204
|
|
||||||
verify := exec.Command("runmqsc", "-v", "-e")
|
|
||||||
// #nosec G204 - command is fixed, no injection vector
|
|
||||||
cmd := exec.Command("runmqsc")
|
|
||||||
// Read mqsc file into variable
|
|
||||||
// #nosec G304 - filename variable is derived from contents of 'configDir' which is a defined constant
|
|
||||||
mqsc, err := ioutil.ReadFile(abs)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error reading file %v: %v", abs, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Write mqsc to buffer
|
|
||||||
var buffer bytes.Buffer
|
|
||||||
_, err = buffer.Write(mqsc)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Error writing MQSC file %v to buffer: %v", abs, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
verifyBuffer := buffer
|
|
||||||
|
|
||||||
// Buffer mqsc to stdin of runmqsc
|
|
||||||
cmd.Stdin = &buffer
|
|
||||||
verify.Stdin = &verifyBuffer
|
|
||||||
|
|
||||||
// Verify the MQSC commands
|
|
||||||
out, err := verify.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("Error verifying MQSC file %v (%v):\n\t%v", file.Name(), err, formatMQSCOutput(string(out)))
|
|
||||||
return fmt.Errorf("Error verifying MQSC file %v (%v):\n\t%v", file.Name(), err, formatMQSCOutput(string(out)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run runmqsc command
|
|
||||||
out, err = cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("Error running MQSC file %v (%v):\n\t%v", file.Name(), err, formatMQSCOutput(string(out)))
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
// Print the runmqsc output, adding tab characters to make it more readable as part of the log
|
|
||||||
log.Printf("Output for \"runmqsc\" with %v:\n\t%v", abs, formatMQSCOutput(string(out)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func stopQueueManager(name string) error {
|
func stopQueueManager(name string) error {
|
||||||
log.Println("Stopping queue manager")
|
log.Println("Stopping queue manager")
|
||||||
qmGracePeriod := os.Getenv("MQ_GRACE_PERIOD")
|
qmGracePeriod := os.Getenv("MQ_GRACE_PERIOD")
|
||||||
@@ -260,7 +203,7 @@ func getQueueManagerDataDir(mounts map[string]string, name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCreateQueueManagerArgs(mounts map[string]string, name string, devMode bool) []string {
|
func getCreateQueueManagerArgs(mounts map[string]string, name string, devMode bool) []string {
|
||||||
args := []string{"-ii", "/etc/mqm/", "-q", "-p", "1414"}
|
args := []string{"-ii", "/etc/mqm/", "-ic", "/etc/mqm/", "-q", "-p", "1414"}
|
||||||
if devMode {
|
if devMode {
|
||||||
args = append(args, "-oa", "user")
|
args = append(args, "-oa", "user")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -584,7 +584,16 @@ func TestMQSC(t *testing.T) {
|
|||||||
id := runContainer(t, cli, &containerConfig)
|
id := runContainer(t, cli, &containerConfig)
|
||||||
defer cleanContainer(t, cli, id)
|
defer cleanContainer(t, cli, id)
|
||||||
waitForReady(t, cli, id)
|
waitForReady(t, cli, id)
|
||||||
rc, mqscOutput := execContainer(t, cli, id, "", []string{"bash", "-c", "echo 'DISPLAY QLOCAL(test)' | runmqsc"})
|
|
||||||
|
rc := -1
|
||||||
|
mqscOutput := ""
|
||||||
|
for i := 0; i < 60; i++ {
|
||||||
|
rc, mqscOutput = execContainer(t, cli, id, "", []string{"bash", "-c", "echo 'DISPLAY QLOCAL(test)' | runmqsc"})
|
||||||
|
if rc == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
if rc != 0 {
|
if rc != 0 {
|
||||||
r := regexp.MustCompile("AMQ[0-9][0-9][0-9][0-9]E")
|
r := regexp.MustCompile("AMQ[0-9][0-9][0-9][0-9]E")
|
||||||
t.Fatalf("Expected runmqsc to exit with rc=0, got %v with error %v", rc, r.FindString(mqscOutput))
|
t.Fatalf("Expected runmqsc to exit with rc=0, got %v with error %v", rc, r.FindString(mqscOutput))
|
||||||
@@ -628,7 +637,15 @@ func TestLargeMQSC(t *testing.T) {
|
|||||||
defer cleanContainer(t, cli, id)
|
defer cleanContainer(t, cli, id)
|
||||||
waitForReady(t, cli, id)
|
waitForReady(t, cli, id)
|
||||||
|
|
||||||
rc, mqscOutput := execContainer(t, cli, id, "", []string{"bash", "-c", "echo 'DISPLAY QLOCAL(test" + strconv.Itoa(numQueues) + ")' | runmqsc"})
|
rc := -1
|
||||||
|
mqscOutput := ""
|
||||||
|
for i := 0; i < 60; i++ {
|
||||||
|
rc, mqscOutput = execContainer(t, cli, id, "", []string{"bash", "-c", "echo 'DISPLAY QLOCAL(test" + strconv.Itoa(numQueues) + ")' | runmqsc"})
|
||||||
|
if rc == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
if rc != 0 {
|
if rc != 0 {
|
||||||
r := regexp.MustCompile("AMQ[0-9][0-9][0-9][0-9]E")
|
r := regexp.MustCompile("AMQ[0-9][0-9][0-9][0-9]E")
|
||||||
t.Fatalf("Expected runmqsc to exit with rc=0, got %v with error %v", rc, r.FindString(mqscOutput))
|
t.Fatalf("Expected runmqsc to exit with rc=0, got %v with error %v", rc, r.FindString(mqscOutput))
|
||||||
@@ -1045,10 +1062,17 @@ func TestReadiness(t *testing.T) {
|
|||||||
t.Log(mqsc)
|
t.Log(mqsc)
|
||||||
for {
|
for {
|
||||||
readyRC, _ := execContainer(t, cli, id, "", []string{"chkmqready"})
|
readyRC, _ := execContainer(t, cli, id, "", []string{"chkmqready"})
|
||||||
queueCheckRC, queueCheckOut := execContainer(t, cli, id, "", []string{"bash", "-c", queueCheckCommand})
|
|
||||||
t.Logf("readyRC=%v,queueCheckRC=%v\n", readyRC, queueCheckRC)
|
|
||||||
|
|
||||||
if readyRC == 0 {
|
if readyRC == 0 {
|
||||||
|
queueCheckRC := -1
|
||||||
|
queueCheckOut := ""
|
||||||
|
for i := 1; i < 60; i++ {
|
||||||
|
queueCheckRC, queueCheckOut = execContainer(t, cli, id, "", []string{"bash", "-c", queueCheckCommand})
|
||||||
|
t.Logf("readyRC=%v,queueCheckRC=%v\n", readyRC, queueCheckRC)
|
||||||
|
if queueCheckRC == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
if queueCheckRC != 0 {
|
if queueCheckRC != 0 {
|
||||||
r := regexp.MustCompile("AMQ[0-9][0-9][0-9][0-9]E")
|
r := regexp.MustCompile("AMQ[0-9][0-9][0-9][0-9]E")
|
||||||
t.Fatalf("Runmqsc returned %v with error %v. chkmqready returned %v when MQSC had not finished", queueCheckRC, r.FindString(queueCheckOut), readyRC)
|
t.Fatalf("Runmqsc returned %v with error %v. chkmqready returned %v when MQSC had not finished", queueCheckRC, r.FindString(queueCheckOut), readyRC)
|
||||||
|
|||||||
Reference in New Issue
Block a user