Skip to content

Commit

Permalink
Test framework and Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aramisjohnson authored and dangula committed May 2, 2017
1 parent e87b196 commit b589b18
Show file tree
Hide file tree
Showing 47 changed files with 4,455 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.vscode/
/.work
/.download
/.idea

/bin
/vendor
Expand All @@ -16,3 +17,7 @@ demo/standalone/cloud-config.yml
.virtualbox/

.discovery-token
e2e/results
e2e/vendor
e2e/.glide
tests/smoke/temp_image.tar
20 changes: 20 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ try {
sh 'build/run make -j\$(nproc) check'
}

stage('E2E') {
def exists = fileExists 'release/version'

if (!exists) {
error('The file release/version does not exist')
}

def rook_tag = readFile (file: 'release/version', encoding : 'utf-8').trim()

if (rook_tag == '') {
error('Failed to get rook_tag from version file')
}

echo 'Rook Tag is ' + rook_tag

sh "e2e/scripts/smoke_test.sh ${rook_tag} Kubernetes v1.6"

junit 'e2e/results/*.xml'
}

stage('Publish') {
withCredentials([
[$class: 'UsernamePasswordMultiBinding', credentialsId: 'rook-quay-io', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASSWORD'],
Expand Down
8 changes: 6 additions & 2 deletions build/makelib/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ endef

$(foreach f,$(RELEASE_FLAVORS),$(foreach p,$(RELEASE_PLATFORMS), $(eval $(call release-target,$(f),$(p)))))

release.build: release.build.all
release.build:
@build/release/release.sh build.init
@$(MAKE) release.build.all

release.publish: release.publish.all
release.publish:
@build/release/release.sh publish.init
@$(MAKE) release.publish.all

release.promote:
@build/release/release.sh promote.init
Expand Down
2 changes: 1 addition & 1 deletion build/release/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ github_release_complete() {
write_version_file() {
# upload a file with the version number
cat <<EOF > ${RELEASE_DIR}/version
${version}
${RELEASE_VERSION}
EOF
}

Expand Down
8 changes: 7 additions & 1 deletion build/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ shift
mkdir -p ${RELEASE_DIR}

case ${action} in
build.init)
write_version_file
;;

publish.init)
;;

build|publish|promote|cleanup)
platform=$1
shift
Expand All @@ -26,7 +33,6 @@ case ${action} in
fi

echo promoting release ${RELEASE_VERSION} to channel ${RELEASE_CHANNEL}
write_version_file
publish_version_file
github_create_or_replace_release
;;
Expand Down
30 changes: 30 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Rook Test Framework

The Rook Test Framework is a Go project that that uses a Docker container with Kubernetes
tools and Docker pre-installed to quickly create a 3 node Kubernetes cluster using Docker in
Docker (DinD) techniques, installs Rook and then runs automation tests to verify its functionality.

##Requirements
1. Docker version => 1.2 && < 17.0
2. Ubuntu Host 16 (currently the framework has only been tested on this version)

##Instructions
On your Ubuntu box do the following;
1. Be sure to allocate a minimum of 4 processors to your vm
2. Navigate to the root directory of the repo and run the following:;
```e2e/scripts/smoke_test.sh```

At this point a Docker container with the base image of "quay.io/quantum/rook-test" is created, a
Kubernetes 3 node cluster is created using Kubeadm, that is visible from the Docker host. The
nodes can be identified by the following container names (kube-master, kube-node1 and kube-node2).
All tests with the name 'SmokeSuite' in the method will execute and the results will be of a junit
type output to the e2e/results directory.


### Cleanup
The Rook Test Framework normally cleans up all the containers it creates to setup the environment
and to run the tests. If for some reason the cleanup of the Rook Test framework should fail, the easiest way to manually
cleanup the environment is by doing the following;

1. Delete the docker container that uses an image named "quay.io/quantum/rook-test"
2. Run the script rook/e2e/framework/manager/scripts/rook-dind-cluster-v1.6.sh clean
Empty file added e2e/data/platform.properties
Empty file.
20 changes: 20 additions & 0 deletions e2e/data/smoke/block_mount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Pod
metadata:
name: block-test
spec:
containers:
- image: busybox
name: block-test1
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
volumeMounts:
- name: block-persistent-storage
mountPath: /tmp/rook1
volumes:
- name: block-persistent-storage
persistentVolumeClaim:
claimName: block-pv-claim
restartPolicy: Never
29 changes: 29 additions & 0 deletions e2e/data/smoke/file_mount.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
kind: Pod
metadata:
name: file-test
namespace: rook
spec:
containers:
- name: file-test1
image: busybox
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
env:
volumeMounts:
- mountPath: "/tmp/rookfs"
name: testfs
volumes:
- name: testfs
cephfs:
monitors:
- {{.mon0}}
- {{.mon1}}
- {{.mon2}}
user: admin
secretRef:
name: rook-admin
readOnly: false
restartPolicy: Never
34 changes: 34 additions & 0 deletions e2e/data/smoke/pool_sc_pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: rook.io/v1alpha1
kind: Pool
metadata:
name: replicapool
namespace: rook
spec:
replication:
size: 1
# For an erasure-coded pool, comment out the replication count above and uncomment the following settings.
# Make sure you have enough OSDs to support the replica count or erasure code chunks.
#erasureCode:
# codingChunks: 2
# dataChunks: 2
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: rook-block
provisioner: rook.io/block
parameters:
pool: replicapool
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: block-pv-claim
annotations:
volume.beta.kubernetes.io/storage-class: rook-block
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1M
19 changes: 19 additions & 0 deletions e2e/data/smoke/rgw_external.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: rgw-external
namespace: rook
labels:
app: rgw
rook_cluster: rook
spec:
ports:
- name: rgw
port: 53390
protocol: TCP
targetPort: 53390
selector:
app: rgw
rook_cluster: rook
sessionAffinity: None
type: NodePort
138 changes: 138 additions & 0 deletions e2e/framework/clients/k8s_rook_block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package clients

import (
"fmt"
"github.com/rook/rook/e2e/framework/contracts"
)

type k8sRookBlock struct {
transportClient contracts.ITransportClient
}

var (
listCmd = []string{"rook", "block", "ls"}
writeDataToBlockPod = []string{"sh", "-c", "WRITE_DATA_CMD"}
readDataFromBlockPod = []string{"cat", "READ_DATA_CMD"}
)

// Constructor to create k8sRookBlock - client to perform rook Block operations on k8s
func CreateK8SRookBlock(client contracts.ITransportClient) *k8sRookBlock {
return &k8sRookBlock{transportClient: client}
}

// Function to create a Block using Rook
// Input paramaters -
//name - path to a yaml file that creates a pvc in k8s - yaml should describe name and size of pvc being created
//size - not user for k8s implementation since its descried on the pvc yaml definition
//Output - k8s create pvc operation output and/or error
func (rb *k8sRookBlock) BlockCreate(name string, size int) (string, error) {
cmdArgs := []string{name}
out, err, status := rb.transportClient.Create(cmdArgs, nil)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to create block -- : %s", err)
}
}

// Function to delete a Block using Rook
// Input paramaters -
//name - path to a yaml file that where pvc is desirbed - delete is run on the the yaml definition
//Output - k8s delete pvc operation output and/or error
func (rb *k8sRookBlock) BlockDelete(name string) (string, error) {
cmdArgs := []string{name}
out, err, status := rb.transportClient.Delete(cmdArgs, nil)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to delete block -- : %s", err)
}
}

