Skip to content

Commit 8d16434

Browse files
committed
Merge branch 'private-master' into UserExternal
2 parents f39f907 + 94ad666 commit 8d16434

File tree

14 files changed

+250
-39
lines changed

14 files changed

+250
-39
lines changed

.travis.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Temporarily removing dist tag as not supported by power build
16-
# dist: xenial
17-
15+
dist: xenial
1816
sudo: required
1917
language: go
18+
group: xeniallegacy
2019

2120
go:
2221
- "1.13.15"
2322

2423
services:
2524
- docker
2625

26+
env:
27+
global:
28+
- MAIN_BRANCH=private-master
29+
- MQ_LTS_VERSION=9.2.0.1
30+
- TAGCACHE_FILE=tagcache
31+
2732
go_import_path: "github.com/ibm-messaging/mq-container"
2833

2934
# cache:
@@ -39,6 +44,9 @@ jobs:
3944
env:
4045
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_920_ARCHIVE_REPOSITORY_DEV_AMD64
4146
script: bash -e travis-build-scripts/run.sh
47+
48+
# CD Build
49+
4250
- stage: global-tag
4351
if: branch = private-master AND type != pull_request OR tag =~ ^release-candidate*
4452
name: "Generate Global Tag"
@@ -80,6 +88,49 @@ jobs:
8088
env:
8189
- PUSH_MANIFEST_ONLY=true
8290
script: bash -e travis-build-scripts/run.sh
91+
92+
# LTS Build
93+
94+
- stage: global-tag
95+
if: branch = private-master AND type != pull_request OR tag =~ ^release-candidate*
96+
name: "Generate Global Tag"
97+
os: linux
98+
env:
99+
- LTS=true
100+
- TAGCACHE_FILE=tagcache-lts
101+
- MQ_VERSION=$MQ_LTS_VERSION
102+
script: bash -e travis-build-scripts/global-tag.sh
103+
- stage: build
104+
if: branch = private-master OR tag =~ ^release-candidate*
105+
name: "Multi-Arch AMD64 build"
106+
os: linux
107+
env:
108+
- LTS=true
109+
- TAGCACHE_FILE=tagcache-lts
110+
- MQ_VERSION=$MQ_LTS_VERSION
111+
- MQ_ARCHIVE_REPOSITORY=$MQ_9201_EUS_ARCHIVE_REPOSITORY_AMD64
112+
script: bash -e travis-build-scripts/run.sh
113+
- stage: build
114+
if: branch = private-master OR tag =~ ^release-candidate*
115+
name: "Multi-Arch S390X build"
116+
os: linux-s390
117+
env:
118+
- LTS=true
119+
- TAGCACHE_FILE=tagcache-lts
120+
- MQ_VERSION=$MQ_LTS_VERSION
121+
- TEST_OPTS_DOCKER="-run TestGoldenPathWithMetrics"
122+
- MQ_ARCHIVE_REPOSITORY=$MQ_9201_EUS_ARCHIVE_REPOSITORY_S390X
123+
script: bash -e travis-build-scripts/run.sh
124+
- stage: push-manifest
125+
if: branch = private-master AND type != pull_request OR tag =~ ^release-candidate*
126+
name: "Push Manifest-list to registry"
127+
env:
128+
- LTS=true
129+
- TAGCACHE_FILE=tagcache-lts
130+
- MQ_VERSION=$MQ_LTS_VERSION
131+
- PUSH_MANIFEST_ONLY=true
132+
script: bash -e travis-build-scripts/run.sh
133+
83134
before_install:
84135
- make install-build-deps
85136
- make install-credential-helper
@@ -91,6 +142,3 @@ before_script: echo nothing
91142

92143
after_success:
93144
- make lint
94-
95-
after_failure:
96-
- ./travis-build-scripts/cleanup-cache.sh

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change log
22

3+
## 9.2.0.1-LTS (2020-12-04)
4+
5+
* Added support for MQ Long Term Support (production licensed only) in the mq-container
6+
37
## 9.2.0.0 (2020-07-23)
48

59
* Updated to [MQ version 9.2.0.0](https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.2.0/com.ibm.mq.pro.doc/q113110_.htm)

Dockerfile-server

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ COPY pkg/ ./pkg
4141
COPY vendor/ ./vendor
4242
ENV CGO_CFLAGS="-I/opt/mqm/inc/" \
4343
CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
44+
ENV PATH="${PATH}:/opt/mqm/bin"
4445
RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\" -X \"main.ImageTag=$IMAGE_TAG\"" ./cmd/runmqserver/
4546
RUN go build ./cmd/chkmqready/
4647
RUN go build ./cmd/chkmqhealthy/

