Created
March 5, 2018 22:53
-
-
Save sdodson/694eec67b0ee79c8f044b35fa996d24f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| etcdctl2() { | |
| /usr/bin/etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://`hostname`:2379 ${@} | |
| } | |
| etcdctl3() { | |
| ETCDCTL_API=3 /usr/bin/etcdctl --cert /etc/etcd/peer.crt --key /etc/etcd/peer.key --cacert /etc/etcd/ca.crt --endpoints https://`hostname`:2379 ${@} | |
| } | |
| clean_etcd() { | |
| systemctl stop etcd | |
| rm -rf /var/lib/etcd/member | |
| systemctl start etcd | |
| } | |
| migrate_etcd() { | |
| echo "############# migrating start" | |
| systemctl stop etcd | |
| ETCDCTL_API=3 etcdctl migrate --data-dir=/var/lib/etcd | |
| systemctl start etcd | |
| echo "############# migration done" | |
| echo "" | |
| } | |
| get_key() { | |
| echo "v2 $1 = $(etcdctl2 get $1 2>/dev/null)" | |
| echo "v3 $1 = $(etcdctl3 get $1 --print-value-only 2>/dev/null )" | |
| } | |
| get_everything() { | |
| get_key /test/added-step0 | |
| get_key /test/added-step1 | |
| get_key /test/added-step2 | |
| get_key /test/updated-step1 | |
| get_key /test/updated-step1-and-step2 | |
| get_key /test/deleted-step0 | |
| get_key /test/deleted-step1 | |
| get_key /test/deleted-step2 | |
| } | |
| step0() { | |
| echo "### start step0" | |
| echo "v2 keys set to 'step0'" | |
| etcdctl2 mkdir /test | |
| etcdctl2 mk /test/added-step0 step0 | |
| etcdctl2 mk /test/updated-step1 step0 | |
| etcdctl2 mk /test/updated-step1-and-step2 step0 | |
| etcdctl2 mk /test/deleted-step0 step0 | |
| etcdctl2 mk /test/deleted-step1 step0 | |
| etcdctl2 mk /test/deleted-step2 step0 | |
| echo "Deleting /test/deleted-step0" | |
| etcdctl2 rm /test/deleted-step0 | |
| echo "### end step0" | |
| echo "" | |
| } | |
| step1() { | |
| echo "### start step1" | |
| echo "v3 set updated-step1-and-step2, updated-step1, added-step1 to 'step1'. delete deleted-step1" | |
| etcdctl3 put /test/added-step1 step1 | |
| etcdctl3 put /test/updated-step1-and-step2 step1 | |
| etcdctl3 put /test/updated-step1 step1 | |
| etcdctl3 del /test/deleted-step1 | |
| echo "### end step1" | |
| echo "" | |
| } | |
| step2() { | |
| echo "### start step2" | |
| echo "v2 set /test/updated-step1-and-step2 to 'step2', remove /test/deleted-step2, add /test/added-step2" | |
| etcdctl2 update /test/updated-step1-and-step2 step2 | |
| etcdctl2 mk /test/added-step2 step2 | |
| etcdctl2 rm /test/deleted-step2 | |
| echo "### stop step2" | |
| echo "" | |
| } | |
| clean_etcd | |
| step0 | |
| echo "sleep 10s" | |
| sleep 10 | |
| get_everything | |
| migrate_etcd | |
| get_everything | |
| step1 | |
| echo "sleep 10s" | |
| sleep 10 | |
| get_everything | |
| step2 | |
| echo " sleep 10s" | |
| sleep 10 | |
| migrate_etcd | |
| get_everything | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment