@@ -40,6 +40,7 @@ import (
4040
4141func TestLicenseNotSet (t * testing.T ) {
4242 t .Parallel ()
43+
4344 cli , err := client .NewEnvClient ()
4445 if err != nil {
4546 t .Fatal (err )
@@ -56,6 +57,7 @@ func TestLicenseNotSet(t *testing.T) {
5657
5758func TestLicenseView (t * testing.T ) {
5859 t .Parallel ()
60+
5961 cli , err := client .NewEnvClient ()
6062 if err != nil {
6163 t .Fatal (err )
@@ -79,12 +81,14 @@ func TestLicenseView(t *testing.T) {
7981// TestGoldenPath starts a queue manager successfully when metrics are enabled
8082func TestGoldenPathWithMetrics (t * testing.T ) {
8183 t .Parallel ()
84+
8285 goldenPath (t , true )
8386}
8487
8588// TestGoldenPath starts a queue manager successfully when metrics are disabled
8689func TestGoldenPathNoMetrics (t * testing.T ) {
8790 t .Parallel ()
91+
8892 goldenPath (t , false )
8993}
9094
@@ -112,6 +116,7 @@ func goldenPath(t *testing.T, metric bool) {
112116// by Ubuntu
113117func TestSecurityVulnerabilitiesUbuntu (t * testing.T ) {
114118 t .Parallel ()
119+
115120 cli , err := client .NewEnvClient ()
116121 if err != nil {
117122 t .Fatal (err )
@@ -141,6 +146,7 @@ func TestSecurityVulnerabilitiesUbuntu(t *testing.T) {
141146// by Red Hat
142147func TestSecurityVulnerabilitiesRedHat (t * testing.T ) {
143148 t .Parallel ()
149+
144150 cli , err := client .NewEnvClient ()
145151 if err != nil {
146152 t .Fatal (err )
@@ -153,22 +159,25 @@ func TestSecurityVulnerabilitiesRedHat(t *testing.T) {
153159 if rc != 0 {
154160 t .Skip ("Skipping test because container is not RedHat-based" )
155161 }
156- id , _ , err := command .Run ("buildah" , "from" , imageName ())
162+ id , _ , err := command .Run ("sudo" , " buildah" , "from" , imageName ())
157163 if err != nil {
164+ t .Log (id )
158165 t .Fatal (err )
159166 }
160167 id = strings .TrimSpace (id )
161168 defer command .Run ("buildah" , "rm" , id )
162- mnt , _ , err := command .Run ("buildah" , "mount" , id )
169+ mnt , _ , err := command .Run ("sudo" , " buildah" , "mount" , id )
163170 if err != nil {
171+ t .Log (mnt )
164172 t .Fatal (err )
165173 }
166174 mnt = strings .TrimSpace (mnt )
167- _ , _ , err = command .Run ("bash" , "-c" , "cp /etc/yum.repos.d/* " + filepath .Join (mnt , "/etc/yum.repos.d/" ))
175+ out , _ , err : = command .Run ("bash" , "-c" , "sudo cp /etc/yum.repos.d/* " + filepath .Join (mnt , "/etc/yum.repos.d/" ))
168176 if err != nil {
177+ t .Log (out )
169178 t .Fatal (err )
170179 }
171- out , ret , _ : = command .Run ("bash" , "-c" , "yum --installroot=" + mnt + " updateinfo list sec | grep /Sec" )
180+ out , ret , _ = command .Run ("bash" , "-c" , "yum --installroot=" + mnt + " updateinfo list sec | grep /Sec" )
172181 if ret != 1 {
173182 t .Errorf ("Expected no vulnerabilities, found the following:\n %v" , out )
174183 }
@@ -194,25 +203,29 @@ func utilTestNoQueueManagerName(t *testing.T, hostName string, expectedName stri
194203}
195204func TestNoQueueManagerName (t * testing.T ) {
196205 t .Parallel ()
206+
197207 utilTestNoQueueManagerName (t , "test" , "test" )
198208}
199209
200210func TestNoQueueManagerNameInvalidHostname (t * testing.T ) {
201211 t .Parallel ()
212+
202213 utilTestNoQueueManagerName (t , "test-1" , "test1" )
203214}
204215
205216// TestWithVolume runs a container with a Docker volume, then removes that
206217// container and starts a new one with same volume. With metrics enabled
207218func TestWithVolumeAndMetrics (t * testing.T ) {
208219 t .Parallel ()
220+
209221 withVolume (t , true )
210222}
211223
212224// TestWithVolume runs a container with a Docker volume, then removes that
213225// container and starts a new one with same volume. With metrics disabled
214226func TestWithVolumeNoMetrics (t * testing.T ) {
215227 t .Parallel ()
228+
216229 withVolume (t , false )
217230}
218231
@@ -264,6 +277,7 @@ func withVolume(t *testing.T, metric bool) {
264277// and restarted cleanly
265278func TestNoVolumeWithRestart (t * testing.T ) {
266279 t .Parallel ()
280+
267281 cli , err := client .NewEnvClient ()
268282 if err != nil {
269283 t .Fatal (err )
@@ -284,6 +298,7 @@ func TestNoVolumeWithRestart(t *testing.T) {
284298// where `runmqserver -i` is run to initialize the storage. Then the
285299// container can be run as normal.
286300func TestVolumeRequiresRoot (t * testing.T ) {
301+
287302 cli , err := client .NewEnvClient ()
288303 if err != nil {
289304 t .Fatal (err )
@@ -346,6 +361,7 @@ func TestVolumeRequiresRoot(t *testing.T) {
346361// TestCreateQueueManagerFail causes a failure of `crtmqm`
347362func TestCreateQueueManagerFail (t * testing.T ) {
348363 t .Parallel ()
364+
349365 cli , err := client .NewEnvClient ()
350366 if err != nil {
351367 t .Fatal (err )
@@ -380,6 +396,7 @@ func TestCreateQueueManagerFail(t *testing.T) {
380396// TestStartQueueManagerFail causes a failure of `strmqm`
381397func TestStartQueueManagerFail (t * testing.T ) {
382398 t .Parallel ()
399+
383400 cli , err := client .NewEnvClient ()
384401 if err != nil {
385402 t .Fatal (err )
@@ -417,6 +434,7 @@ func TestStartQueueManagerFail(t *testing.T) {
417434// attached storage gets unmounted.
418435func TestVolumeUnmount (t * testing.T ) {
419436 t .Parallel ()
437+
420438 cli , err := client .NewEnvClient ()
421439 if err != nil {
422440 t .Fatal (err )
@@ -465,6 +483,7 @@ func TestVolumeUnmount(t *testing.T) {
465483// created, then checks that no zombies exist (runmqserver should reap them)
466484func TestZombies (t * testing.T ) {
467485 t .Parallel ()
486+
468487 cli , err := client .NewEnvClient ()
469488 if err != nil {
470489 t .Fatal (err )
@@ -501,6 +520,7 @@ func TestZombies(t *testing.T) {
501520// on that image, and checks that the MQSC has been applied correctly.
502521func TestMQSC (t * testing.T ) {
503522 t .Parallel ()
523+
504524 cli , err := client .NewEnvClient ()
505525 if err != nil {
506526 t .Fatal (err )
@@ -575,6 +595,7 @@ func TestMQSC(t *testing.T) {
575595// WARNING: This test is sensitive to the speed of the machine it's running on.
576596func TestReadiness (t * testing.T ) {
577597 t .Parallel ()
598+
578599 cli , err := client .NewEnvClient ()
579600 if err != nil {
580601 t .Fatal (err )
@@ -629,29 +650,42 @@ func TestReadiness(t *testing.T) {
629650
630651func TestErrorLogRotation (t * testing.T ) {
631652 t .Parallel ()
653+
632654 cli , err := client .NewEnvClient ()
633655 if err != nil {
634656 t .Fatal (err )
635657 }
658+
659+ logsize := 65536
660+
661+ rc , _ := runContainerOneShot (t , cli , "bash" , "-c" , "test -d /etc/apt" )
662+ if rc != 0 {
663+ // RHEL
664+ logsize = 32768
665+ }
666+
636667 qmName := "qm1"
637668 containerConfig := container.Config {
638669 Env : []string {
639670 "LICENSE=accept" ,
640671 "MQ_QMGR_NAME=" + qmName ,
641- "MQMAXERRORLOGSIZE=65536" ,
672+ fmt . Sprintf ( "MQMAXERRORLOGSIZE=%d" , logsize ) ,
642673 "LOG_FORMAT=json" ,
674+ fmt .Sprintf ("AMQ_EXTRA_QM_STANZAS=QMErrorLog:ErrorLogSize=%d" , logsize ),
643675 },
644676 ExposedPorts : nat.PortSet {
645677 "1414/tcp" : struct {}{},
646678 },
647679 }
680+
648681 id := runContainer (t , cli , & containerConfig )
649682 defer cleanContainer (t , cli , id )
650683 waitForReady (t , cli , id )
651684 dir := "/var/mqm/qmgrs/" + qmName + "/errors"
652685 // Generate some content for the error logs, by trying to put messages under an unauthorized user
653686 // execContainer(t, cli, id, "fred", []string{"bash", "-c", "for i in {1..30} ; do /opt/mqm/samp/bin/amqsput FAKE; done"})
654687 execContainer (t , cli , id , "root" , []string {"useradd" , "fred" })
688+
655689 for {
656690 execContainer (t , cli , id , "fred" , []string {"bash" , "-c" , "/opt/mqm/samp/bin/amqsput FAKE" })
657691
@@ -694,12 +728,14 @@ func TestErrorLogRotation(t *testing.T) {
694728// Tests the log comes out in JSON format when JSON format is enabled. With metrics enabled
695729func TestJSONLogFormatWithMetrics (t * testing.T ) {
696730 t .Parallel ()
731+
697732 jsonLogFormat (t , true )
698733}
699734
700735// Tests the log comes out in JSON format when JSON format is enabled. With metrics disabled
701736func TestJSONLogFormatNoMetrics (t * testing.T ) {
702737 t .Parallel ()
738+
703739 jsonLogFormat (t , false )
704740}
705741
@@ -740,6 +776,7 @@ func jsonLogFormat(t *testing.T, metric bool) {
740776
741777func TestBadLogFormat (t * testing.T ) {
742778 t .Parallel ()
779+
743780 cli , err := client .NewEnvClient ()
744781 if err != nil {
745782 t .Fatal (err )
0 commit comments