forked from rook/rook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e87b196
commit b589b18
Showing
47 changed files
with
4,455 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
} |
Oops, something went wrong.