-
Notifications
You must be signed in to change notification settings - Fork 44
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 #90 from scality/test-scenarios
Rework tests layout
- Loading branch information
Showing
36 changed files
with
3,591 additions
and
135 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,105 @@ | ||
top_srcdir="$(realpath "$(pwd)/../..")" | ||
|
||
ANSIBLE_FORCE_COLOR=true | ||
export ANSIBLE_FORCE_COLOR | ||
|
||
make_shell() { | ||
make --no-print-directory -C "${top_srcdir}" shell C="$*" | ||
} | ||
|
||
die() { | ||
exit 1 | ||
} | ||
|
||
setup_suite() { | ||
echo "Creating loopback block-device and configuring VM" | ||
sudo truncate -s 20G /kube-lvm || die | ||
sudo losetup /dev/loop0 /kube-lvm || die | ||
|
||
echo "Disabling iptables" | ||
sudo systemctl disable --now iptables || die | ||
sudo systemctl disable --now ip6tables || die | ||
sudo iptables -F || die | ||
sudo iptables -X || die | ||
|
||
echo "Creating shell environment" | ||
make_shell true | ||
|
||
echo "Deploy the cluster" | ||
make_shell ansible-playbook -i "$(pwd)/inventory" metal-k8s.yml --skip elasticsearch || die | ||
|
||
KUBECONFIG=$(pwd)/inventory/artifacts/admin.conf | ||
export KUBECONFIG | ||
|
||
echo "Run a sample kubectl command" | ||
make_shell kubectl get nodes | ||
} | ||
|
||
test_reclaim_storage() { | ||
echo "Listing all PVs before test (some should be available)" | ||
make_shell kubectl get pv | ||
|
||
echo "Running simple Pod with PersistentVolumeClaim" | ||
make_shell kubectl apply -f - << EOF | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: testclaim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 2Gi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: test-pv | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: test-pv | ||
image: busybox | ||
command: ['/bin/sh'] | ||
args: | ||
- "-c" | ||
- "mount | grep /var/test_pv && touch /var/test_pv/foo" | ||
volumeMounts: | ||
- name: test-volume | ||
mountPath: /var/test_pv | ||
volumes: | ||
- name: test-volume | ||
persistentVolumeClaim: | ||
claimName: testclaim | ||
EOF | ||
|
||
echo "Wait for Pod to exit" | ||
#TODO This could loop forever... | ||
until make_shell kubectl get pods test-pv -o jsonpath='{.status.phase}' | grep -E '(Failed|Succeeded)'; do | ||
echo "Sleeping..." | ||
sleep 1 | ||
done | ||
|
||
RESULT=$(make_shell kubectl get pods test-pv -o jsonpath='{.status.phase}') | ||
echo "Pod exited, listing all PVs:" | ||
make_shell kubectl get pv | ||
|
||
echo "Cleaning up resources" | ||
make_shell kubectl delete pod test-pv | ||
make_shell kubectl delete pvc testclaim | ||
|
||
assert_equals "Succeeded" "${RESULT}" | ||
|
||
echo "Verify some PVs are in Released state" | ||
assert 'make_shell kubectl get pv -o jsonpath={.items[*].status.phase} | grep Released > /dev/null' \ | ||
"No PVs in Released state" | ||
|
||
echo "Reclaim storage" | ||
make_shell ansible-playbook -i "$(pwd)/inventory" reclaim-storage.yml | ||
|
||
echo "Verify that no PV is in released state" | ||
assert_fails 'make_shell kubectl get pv -o jsonpath={.items[*].status.phase} | grep Released > /dev/null' \ | ||
"PVs in Released state found" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
bash_unit filter=insert_tag |
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,2 @@ | ||
*.swp | ||
token |
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,46 @@ | ||
**bash unit testing enterprise edition framework for professionals ![bash_unit](img/bu_50.png)** | ||
|
||
If you like bash_unit and want to contribute, you can do so in one of the | ||
following ways (order might matter). | ||
|
||
# Spread the word | ||
|
||
Talking about bash_unit is a very welcomed contribution. | ||
|
||
Share your success with bash_unit on your blog, twitter, stackoverflow... | ||
|
||
Nice words to share your experience with bash_unit is always appreciated. | ||
If you want to say something nice about bash_unit but can not think of a | ||
place for that right now, just add a comment to | ||
[issue #37](https://github.com/pgrange/bash_unit/issues/37). | ||
|
||
Starring the project is also appreciated. | ||
|
||
# Suggest improvements | ||
|
||
When you see something that is not working with bash_unit, or if you feel | ||
something is missing, open an | ||
[issue](https://github.com/pgrange/bash_unit/issues). | ||
|
||
Opening issues helps improving bash_unit. | ||
|
||
# Contribute code | ||
|
||
If you use a tool like bash_unit, odds are high that you already heard | ||
about software development. Just code the improvement you have in mind | ||
and create a pull-request. | ||
|
||
You can contribute with new features you think are missing but you can | ||
also find inspiration with the | ||
[open issues](https://github.com/pgrange/bash_unit/issues) of bash_unit. | ||
|
||
See [how to contribute code](CONTRIBUTING_CODE.md). | ||
|
||
# Donate | ||
|
||
bash_unit is free software I develop during my (not so) free time. If you feel | ||
bash_unit is helpfull enough to you that you want to compensate for some of | ||
the time spent developing or promoting it, you can contribute with your money | ||
on liberapay: | ||
|
||
[![liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/bash_unit/donate) |
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,3 @@ | ||
To perform a new release, run ./release in current directory. | ||
|
||
See help for more informations. |
Oops, something went wrong.