Skip to content

Commit

Permalink
Merge pull request #977 from satya-gorli/opensdsCI
Browse files Browse the repository at this point in the history
CI Files for UT, IT and E2E Test
  • Loading branch information
skdwriting committed Aug 14, 2019
2 parents a9aba69 + dc8bd04 commit fdb32c2
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 4 deletions.
19 changes: 16 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ matrix:
fast_finish: true
allow_failures:
- go: tip
- script: osds_verify
- script: osds_e2etest_build
exclude:
# - go: tip
# env: TARGET=arm
Expand All @@ -44,9 +46,20 @@ install:
# Build OpenSDS Controller source code
- make all

script:
- ./install/CI/coverage
- ./install/CI/test

jobs:
include:
- stage: "Test Jobs" # naming the Tests stage
script: make
name: "builds osds core components" # names the first Tests stage job
- script: make osds_verify
name: "verify osds" # names the second Tests stage job
- script: make osds_unit_test
name: "unit test opensds" # names the third Tests stage job
- script: make osds_integration_test
name: "integration test opensds" # names the fourth Tests stage job
- script: make osds_e2etest_build
name: "e2e_test" # names the fifth Tests stage job

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,30 @@ docker: build
docker build cmd/osdslet -t opensdsio/opensds-controller:$(DOCKER_TAG)
docker build cmd/osdsapiserver -t opensdsio/opensds-apiserver:$(DOCKER_TAG)

test: build
test: build #osds_verify osds_unit_test osds_integration_test osds_e2eflowtest_build osds_e2etest_build
install/CI/test
# make osds_core
.PHONY: osds_core
osds_core:
cd osds && $(MAKE)

# unit tests
.PHONY: osds_unit_test
osds_unit_test:
cd osds && $(MAKE) unit_test

# verify
.PHONY: osds_verify
osds_verify:
cd osds && $(MAKE) verify

.PHONY: osds_integration_test
osds_integration_test:
cd osds && $(MAKE) integration_test

.PHONY: osds_e2etest_build
osds_e2etest_build:
cd osds && $(MAKE) e2etest_build

protoc_precheck:
@if ! which protoc >/dev/null; then\
Expand Down
45 changes: 45 additions & 0 deletions osds/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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.

#unit tests
.PHONY: unit_test
ifeq ($(WHAT),)
TEST_DIR="./pkg/"
else
TEST_DIR=${WHAT}
endif

export GOARCHAIUS_CONFIG_PATH=$(CURDIR)
test:
find ${TEST_DIR} -name "*_test.go"|xargs -i dirname {}|uniq|xargs -i go test ${T} {}
# verify
.PHONY: verify
verify:
bash -x ./verify.sh

.PHONY: unit_test
unit_test:
bash -x ./../test/unittest/unittest.sh

.PHONY: integration_test
integration_test:
#ash test/integration/scripts/execute.sh
bash -x ./../test/integration/integrationtest.sh
.PHONY: e2etest_build
e2etest_build:
bash -x ./../test/e2e/e2etest.sh

.PHONY: clean
clean:
bash -x hack/clean.sh
35 changes: 35 additions & 0 deletions osds/update-gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env 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
set -o nounset
set -o pipefail

ROOTDIR=$( cd "$(dirname "$0")" ; pwd -P )/..

cd "$ROOTDIR"

# The files or packagess we should update gofmt.
find_files() {
find . -not \( \
\( \
-wholename './.git' \
-o -wholename '*/vendor/*' \
\) -prune \
\) -name '*.go'
}

find_files | xargs gofmt -s -w
29 changes: 29 additions & 0 deletions osds/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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.

if ! [ -f "./bin/gometalinter" ]; then echo "Download The files";
curl -L https://git.io/vp6lP | sh
fi
export PATH=${PATH}:${GOPATH}/bin:${GOPATH}/src/github.com/opensds/opensds/osds/bin
gometalinter --disable-all --enable=gofmt --enable=misspell --enable=golint --exclude=vendor --exclude=test ./../... > golintoutput.txt
if [ $? != 0 ]; then
echo "Please fix the warnings!"
echo "Run ./update-gofmt.sh if any warnings in gofmt"
#exit 1
else
echo "Gofmt,misspell,golint checks have been passed"
fi

39 changes: 39 additions & 0 deletions test/e2e/e2etest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/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 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 e2e test
split_line "Start e2e test"
sudo $OPENSDS_DIR/install/devsds/install.sh
ps -ef|grep osds
go test -v github.com/opensds/opensds/test/e2e/... -tags e2e

# Start e2e flow test
split_line "Start e2e flow test"
go build -o ./test/e2e/volume-connector github.com/opensds/opensds/test/e2e/connector/
go test -v github.com/opensds/opensds/test/e2e/... -tags e2ef
sudo $OPENSDS_DIR/install/devsds/uninstall.sh
36 changes: 36 additions & 0 deletions test/integration/integrationtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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 integration test.
split_line "Start integration test"
sudo $OPENSDS_DIR/test/integration/prepare.sh
go test -v github.com/opensds/opensds/test/integration/... -tags integration
sudo killall -9 osdslet osdsdock
sudo rm /etc/opensds/opensds.conf -rf

44 changes: 44 additions & 0 deletions test/unittest/unittest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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"

wget https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64
chmod +x ./swagger_linux_amd64 && ./swagger_linux_amd64 validate --stop-on-error $OPENSDS_DIR/openapi-spec/swagger.yaml
rm ./swagger_linux_amd64

# Start unit test.
split_line "Start unit test"
go test -v github.com/opensds/opensds/osdsctl/... -cover
go test -v github.com/opensds/opensds/client/... -cover
go test -v github.com/opensds/opensds/pkg/... -cover
go test -v github.com/opensds/opensds/contrib/... -cover

0 comments on commit fdb32c2

Please sign in to comment.