Add logic to set custom Log File Page number (#371)
* Add logic to set custom Log File Page number Signed-off-by: Nicholas-Daffern <Nicholas.Daffern@ibm.com>
This commit is contained in:
committed by
GitHub Enterprise
parent
862427306b
commit
ed618dc6f6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2017, 2022
|
||||
© Copyright IBM Corporation 2017, 2023
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -77,45 +77,20 @@ func TestLicenseView(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Start a container with qm grace set to x seconds
|
||||
// Check that when the container is stopped that the command endmqm has option -tp and x
|
||||
func TestEndMQMOpts(t *testing.T) {
|
||||
t.Parallel()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
containerConfig := container.Config{
|
||||
Env: []string{"LICENSE=accept", "MQ_GRACE_PERIOD=27"},
|
||||
}
|
||||
|
||||
id := runContainer(t, cli, &containerConfig)
|
||||
defer cleanContainer(t, cli, id)
|
||||
waitForReady(t, cli, id)
|
||||
killContainer(t, cli, id, "SIGTERM")
|
||||
_, out := execContainer(t, cli, id, "", []string{"bash", "-c", "ps -ef | grep 'endmqm -w -r -tp 27'"})
|
||||
t.Log(out)
|
||||
if !strings.Contains(out, "endmqm -w -r -tp 27") {
|
||||
t.Errorf("Expected endmqm options endmqm -w -r -tp 27; got \"%v\"", out)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGoldenPath starts a queue manager successfully when metrics are enabled
|
||||
func TestGoldenPathWithMetrics(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
goldenPath(t, true)
|
||||
}
|
||||
|
||||
// TestGoldenPath starts a queue manager successfully when metrics are disabled
|
||||
func TestGoldenPathNoMetrics(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
goldenPath(t, false)
|
||||
}
|
||||
|
||||
// Actual test function for TestGoldenPathNoMetrics & TestGoldenPathWithMetrics
|
||||
func goldenPath(t *testing.T, metric bool) {
|
||||
func goldenPath(t *testing.T, metrics bool) {
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -123,13 +98,17 @@ func goldenPath(t *testing.T, metric bool) {
|
||||
containerConfig := container.Config{
|
||||
Env: []string{"LICENSE=accept", "MQ_QMGR_NAME=qm1"},
|
||||
}
|
||||
if metric {
|
||||
if metrics {
|
||||
containerConfig.Env = append(containerConfig.Env, "MQ_ENABLE_METRICS=true")
|
||||
}
|
||||
|
||||
id := runContainer(t, cli, &containerConfig)
|
||||
defer cleanContainer(t, cli, id)
|
||||
waitForReady(t, cli, id)
|
||||
|
||||
t.Run("Validate Default LogFilePages", func(t *testing.T) {
|
||||
testLogFilePages(t, cli, id, "qm1", "4096")
|
||||
})
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, id)
|
||||
}
|
||||
@@ -1482,3 +1461,45 @@ func TestStartedCheckWithNoNewPrivileges(t *testing.T) {
|
||||
func TestStartedCheckWithNewPrivileges(t *testing.T) {
|
||||
utilTestStartedCheck(t, false)
|
||||
}
|
||||
|
||||
// Start a container with qm grace set to x seconds
|
||||
// Check that when the container is stopped that the command endmqm has option -tp and x
|
||||
func TestEndMQMOpts(t *testing.T) {
|
||||
t.Parallel()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
containerConfig := container.Config{
|
||||
Env: []string{"LICENSE=accept", "MQ_GRACE_PERIOD=27"},
|
||||
}
|
||||
|
||||
id := runContainer(t, cli, &containerConfig)
|
||||
defer cleanContainer(t, cli, id)
|
||||
waitForReady(t, cli, id)
|
||||
killContainer(t, cli, id, "SIGTERM")
|
||||
_, out := execContainer(t, cli, id, "", []string{"bash", "-c", "ps -ef | grep 'endmqm -w -r -tp 27'"})
|
||||
t.Log(out)
|
||||
if !strings.Contains(out, "endmqm -w -r -tp 27") {
|
||||
t.Errorf("Expected endmqm options endmqm -w -r -tp 27; got \"%v\"", out)
|
||||
}
|
||||
}
|
||||
|
||||
//TestCustomLogFilePages starts a qmgr with a custom number of logfilepages set.
|
||||
//Check that the number of logfilepages matches.
|
||||
func TestCustomLogFilePages(t *testing.T) {
|
||||
t.Parallel()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
containerConfig := container.Config{
|
||||
Env: []string{"LICENSE=accept", "MQ_QMGR_LOG_FILE_PAGES=8192", "MQ_QMGR_NAME=qmlfp"},
|
||||
}
|
||||
|
||||
id := runContainer(t, cli, &containerConfig)
|
||||
defer cleanContainer(t, cli, id)
|
||||
waitForReady(t, cli, id)
|
||||
|
||||
testLogFilePages(t, cli, id, "qmlfp", "8192")
|
||||
}
|
||||
|
||||
@@ -928,3 +928,13 @@ func startContainerError(t *testing.T, cli *client.Client, ID string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//testLogFilePages validates that the specified number of logFilePages is present in the qm.ini file.
|
||||
func testLogFilePages(t *testing.T, cli *client.Client, id string, qmName string, expectedLogFilePages string) {
|
||||
catIniFileCommand := fmt.Sprintf("cat /var/mqm/qmgrs/" + qmName + "/qm.ini")
|
||||
_, iniContent := execContainer(t, cli, id, "", []string{"bash", "-c", catIniFileCommand})
|
||||
|
||||
if !strings.Contains(iniContent, "LogFilePages="+expectedLogFilePages) {
|
||||
t.Errorf("Expected qm.ini to contain LogFilePages="+expectedLogFilePages+"; got qm.ini \"%v\"", iniContent)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user