Makefile

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ TEST_OPTS_DOCKER ?=
4545
MQ_IMAGE_ADVANCEDSERVER ?=ibm-mqadvanced-server
4646
# MQ_IMAGE_DEVSERVER is the name of the built MQ Advanced for Developers image
4747
MQ_IMAGE_DEVSERVER ?=ibm-mqadvanced-server-dev
48+
# MQ_MANIFEST_TAG is the tag to use for fat-manifest
49+
MQ_MANIFEST_TAG ?= $(MQ_VERSION)$(LTS_TAG)
4850
# MQ_TAG is the tag of the built MQ Advanced image & MQ Advanced for Developers image
49-
MQ_TAG ?=$(MQ_VERSION)-$(ARCH)
51+
MQ_TAG ?= $(MQ_MANIFEST_TAG)-$(ARCH)
5052
# COMMAND is the container command to run. "podman" or "docker"
5153
COMMAND ?=$(shell type -p podman 2>&1 >/dev/null && echo podman || echo docker)
5254
# MQ_DELIVERY_REGISTRY_HOSTNAME is a remote registry to push the MQ Image to (if required)
@@ -63,8 +65,8 @@ REGISTRY_USER ?=
6365
REGISTRY_PASS ?=
6466
# ARCH is the platform architecture (e.g. amd64, ppc64le or s390x)
6567
ARCH ?= $(if $(findstring x86_64,$(shell uname -m)),amd64,$(shell uname -m))
66-
# Tag to use for fat-manifest
67-
MQ_MANIFEST_TAG=$(MQ_VERSION)
68+
# LTS is a boolean value to enable/disable LTS container build
69+
LTS ?= false
6870

6971
###############################################################################
7072
# Other variables
@@ -109,6 +111,22 @@ else ifeq "$(ARCH)" "s390x"
109111
MQ_ARCHIVE_ARCH=S390X
110112
endif
111113

114+
# LTS_TAG is the tag modifier for an LTS container build
115+
LTS_TAG=
116+
ifeq "$(LTS)" "true"
117+
ifneq "$(LTS_TAG_OVERRIDE)" "$(EMPTY)"
118+
LTS_TAG=$(LTS_TAG_OVERRIDE)
119+
else
120+
LTS_TAG=-lts
121+
endif
122+
MQ_ARCHIVE:=$(MQ_VERSION)-IBM-MQ-Advanced-Non-Install-Linux$(MQ_ARCHIVE_ARCH).tar.gz
123+
MQ_DELIVERY_REGISTRY_NAMESPACE:=$(MQ_DELIVERY_REGISTRY_NAMESPACE)$(LTS_TAG)
124+
endif
125+
126+
ifneq (,$(findstring release-candidate,$(TRAVIS_TAG)))
127+
MQ_DELIVERY_REGISTRY_NAMESPACE=release-candidates
128+
endif
129+
112130
ifneq "$(MQ_DELIVERY_REGISTRY_NAMESPACE)" "$(EMPTY)"
113131
MQ_DELIVERY_REGISTRY_FULL_PATH=$(MQ_DELIVERY_REGISTRY_HOSTNAME)/$(MQ_DELIVERY_REGISTRY_NAMESPACE)
114132
else
@@ -119,7 +137,7 @@ endif
119137

120138
ifneq "$(RELEASE)" "$(EMPTY)"
121139
EXTRA_LABELS=--label release=$(RELEASE)
122-
MQ_MANIFEST_TAG=$(MQ_VERSION)-$(RELEASE)-$(RELEASE_CANDIDATE)
140+
MQ_MANIFEST_TAG=$(MQ_VERSION)-$(RELEASE)$(LTS_TAG)-$(RELEASE_CANDIDATE)
123141
MQ_TAG=$(MQ_MANIFEST_TAG)-$(ARCH)
124142
endif
125143

@@ -131,9 +149,10 @@ ifeq "$(GIT_COMMIT)" "$(EMPTY)"
131149
GIT_COMMIT=$(shell git rev-parse --short HEAD)
132150
endif
133151

