-
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 #122 from linkernetworks/hwchiu/VX-189
[Task] VX-189 Use bats to provide integration test. Former-commit-id: 7b45afe9892c4b618c86e5d4e9da06775c863eec [formerly 7b45afe9892c4b618c86e5d4e9da06775c863eec [formerly 6069e60]] Former-commit-id: 02c977c7b62cdbdda9857b0d79d55e1a9a93e005 Former-commit-id: b51d577
- Loading branch information
Showing
9 changed files
with
173 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bats | ||
|
||
@test "Check the httpie" { | ||
run which http | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Check the jq" { | ||
run which jq | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Check the OpenvSwitch" { | ||
run which ovs-vsctl | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Check kubernetes tools" { | ||
run which kubectl | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Check kubernetes cluster" { | ||
run kubectl get nodes | ||
[ $status = 0 ] | ||
[[ ${lines[0]} != "No resources found." ]] | ||
} |
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,58 @@ | ||
#!/usr/bin/env bats | ||
|
||
load data | ||
setup() { | ||
sed -i "s/@NODENAME@/${nodeName}/" networks.json | ||
sed -i "s/@NETWORKNAME@/${networkName}/" networks.json | ||
sed -i "s/@NETWORKNAME@/${networkName}/" pod.json | ||
sed -i "s/@PODNAME@/${podName}/" pod.json | ||
} | ||
|
||
teardown() { | ||
git checkout networks.json | ||
git checkout pod.json | ||
} | ||
|
||
@test "Create network" { | ||
http -v --check-status 127.0.0.1:32326/v1/networks < networks.json | ||
[ $? = 0 ] | ||
} | ||
|
||
@test "List network" { | ||
run bash -c "http http://127.0.0.1:32326/v1/networks/ 2>/dev/null | jq -r '.[] | select(.name == \"${networkName}\").name'" | ||
[ "$output" = "${networkName}" ] | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Create Pod" { | ||
http -v --check-status 127.0.0.1:32326/v1/pods < pod.json | ||
[ $? = 0 ] | ||
#Wait the Pod | ||
#jsonpath="{.status.phase}" | ||
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 "List Pod" { | ||
run bash -c "http http://127.0.0.1:32326/v1/pods/ 2>/dev/null | jq -r '.[] | select(.name == \"${podName}\").name'" | ||
[ "$output" = "${podName}" ] | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Delete Pod" { | ||
run bash -c 'http http://127.0.0.1:32326/v1/pods/ 2>/dev/null | jq -r ".[0].id"' | ||
run http DELETE http://127.0.0.1:32326/v1/pods/${output} 2>/dev/null | ||
[ $status = 0 ] | ||
} | ||
|
||
@test "Delete Network" { | ||
run bash -c 'http http://127.0.0.1:32326/v1/networks/ 2>/dev/null | jq -r ".[0].id"' | ||
run http DELETE http://127.0.0.1:32326/v1/networks/${output} 2>/dev/null | ||
[ $status = 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 @@ | ||
nodeName=`kubectl get nodes | grep "Ready" | awk '{print $1}'` | ||
if [ -z "$networkName" ]; then | ||
export name=$(date | md5sum | cut -b 1-19) | ||
export podName="test-pod-$name" | ||
export networkName="test-network-$name" | ||
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,15 @@ | ||
{ | ||
"type":"system", | ||
"isDPDKPort":false, | ||
"name":"@NETWORKNAME@", | ||
"vlanTags":[], | ||
"bridgeName":"br0", | ||
"nodes":[ | ||
{ | ||
"name": "@NODENAME@", | ||
"physicalInterfaces": [{ | ||
"name":"eth10" | ||
}] | ||
} | ||
] | ||
} |
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,38 @@ | ||
{ | ||
"name": "@PODNAME@", | ||
"labels":{}, | ||
"namespace":"default", | ||
"containers":[ | ||
{ | ||
"name":"first-container", | ||
"image":"busybox", | ||
"command":["sleep","3600"] | ||
} | ||
], | ||
"networks":[ | ||
{ | ||
"name":"@NETWORKNAME@", | ||
"ifName":"eth12", | ||
"vlan":0, | ||
"ipAddress":"1.2.3.4", | ||
"netmask":"255.255.255.0", | ||
"vlanTag":123 | ||
}, | ||
{ | ||
"name":"@NETWORKNAME@", | ||
"ifName":"eth13", | ||
"vlan":0, | ||
"ipAddress":"1.2.4.5", | ||
"netmask":"255.255.255.0", | ||
"vlanTag":124 | ||
}, | ||
{ | ||
"name":"@NETWORKNAME@", | ||
"ifName":"eth15", | ||
"vlan":0, | ||
"ipAddress":"15.2.4.5", | ||
"netmask":"255.255.255.0" | ||
} | ||
], | ||
"volumes":[] | ||
} |