// Function to list all the blocks created/being managed by rook
//Returns a ouput for rook cli for block list
func (rb *k8sRookBlock) BlockList() (string, error) {
out, err, status := rb.transportClient.Execute(listCmd, nil)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to list all blocks -- : %s", err)
}
}

// Function to map a Block using Rook
// Input paramaters -
//name - path to a yaml file that creates a pod - pod should be defined to use a pvc that was created earlier
//mountpath - not used in this impl since mountpath is defined in the pod definition
//Output - k8s create pod operation output and/or error
func (rb *k8sRookBlock) BlockMap(name string, mountpath string) (string, error) {
cmdArgs := []string{name}
out, err, status := rb.transportClient.Create(cmdArgs, nil)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to Map block -- : %s", err)
}

}

// Function to write data to block created by rook ,i.e. write data to a pod that is using a pvc
// Input paramaters -
//name - path to a yaml file that creates a pod - pod should be defined to use a pvc that was created earlier
//mountpath - folder on the pod were data is supposed to be written(should match the mountpath described in the pod definition)
//data - data to be written
//filename - file where data is written to
//namespace - optional param - namespace of the pod
//Output - k8s exec pod operation output and/or error
func (rb *k8sRookBlock) BlockWrite(name string, mountpath string, data string, filename string, namespace string) (string, error) {
wt := "echo \"" + data + "\">" + mountpath + "/" + filename
writeDataToBlockPod[2] = wt
option := []string{name}
if namespace != "" {
option = append(option, namespace)
}
out, err, status := rb.transportClient.Execute(writeDataToBlockPod, option)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to write data to pod: %s --> %s", err, out)
}
}

// Function to read from block created by rook ,i.e. Read data from a pod that is using a pvc
// Input paramaters -
//name - path to a yaml file that creates a pod - pod should be defined to use a pvc that was created earlier
//mountpath - folder on the pod were data is supposed to be written(should match the mountpath described in the pod definition)
//filename - file to be read
//namespace - optional param - namespace of the pod
//Output - k8s exec pod operation output and/or error
func (rb *k8sRookBlock) BlockRead(name string, mountpath string, filename string, namespace string) (string, error) {
rd := mountpath + "/" + filename
readDataFromBlockPod[1] = rd
option := []string{name}
if namespace != "" {
option = append(option, namespace)
}
out, err, status := rb.transportClient.Execute(readDataFromBlockPod, option)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to read data to pod -- : %s", err)
}
}

// Function to map a Block using Rook
// Input paramaters -
//name - path to a yaml file - the pod described in yam file is deleted
//mountpath - not used in this impl since mountpath is defined in the pod definition
//Output - k8s delete pod operation output and/or error
func (rb *k8sRookBlock) BlockUnmap(name string, mountpath string) (string, error) {
cmdArgs := []string{name}
out, err, status := rb.transportClient.Delete(cmdArgs, nil)
if status == 0 {
return out, nil
} else {
return err, fmt.Errorf("Unable to unmap block -- : %s", err)
}

}
Loading

0 comments on commit b589b18

Please sign in to comment.