134-
ifeq ($(shell [ ! -z $(TRAVIS) ] && [ "$(TRAVIS_PULL_REQUEST)" = "false" ] && [ "$(TRAVIS_BRANCH)" = "private-master" ] && echo true), true)
135-
RELEASE_TAG=$(shell [ -z "$(RELEASE)" ] || echo "-$(RELEASE)-$(RELEASE_CANDIDATE)")
136-
MQ_MANIFEST_TAG=$(MQ_VERSION)$(RELEASE_TAG).$(TIMESTAMPFLAT).$(GIT_COMMIT)
152+
ifeq ($(shell [ ! -z $(TRAVIS) ] && [ "$(TRAVIS_PULL_REQUEST)" = "false" ] && [ "$(TRAVIS_BRANCH)" = "$(MAIN_BRANCH)" ] && echo true), true)
153+
RELEASE_TAG=$(shell [ -z "$(RELEASE)" ] || echo "-$(RELEASE)")
154+
RELEASE_CANDIDATE_TAG=$(shell [ -z "$(RELEASE_CANDIDATE)" ] || echo "-$(RELEASE_CANDIDATE)")
155+
MQ_MANIFEST_TAG=$(MQ_VERSION)$(RELEASE_TAG)$(LTS_TAG).$(TIMESTAMPFLAT).$(GIT_COMMIT)$(RELEASE_CANDIDATE_TAG)
137156
MQ_TAG=$(MQ_MANIFEST_TAG)-$(ARCH)
138157
endif
139158

@@ -205,9 +224,9 @@ downloads: downloads/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE)
205224

206225
.PHONY: cache-mq-tag
207226
cache-mq-tag:
208-
@$(shell printf "MQ_MANIFEST_TAG_CACHED=$(MQ_MANIFEST_TAG)\n" > $(PATH_TO_MQ_TAG_CACHE))
209-
@$(shell printf "MQ_TAG_CACHED_amd64=$(MQ_MANIFEST_TAG)-amd64\n" >> $(PATH_TO_MQ_TAG_CACHE))
210-
@$(shell printf "MQ_TAG_CACHED_s390x=$(MQ_MANIFEST_TAG)-s390x\n" >> $(PATH_TO_MQ_TAG_CACHE))
227+
@printf "MQ_MANIFEST_TAG_CACHED=$(MQ_MANIFEST_TAG)\n" | tee $(PATH_TO_MQ_TAG_CACHE)
228+
@printf "MQ_TAG_CACHED_amd64=$(MQ_MANIFEST_TAG)-amd64\n" | tee -a $(PATH_TO_MQ_TAG_CACHE)
229+
@printf "MQ_TAG_CACHED_s390x=$(MQ_MANIFEST_TAG)-s390x\n" | tee -a $(PATH_TO_MQ_TAG_CACHE)
211230

212231
# Vendor Go dependencies for the Docker tests
213232
test/docker/vendor:
@@ -398,16 +417,20 @@ pull-devserver:
398417
.PHONY: push-manifest
399418
push-manifest: build-skopeo-container
400419
$(info $(SPACER)$(shell printf $(TITLE)"** Determining the image digests **"$(END)))
420+
ifneq "$(LTS)" "true"
401421
$(eval MQ_IMAGE_DEVSERVER_AMD64_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux --override-arch s390x inspect --creds $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) docker://$(MQ_IMAGE_DEVSERVER_AMD64) | jq -r .Digest))
402422
$(eval MQ_IMAGE_DEVSERVER_S390X_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) docker://$(MQ_IMAGE_DEVSERVER_S390X) | jq -r .Digest))
403-
$(eval MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) docker://$(MQ_IMAGE_ADVANCEDSERVER_AMD64) | jq -r .Digest))
404-
$(eval MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) docker://$(MQ_IMAGE_ADVANCEDSERVER_S390X) | jq -r .Digest))
405423
$(info $(shell printf "** Determined the built $(MQ_IMAGE_DEVSERVER_AMD64) has a digest of $(MQ_IMAGE_DEVSERVER_AMD64_DIGEST)**"$(END)))
406424
$(info $(shell printf "** Determined the built $(MQ_IMAGE_DEVSERVER_S390X) has a digest of $(MQ_IMAGE_DEVSERVER_S390X_DIGEST)**"$(END)))
425+
endif
426+
$(eval MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) docker://$(MQ_IMAGE_ADVANCEDSERVER_AMD64) | jq -r .Digest))
427+
$(eval MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_ARCHIVE_REPOSITORY_USER):$(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) docker://$(MQ_IMAGE_ADVANCEDSERVER_S390X) | jq -r .Digest))
407428
$(info $(shell printf "** Determined the built $(MQ_IMAGE_ADVANCEDSERVER_AMD64) has a digest of $(MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST)**"$(END)))
408429
$(info $(shell printf "** Determined the built $(MQ_IMAGE_ADVANCEDSERVER_S390X) has a digest of $(MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST)**"$(END)))
430+
ifneq "$(LTS)" "true"
409431
$(info $(shell printf "** Calling script to create fat-manifest for $(MQ_IMAGE_DEVSERVER_MANIFEST)**"$(END)))
410432
echo $(shell ./travis-build-scripts/create-manifest-list.sh -r $(MQ_DELIVERY_REGISTRY_HOSTNAME) -n $(MQ_DELIVERY_REGISTRY_NAMESPACE) -i $(MQ_IMAGE_DEVSERVER) -t $(MQ_MANIFEST_TAG_CACHED) -u $(MQ_ARCHIVE_REPOSITORY_USER) -p $(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) -d "$(MQ_IMAGE_DEVSERVER_AMD64_DIGEST) $(MQ_IMAGE_DEVSERVER_S390X_DIGEST)" $(END))
433+
endif
411434
$(info $(shell printf "** Calling script to create fat-manifest for $(MQ_IMAGE_ADVANCEDSERVER_MANIFEST)**"$(END)))
412435
echo $(shell ./travis-build-scripts/create-manifest-list.sh -r $(MQ_DELIVERY_REGISTRY_HOSTNAME) -n $(MQ_DELIVERY_REGISTRY_NAMESPACE) -i $(MQ_IMAGE_ADVANCEDSERVER) -t $(MQ_MANIFEST_TAG_CACHED) -u $(MQ_ARCHIVE_REPOSITORY_USER) -p $(MQ_ARCHIVE_REPOSITORY_CREDENTIAL) -d "$(MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST) $(MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST)" $(END))
413436

