@@ -648,3 +648,119 @@ func TestCorrectLicense(t *testing.T) {
648648 t .Errorf ("Expected license to be '%s' but was '%s" , expectedLicense , license )
649649 }
650650}
651+
652+ func TestVersioning (t * testing.T ) {
653+ t .Parallel ()
654+
655+ cli , err := client .NewEnvClient ()
656+ if err != nil {
657+ t .Fatal (err )
658+ }
659+
660+ containerConfig := container.Config {
661+ Env : []string {"LICENSE=accept" },
662+ }
663+ id := runContainer (t , cli , & containerConfig )
664+ defer cleanContainer (t , cli , id )
665+ waitForReady (t , cli , id )
666+
667+ // Get whole logs and check versioning system
668+ l := inspectLogs (t , cli , id )
669+ scanner := bufio .NewScanner (strings .NewReader (l ))
670+
671+ total := 6
672+ foundCreated := false
673+ foundRevision := false
674+ foundSource := false
675+ foundMQVersion := false
676+ foundMQLevel := false
677+ foundMQLicense := false
678+
679+ for scanner .Scan () {
680+ line := scanner .Text ()
681+ if strings .Contains (line , "Image created:" ) && ! foundCreated {
682+ total --
683+ foundCreated = true
684+ dataAr := strings .Split (line , " " )
685+ data := dataAr [len (dataAr )- 1 ]
686+
687+ // Verify created
688+ _ , err := time .Parse (time .RFC3339 , data )
689+ if err != nil {
690+ t .Errorf ("Failed to validate Image created (%v) - %v" , data , err )
691+ }
692+ }
693+
694+ if strings .Contains (line , "Image revision:" ) && ! foundRevision {
695+ total --
696+ foundRevision = true
697+ dataAr := strings .Split (line , " " )
698+ data := dataAr [len (dataAr )- 1 ]
699+
700+ // Verify revision
701+ pattern := regexp .MustCompile ("^[a-fA-F0-9]{40}$" )
702+ if ! pattern .MatchString (data ) {
703+ t .Errorf ("Failed to validate revision (%v)" , data )
704+ }
705+ }
706+
707+ if strings .Contains (line , "Image source:" ) && ! foundSource {
708+ total --
709+ foundSource = true
710+ dataAr := strings .Split (line , " " )
711+ data := dataAr [len (dataAr )- 1 ]
712+
713+ // Verify source
714+ if ! strings .Contains (data , "github" ) {
715+ t .Errorf ("Failed to validate source (%v)" , data )
716+ }
717+ }
718+
719+ if strings .Contains (line , "MQ version:" ) && ! foundMQVersion {
720+ total --
721+ foundMQVersion = true
722+ dataAr := strings .Split (line , " " )
723+ data := dataAr [len (dataAr )- 1 ]
724+
725+ // Verify MQ version
726+ pattern := regexp .MustCompile ("^\\ d+\\ .\\ d+\\ .\\ d+\\ .\\ d+$" )
727+ if ! pattern .MatchString (data ) {
728+ t .Errorf ("Failed to validate mq version (%v)" , data )
729+ }
730+ }
731+
732+ if strings .Contains (line , "MQ level:" ) && ! foundMQLevel {
733+ total --
734+ foundMQLevel = true
735+ dataAr := strings .Split (line , " " )
736+ data := dataAr [len (dataAr )- 1 ]
737+
738+ // Verify MQ version
739+ pattern := regexp .MustCompile ("^p\\ d{3}-.+$" )
740+ if ! pattern .MatchString (data ) {
741+ t .Errorf ("Failed to validate mq level (%v)" , data )
742+ }
743+ }
744+
745+ if strings .Contains (line , "MQ license:" ) && ! foundMQLicense {
746+ total --
747+ foundMQLicense = true
748+ dataAr := strings .Split (line , " " )
749+ data := dataAr [len (dataAr )- 1 ]
750+
751+ // Verify MQ version
752+ if data != "Developer" && data != "Production" {
753+ t .Errorf ("Failed to validate mq license (%v)" , data )
754+ }
755+ }
756+
757+ // end loop early
758+ if total == 0 {
759+ break
760+ }
761+ }
762+
763+ if ! foundCreated || ! foundRevision || ! foundSource || ! foundMQVersion || ! foundMQLevel || ! foundMQLicense {
764+ t .Errorf ("Failed to find one or more version strings: created(%v) revision(%v) source(%v) mqversion(%v) mqlevel(%v) mqlicense(%v)" , foundCreated , foundRevision , foundSource , foundMQVersion , foundMQLevel , foundMQLicense )
765+ }
766+ }
0 commit comments