Skip to content

Commit

Permalink
Supplying ssh keys and env variable to container for e2e testing
Browse files Browse the repository at this point in the history
adding missing pkg and sample test file

a minor fix for CI to consume key from correct location

correcting CI faiure

reading SSH_KEY_OPT correctly

code cleanup

restarting CI run

Adding support SSH_KEY_PATH for local test run, no need to set environment vars any more

Adding target for e2e tests (addressing Ritesh's comment)

Fix Admin Cli command to list selected columns for Filesystem Type an… (vmware-archive#845)

* Fix Admin Cli command to list selected columns for Filesystem Type and Disk Format

adding new test target @test-All

adding inline comment

adding test target to drone script (Addressing Ritesh's comment)

testing out CI failure

adding e2e-test target to pick up at CI using drone script
  • Loading branch information
shuklanirdesh82 committed Jan 10, 2017
1 parent 76594b4 commit a88dcd5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion misc/drone-scripts/deploy-and-test-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ log "starting deploy and test"

INCLUDE_HOSTD="false"

if make -s deploy-esx deploy-vm testasroot testremote TEST_VOL_NAME=vol.build$BUILD_NUMBER;
if make -s deploy-esx deploy-vm testasroot e2e-dkrVolDriver-test testremote TEST_VOL_NAME=vol.build$BUILD_NUMBER;
then
echo "=> Build Complete" `date`
#stop_build $VM1 $BUILD_NUMBER
Expand Down
15 changes: 15 additions & 0 deletions misc/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,24 @@ then
$DOCKER run --rm -it -v $PWD/..:$dir -w $dir $pylint_container $MAKE_ESX pylint
else
docker_socket=/var/run/docker.sock
if [ -z $SSH_KEY_OPT ]
then
SSH_KEY_OPT="-i /root/.ssh/id_rsa"
fi
ssh_key_opt_container=`echo $SSH_KEY_OPT | cut -d" " -f2`
ssh_key_path=$SSH_KEY_PATH
if [ -z $ssh_key_path ]
then
ssh_key_path=~/.ssh/id_rsa
fi
$DOCKER run --privileged --rm -it \
-e "PKG_VERSION=$PKG_VERSION" \
-e "INCLUDE_UI=$INCLUDE_UI" \
-e "ESX=$2" \
-e "VM1=$4" \
-e "VM2=$3" \
-e "SSH_KEY_OPT=$SSH_KEY_OPT" \
-v $docker_socket:$docker_socket \
-v $ssh_key_path:$ssh_key_opt_container:ro \
-v $PWD/..:$dir -w $dir $plug_container $MAKE $1
fi
20 changes: 20 additions & 0 deletions vmdk_plugin/E2E_Tests/sample_e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package e2e_test

import "testing"
import "os/exec"
import "fmt"
import "os"
import "strings"

//TODO: This is a sample testcase and will be removed after finishing the review.

func TestSomething(t *testing.T) {
var err error
var out []byte

out, err = exec.Command("/usr/bin/ssh", strings.Split(os.Getenv("SSH_KEY_OPT")," ")[0], strings.Split(os.Getenv("SSH_KEY_OPT")," ")[1], "-q", "-kTax", "-o StrictHostKeyChecking=no", "root@"+os.Getenv("ESX"), "/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py", "ls").CombinedOutput()
fmt.Printf("\nerr=>%s.....\nout=>%s", err, out)

out, err = exec.Command("/usr/bin/ssh", strings.Split(os.Getenv("SSH_KEY_OPT")," ")[0], strings.Split(os.Getenv("SSH_KEY_OPT")," ")[1], "-q", "-kTax", "-o StrictHostKeyChecking=no", "root@"+os.Getenv("VM1"), "ifconfig").CombinedOutput()
fmt.Printf("\nerr=>%s .....\nout=>%s", err, out)
}
18 changes: 14 additions & 4 deletions vmdk_plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ test:
.PHONY: testasroot
testasroot:
$(log_target)
$(GO) test $(PLUGIN)/drivers/vmdk/vmdkops -cover
$(GO) test $(PLUGIN)/utils/config -cover
$(GO) test $(PLUGIN)/drivers/vmdk/vmdkops -cover -v
$(GO) test $(PLUGIN)/utils/config -cover -v

# does sanity check of create/remove docker volume on the guest
TEST_VOL_NAME ?= DefaultTestVol
Expand All @@ -314,7 +314,7 @@ checkremote:
@$(SSH) $(TEST_VM) docker -H $(VM2_DOCKER) ps > /dev/null 2>/dev/null || \
(echo VM2 $(VM2): $(CONN_MSG); exit 1)

.PHONY: test-vm test-esx test-all testremote
.PHONY: test-vm test-esx test-all testremote e2e-test
# test-vm runs GO unit tests and plugin test suite on a guest VM
# expects binaries to be deployed ot the VM and ESX (see deploy-all target)
test-vm: checkremote deploy-vm-test
Expand All @@ -330,7 +330,17 @@ test-esx:
$(MAKE) --directory=$(ESX_SRC) $@

testremote: test-esx test-vm
test-all: test testremote
test-all: test e2e-test testremote

# An end-to-end test target for vSphere Docker Volume Driver
e2e-test:
$(log_target)
$(SCRIPTS)/build.sh e2e-dkrVolDriver-test "$(ESX)" "$(VM1)" "$(VM2)"

.PHONY: e2e-dkrVolDriver-test
e2e-dkrVolDriver-test:
$(log_target)
$(GO) test $(PLUGIN)/E2E_Tests -cover -v

.PHONY:clean-vm clean-esx clean-all clean-docker
clean-vm:
Expand Down

0 comments on commit a88dcd5

Please # to comment.