cmd/runmqserver/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"strings"
2121

2222
"github.com/ibm-messaging/mq-container/internal/command"
23+
"github.com/ibm-messaging/mq-container/internal/mqversion"
2324
)
2425

2526
var (
@@ -50,7 +51,7 @@ func logImageTag() {
5051
}
5152

5253
func logMQVersion() {
53-
mqVersion, _, err := command.Run("dspmqver", "-b", "-f", "2")
54+
mqVersion, err := mqversion.Get()
5455
if err != nil {
5556
log.Printf("Error Getting MQ version: %v", strings.TrimSuffix(string(mqVersion), "\n"))
5657
}

config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###########################################################################################################################################################
22

33
# MQ_VERSION is the fully qualified MQ version number to build
4-
MQ_VERSION=9.2.0.0
4+
MQ_VERSION ?= 9.2.0.0
55

66
###########################################################################################################################################################

docs/building.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,42 @@ You will also need a [Red Hat Account](https://access.redhat.com) to be able to
1313

1414
## Building a production image
1515

16+
From MQ 9.2.X, the MQ container adds support for MQ Long Term Support (LTS) **production licensed** releases.
17+
18+
### MQ Continuous Delivery (CD)
19+
1620
This procedure works for building the MQ Continuous Delivery release, on `amd64`, `ppc64le` and `s390x` architectures.
1721

1822
1. Create a `downloads` directory in the root of this repository
1923
2. Download MQ from [IBM Passport Advantage](https://www.ibm.com/software/passportadvantage/) or [IBM Fix Central](https://www.ibm.com/support/fixcentral), and place the downloaded file (for example, `IBM_MQ_9.2.0_LINUX_X86-64_NOINST.tar.gz`) in the `downloads` directory
2024
3. Login to the Red Hat Registry: `docker login registry.redhat.io` using your Customer Portal credentials.
2125
4. Run `make build-advancedserver`
2226

23-
> **Warning**: Note that from MQ 9.2.X, the MQ container build uses a 'No-Install' MQ Package, available under `IBM MQ V9.2.x Continuous Delivery Release components eAssembly, part no. CJ7CNML`
27+
> **Warning**: Note that from MQ 9.2.X CD, the MQ container build uses a 'No-Install' MQ Package, available under `IBM MQ V9.2.x Continuous Delivery Release components eAssembly, part no. CJ7CNML`
2428
2529
If you have an MQ archive file with a different file name, you can specify a particular file (which must be in the `downloads` directory). You should also specify the MQ version, so that the resulting image is tagged correctly, for example:
2630

2731
```bash
2832
MQ_ARCHIVE=mq-1.2.3.4.tar.gz MQ_VERSION=1.2.3.4 make build-advancedserver
2933
```
3034

35+
### MQ Long Term Support (LTS)
36+
37+
This procedure works for building the MQ Long Term Support release, on `amd64`, `ppc64le` and `s390x` architectures.
38+
39+
1. Create a `downloads` directory in the root of this repository
40+
2. Download MQ from [IBM Passport Advantage](https://www.ibm.com/software/passportadvantage/) or [IBM Fix Central](https://www.ibm.com/support/fixcentral), and place the downloaded file (for example, `9.2.0.1-IBM-MQ-Advanced-Non-Install-LinuxX86.tar.gz`) in the `downloads` directory
41+
3. Login to the Red Hat Registry: `docker login registry.redhat.io` using your Customer Portal credentials.
42+
4. Run `LTS=true make build-advancedserver`
43+
44+
> **Warning**: Note that from MQ 9.2 LTS, the MQ container build uses a 'No-Install' MQ Package, available under `IBM MQ V9.2 Long Term Support Release components eAssembly, part no. CXXXXXX`
45+
46+
If you have an MQ archive file with a different file name, you can specify a particular file (which must be in the `downloads` directory). You should also specify the MQ version, so that the resulting image is tagged correctly, for example:
47+
48+
```bash
49+
MQ_ARCHIVE=mq-1.2.3.4.tar.gz MQ_VERSION=1.2.3.4 LTS=true make build-advancedserver
50+
```
51+
3152
## Building a developer image
3253

3354
Login to the Red Hat Registry: `docker login registry.redhat.io` using your Customer Portal credentials.

internal/mqversion/mqversion.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
© Copyright IBM Corporation 2020
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package mqversion
18+
19+
import (
20+
"fmt"
21+
"strings"
22+
23+
"github.com/ibm-messaging/mq-container/internal/command"
24+
)
25+
26+
// Get will return the current MQ version
27+
func Get() (string, error) {
28+
mqVersion, _, err := command.Run("dspmqver", "-b", "-f", "2")
29+
if err != nil {
30+
return "", fmt.Errorf("Error Getting MQ version: %v", err)
31+
}
32+
return strings.TrimSpace(mqVersion), nil
33+
}
34+
35+
// Compare returns an integer comparing two MQ version strings lexicographically. The result will be 0 if currentVersion==checkVersion, -1 if currentVersion < checkVersion, and +1 if currentVersion > checkVersion
36+
func Compare(checkVersion string) (int, error) {
37+
currentVersion, err := Get()
38+
if err != nil {
39+
return 0, err
40+
}
41+
// trim any suffix from MQ version x.x.x.x
42+
currentVersion = currentVersion[0:7]
43+
if currentVersion < checkVersion {
44+
return -1, nil
45+
} else if currentVersion == checkVersion {
46+
return 0, nil
47+
} else if currentVersion > checkVersion {
48+
return 1, nil
49+
}
50+
return 0, fmt.Errorf("Failed to compare MQ versions")
51+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
© Copyright IBM Corporation 2020
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package mqversion
18+
19+
import "testing"
20+
21+
func TestCompareLower(t *testing.T) {
22+
checkVersion := "9.9.9.9"
23+
mqVersionCheck, err := Compare(checkVersion)
24+
if err != nil {
25+
t.Fatalf("Failed to compare MQ versions: %v", err)
26+
}
27+
if mqVersionCheck != -1 {
28+
t.Errorf("MQ version compare result failed. Expected -1, Got %v", mqVersionCheck)
29+
}
30+
}
31+
32+
func TestCompareHigher(t *testing.T) {
33+
checkVersion := "1.1.1.1"
34+
mqVersionCheck, err := Compare(checkVersion)
35+
if err != nil {
36+
t.Fatalf("Failed to compare MQ versions: %v", err)
37+
}
38+
if mqVersionCheck != 1 {
39+
t.Errorf("MQ version compare result failed. Expected 1, Got %v", mqVersionCheck)
40+
}
41+
}
42+
43+
func TestCompareEqual(t *testing.T) {
44+
checkVersion, err := Get()
45+
if err != nil {
46+
t.Fatalf("Failed to get current MQ version: %v", err)
47+
}
48+
mqVersionCheck, err := Compare(checkVersion)
49+
if err != nil {
50+
t.Fatalf("Failed to compare MQ versions: %v", err)
51+
}
52+
if mqVersionCheck != 0 {
53+
t.Errorf("MQ version compare result failed. Expected 0, Got %v", mqVersionCheck)
54+
}
55+
}

0 commit comments

Comments
 (0)