SEBA-975 cordctl should work with xos 4.x
Change-Id: Ibd64d9eb4a61bc46ec39e971a71a971a82577e01
diff --git a/VERSION b/VERSION
index 738a839..e25d8d9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.4-dev
+1.1.5
diff --git a/internal/pkg/commands/command.go b/internal/pkg/commands/command.go
index 51f8d01..50a50dc 100644
--- a/internal/pkg/commands/command.go
+++ b/internal/pkg/commands/command.go
@@ -36,8 +36,6 @@
OUTPUT_TABLE OutputType = iota
OUTPUT_JSON
OUTPUT_YAML
-
- CORE_VERSION_CONSTRAINT = ">= 3, < 4" // Support XOS major version 3
)
// Make it easy to override output stream for testing
diff --git a/internal/pkg/commands/common.go b/internal/pkg/commands/common.go
index 4629534..273bd5e 100644
--- a/internal/pkg/commands/common.go
+++ b/internal/pkg/commands/common.go
@@ -108,7 +108,7 @@
return nil, nil, err
}
- constraint, err := versionUtils.NewConstraint(CORE_VERSION_CONSTRAINT)
+ constraint, err := versionUtils.NewConstraint(config.CORE_VERSION_CONSTRAINT)
if err != nil {
return nil, nil, err
}
@@ -117,7 +117,7 @@
return nil, nil, corderrors.WithStackTrace(&corderrors.VersionConstraintError{
Name: "xos-core",
Version: serverVersion.String(),
- Constraint: CORE_VERSION_CONSTRAINT})
+ Constraint: config.CORE_VERSION_CONSTRAINT})
}
}
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 382e0c2..e335bfc 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -34,7 +34,7 @@
OUTPUT_JSON
OUTPUT_YAML
- CORE_VERSION_CONSTRAINT = ">= 3, < 4" // Support XOS major version 3
+ CORE_VERSION_CONSTRAINT = ">= 3, < 5" // Support XOS major versions 3 and 4
)
var CharReplacer = strings.NewReplacer("\\t", "\t", "\\n", "\n")
diff --git a/mock/Dockerfile b/mock/Dockerfile
index 900c825..6fbac5d 100644
--- a/mock/Dockerfile
+++ b/mock/Dockerfile
@@ -18,12 +18,12 @@
FROM xosproject/grpc-mock:1.0.0 as build
MAINTAINER Open Networking Foundation
-RUN apk add --update git python2 py-pip make
+RUN apk add --update git python3 py-pip make
WORKDIR /xos
RUN mkdir /xos/v1
RUN git clone https://github.com/opencord/xos /opt/tmp_xos && mv /opt/tmp_xos/xos /opt/xos && mv /opt/tmp_xos/lib /opt/xos/lib && cp /opt/tmp_xos/VERSION /opt/xos
-RUN cd /opt/xos/lib/xos-genx && python setup.py install
+RUN cd /opt/xos/lib/xos-genx && python3 setup.py install
RUN cd /opt/xos/coreapi/protos && make rebuild-protos
RUN cp -r /opt/xos/coreapi/protos/*.proto /xos/v1
@@ -31,6 +31,21 @@
COPY clean.sh /xos/clean.sh
RUN /xos/clean.sh
+# TODO: Ugly hack to fix xos.proto and utility.proto
+#
+# Something is broken in grpc-mock. It is not processing the import statements
+# in xos.proto or utility.proto that import common.proto and therefore it cannot
+# find the ID and Query messages. Until we understand what is wrong, work around this
+# by stripping off the first four lines of common.proto, and appending it to
+# xos.proto and utility.proto.
+
+WORKDIR /xos/v1
+RUN tail -n +4 common.proto > common.suffix
+RUN mv xos.proto xos.orig && cat xos.orig common.suffix > xos.proto && sed -i '/import.*common.proto/d' xos.proto
+RUN mv utility.proto utility.orig && cat utility.orig common.suffix > utility.proto && sed -i '/import.*common.proto/d' utility.proto
+
+# end Ugly hack to fix xos.proto and utility.proto
+
FROM xosproject/grpc-mock:1.0.0
ENV GRPC_MOCK_COMPARE=sparse
diff --git a/pkg/testutils/testutils.go b/pkg/testutils/testutils.go
index 2f80f79..a026b41 100644
--- a/pkg/testutils/testutils.go
+++ b/pkg/testutils/testutils.go
@@ -16,6 +16,7 @@
package testutils
import (
+ "bytes"
"encoding/json"
"errors"
"fmt"
@@ -28,7 +29,6 @@
const (
CONTAINER_NAME = "xos-mock-grpc-server"
- //MOCK_DIR = "/home/smbaker/projects/gopath/src/github.com/opencord/cordctl/mock"
)
var MockDir = os.Getenv("CORDCTL_MOCK_DIR")
@@ -43,11 +43,18 @@
// `data_name` is the name of the data.json to tell the mock server to use.
// If a mock server is already running with the same data_name, it is not restarted.
func StartMockServer(data_name string) error {
+ var stdout, stderr bytes.Buffer
+
cmd_str := fmt.Sprintf("cd %s && DATA_JSON=%s docker-compose up -d", MockDir, data_name)
cmd := exec.Command("/bin/bash", "-c", cmd_str)
+ cmd.Stdout = &stdout
+ cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
+ // something failed... print the stdout and stderr
+ fmt.Printf("stdout=%s\n", stdout.String())
+ fmt.Printf("stderr=%s\n", stderr.String())
return err
}