-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from linkernetworks/hwchiu/VX-238
[Task] Support the NFS Testing in the travisCI environment.
- Loading branch information
Showing
12 changed files
with
162 additions
and
8 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
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 @@ | ||
*.json |
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,21 @@ | ||
nodeName=`kubectl get nodes | grep "Ready" | awk '{print $1}'` | ||
if [ -z "$podName" ]; then | ||
export name=$(date | md5sum | cut -b 1-19) | ||
export podName="test-pod-$name" | ||
export nfsstorageName="test-nfs-storage-$name" | ||
export volumeName="test-nfs-volume-$name" | ||
nfsIP=`kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}"` | ||
#nfsIP="172.17.8.100" | ||
|
||
for i in storage volume pod; do | ||
rm -f $i.json | ||
cp $i.info $i.json | ||
done | ||
|
||
sed -i "s/@NFSIP@/${nfsIP}/" storage.json | ||
sed -i "s/@NFSSTORAGENAME@/${nfsstorageName}/" storage.json | ||
sed -i "s/@STORAGENAME@/${nfsstorageName}/" volume.json | ||
sed -i "s/@VOLUMENAME@/${volumeName}/" volume.json | ||
sed -i "s/@PODNAME@/${podName}/" pod.json | ||
sed -i "s/@VOLUMENAME@/${volumeName}/" pod.json | ||
fi |
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,24 @@ | ||
{ | ||
"name": "@PODNAME@", | ||
"labels":{}, | ||
"namespace":"default", | ||
"containers":[ | ||
{ | ||
"name":"first-container", | ||
"image":"busybox", | ||
"command":["sleep","3600"] | ||
} | ||
], | ||
"networks":[ | ||
], | ||
"volumes":[ | ||
{ | ||
"name":"@VOLUMENAME@", | ||
"mountPath":"/tmp" | ||
} | ||
], | ||
"restartPolicy":"Always", | ||
"capability": true, | ||
"networkType": "cluster", | ||
"nodeAffinity": [] | ||
} |
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,88 @@ | ||
#!/usr/bin/env bats | ||
|
||
load init | ||
|
||
@test "Create Storage" { | ||
http -v --check-status 127.0.0.1:7890/v1/storage < storage.json | ||
[ $? = 0 ] | ||
} | ||
|
||
@test "List Storage" { | ||
run bash -c 'http http://127.0.0.1:7890/v1/storage/ 2>/dev/null | jq -r ".[0].id"' | ||
id=${output} | ||
run kubectl -n vortex get sc nfs-storageclass-${id} -o jsonpath="{.provisioner}" | ||
[ "$output" = "nfs-provisioner-${id}" ] | ||
|
||
NEXT_WAIT_TIME=0 | ||
WAIT_LIMIT=40 | ||
deploymentName="nfs-provisioner-${id}" | ||
until kubectl -n vortex get deployment ${deploymentName} -o jsonpath="{.status.readyReplicas}" | grep "1" || [ $NEXT_WAIT_TIME -eq $WAIT_LIMIT ]; do | ||
sleep 2 | ||
kubectl -n vortex describe deployment ${deploymentName} | ||
NEXT_WAIT_TIME=$((NEXT_WAIT_TIME+ 1)) | ||
done | ||
[ $NEXT_WAIT_TIME != $WAIT_LIMIT ] | ||
} | ||
|
||
@test "Create Volume" { | ||
http -v --check-status 127.0.0.1:7890/v1/volume < volume.json | ||
[ $? = 0 ] | ||
} | ||
|
||
@test "List Volume" { | ||
run bash -c 'http http://127.0.0.1:7890/v1/volume/ 2>/dev/null | jq -r ".[0].id"' | ||
id=${output} | ||
NEXT_WAIT_TIME=0 | ||
WAIT_LIMIT=40 | ||
pvcName="pvc-${id}" | ||
until kubectl get pvc ${pvcName} -o jsonpath="{.status.phase}" | grep "Bound" || [ $NEXT_WAIT_TIME -eq $WAIT_LIMIT ]; do | ||
sleep 2 | ||
kubectl describe pvc ${pvcName} | ||
NEXT_WAIT_TIME=$((NEXT_WAIT_TIME+ 1)) | ||
done | ||
[ $NEXT_WAIT_TIME != $WAIT_LIMIT ] | ||
} | ||
|
||
@test "Create Pod" { | ||
http -v --check-status 127.0.0.1:7890/v1/pods < pod.json | ||
[ $? = 0 ] | ||
} | ||
|
||
@test "List Pod" { | ||
run bash -c "http http://127.0.0.1:7890/v1/pods/ 2>/dev/null | jq -r '.[] | select(.name == \"${podName}\").name'" | ||
[ "$output" = "${podName}" ] | ||
[ $status = 0 ] | ||
|
||
NEXT_WAIT_TIME=0 | ||
WAIT_LIMIT=40 | ||
until kubectl get pods ${podName} -o jsonpath="{.status.phase}" | grep "Running" || [ $NEXT_WAIT_TIME -eq $WAIT_LIMIT ]; do | ||
sleep 2 | ||
kubectl get pods ${podName} | ||
NEXT_WAIT_TIME=$((NEXT_WAIT_TIME+ 1)) | ||
done | ||
[ $NEXT_WAIT_TIME != $WAIT_LIMIT ] | ||
} | ||
|
||
@test "Test NFS" { | ||
kubectl exec ${podName} touch /tmp/testing | ||
find /tmp/nfs | grep testing | ||
[ $? = 0 ] | ||
} | ||
|
||
@test "Delete Pod" { | ||
run bash -c 'http http://127.0.0.1:7890/v1/pods/ 2>/dev/null | jq -r ".[0].id"' | ||
run http DELETE http://127.0.0.1:7890/v1/pods/${output} 2>/dev/null | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Delete Volume" { | ||
run bash -c 'http http://127.0.0.1:7890/v1/volume/ 2>/dev/null | jq -r ".[0].id"' | ||
http -v --check-status DELETE http://127.0.0.1:7890/v1/volume/${output} | ||
[ $? = 0 ] | ||
} | ||
|
||
@test "Delete Storage" { | ||
run bash -c 'http http://127.0.0.1:7890/v1/storage/ 2>/dev/null | jq -r ".[0].id"' | ||
http -v --check-status DELETE http://127.0.0.1:7890/v1/storage/${output} | ||
[ $? = 0 ] | ||
} |
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,6 @@ | ||
{ | ||
"type": "nfs", | ||
"name": "@NFSSTORAGENAME@", | ||
"ip":"@NFSIP@", | ||
"path":"/tmp/nfs" | ||
} |
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,6 @@ | ||
{ | ||
"storageName": "@STORAGENAME@", | ||
"name": "@VOLUMENAME@", | ||
"accessMode":"ReadWriteMany", | ||
"capacity":"300Gi" | ||
} |