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
  • Loading branch information
shuklanirdesh82 committed Jan 9, 2017
1 parent 51b3b92 commit 00b5fc0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion esx_service/cli/vmdkops_admin.py
Expand Up @@ -124,7 +124,7 @@ def commands():
'-c': {
'help': 'Display selected columns',
'choices': ['volume', 'datastore', 'created-by', 'created',
'attached-to', 'policy', 'capacity', 'used',
'attached-to', 'policy', 'capacity', 'used','disk-format',
'fstype', 'access', 'attach-as'],
'metavar': 'Col1,Col2,...'
},
Expand Down
15 changes: 15 additions & 0 deletions misc/scripts/build.sh
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
@@ -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)
}
17 changes: 13 additions & 4 deletions vmdk_plugin/Makefile
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-tests
# 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,16 @@ test-esx:
$(MAKE) --directory=$(ESX_SRC) $@

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

e2e-tests:
$(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 00b5fc0

Please sign in to comment.