diff --git a/install/CI/coverage b/install/CI/coverage new file mode 100755 index 00000000..7a4027dc --- /dev/null +++ b/install/CI/coverage @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2019 The OpenSDS Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +echo "" > coverage.txt + +MODEL_PACKAGE=github.com/sodafoundation/api/pkg/model +PROTOBUF_PACKAGE=github.com/sodafoundation/api/pkg/model/proto + +for testpkg in $(go list ./osdsctl/... ./client/... ./pkg/... ./contrib/...); do + test $testpkg == "$MODEL_PACKAGE" && continue + test $testpkg == "$PROTOBUF_PACKAGE" && continue + go test -race -covermode=atomic -coverprofile=profile.out "$testpkg" + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done diff --git a/install/CI/test b/install/CI/test new file mode 100755 index 00000000..9c901c2e --- /dev/null +++ b/install/CI/test @@ -0,0 +1,64 @@ +#!/bin/bash + +# Copyright 2019 The OpenSDS Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +# Keep track of the script directory +TOP_DIR=$(cd $(dirname "$0") && pwd) +# OpenSDS Root directory +OPENSDS_DIR=$(cd $TOP_DIR/../.. && pwd) + +split_line(){ + echo "================================================================================================" + echo $* + echo "================================================================================================" +} + +# Start the openapi-spec validation. +split_line "Start openapi spec validation" +output=$(docker run -v $OPENSDS_DIR/openapi-spec/swagger.yaml:/swagger.yaml --rm p1c2u/openapi-spec-validator /swagger.yaml) +if [ "$output" != "OK" ] +then + echo "Faild to validate openapi spec" + exit -1 +else + echo "Openapi spec validation is passed~" +fi + +# Start unit test. +split_line "Start unit test" +go test -v github.com/sodafoundation/api/osdsctl/... -cover +go test -v github.com/sodafoundation/api/client/... -cover +go test -v github.com/sodafoundation/api/pkg/... -cover +go test -v github.com/sodafoundation/api/contrib/... -cover + +# Start integration test. +split_line "Start integration test" +sudo $OPENSDS_DIR/test/integration/prepare.sh +go test -v github.com/sodafoundation/api/test/integration/... -tags integration +sudo killall -9 osdsapiserver osdslet osdsdock +sudo rm /etc/sodafoundation/api.conf -rf + +# Start lvm e2e test +split_line "Start lvm e2e test" +sudo $OPENSDS_DIR/install/devsds/install.sh +ps -ef|grep osds +go test -v github.com/sodafoundation/api/test/e2e/... -tags e2e + +# Start lvm e2e flow test +split_line "Start lvm e2e flow test" +go build -o ./test/e2e/volume-connector github.com/sodafoundation/api/test/e2e/connector/ +go test -v github.com/sodafoundation/api/test/e2e/... -tags e2ef +sudo $OPENSDS_DIR/install/devsds/uninstall.sh