Skip to content

Commit

Permalink
Adding coverage and test for travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Apr 9, 2020
1 parent b53a952 commit cd39ccf
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
31 changes: 31 additions & 0 deletions install/CI/coverage
Original file line number Diff line number Diff line change
@@ -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
64 changes: 64 additions & 0 deletions install/CI/test
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cd39ccf

Please sign in to comment.