forked from projectatomic/container-storage-setup
-
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.
Add reset function to cleanup docker-storage-setup configuration
This script should cleanup devicemapper storage as well as remove /etc/sysconfig/docker-storage Closes: projectatomic#128 Approved by: rhvgoyal
- Loading branch information
1 parent
9461ef9
commit 194eca2
Showing
4 changed files
with
142 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
source $SRCDIR/libtest.sh | ||
|
||
# Test "docker-storage-setup reset". Returns 0 on success and 1 on failure. | ||
test_reset_devmapper() { | ||
local devs=${TEST_DEVS} | ||
local test_status | ||
local testname=`basename "$0"` | ||
local vg_name="dss-test-foo" | ||
|
||
# Error out if any pre-existing volume group vg named dss-test-foo | ||
for vg in $(vgs --noheadings -o vg_name); do | ||
if [ "$vg" == "$vg_name" ]; then | ||
echo "ERROR: $testname: Volume group $vg_name already exists." | ||
return 1 | ||
fi | ||
done | ||
|
||
# Create config file | ||
clean_config_files | ||
cat << EOF > /etc/sysconfig/docker-storage-setup | ||
DEVS="$devs" | ||
VG=$vg_name | ||
EOF | ||
|
||
# Run docker-storage-setup | ||
$DSSBIN >> $LOGS 2>&1 | ||
|
||
# Test failed. | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: $testname: $DSSBIN Failed." >> $LOGS | ||
cleanup $vg_name "$devs" | ||
return 1 | ||
fi | ||
|
||
test_status=1 | ||
$DSSBIN --reset >> $LOGS 2>&1 | ||
# Test failed. | ||
if [ $? -eq 0 ]; then | ||
if [ ! -e /etc/sysconfig/docker-storage ]; then | ||
test_status=0 | ||
fi | ||
fi | ||
if [ ${test_status} -eq 1 ]; then | ||
echo "ERROR: $testname: $DSSBIN --reset Failed." >> $LOGS | ||
fi | ||
|
||
cleanup $vg_name "$devs" | ||
|
||
return $test_status | ||
} | ||
|
||
# Create a devicemapper docker backend and then make sure the | ||
# `docker-storage-setup --reset` | ||
# cleans it up properly. | ||
test_reset_devmapper |
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,44 @@ | ||
source $SRCDIR/libtest.sh | ||
|
||
# Test "docker-storage-setup reset". Returns 0 on success and 1 on failure. | ||
test_reset_overlay() { | ||
local test_status | ||
local testname=`basename "$0"` | ||
|
||
# Create config file | ||
clean_config_files | ||
cat << EOF > /etc/sysconfig/docker-storage-setup | ||
STORAGE_DRIVER=overlay | ||
EOF | ||
|
||
# Run docker-storage-setup | ||
$DSSBIN >> $LOGS 2>&1 | ||
|
||
# Test failed. | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: $testname: $DSSBIN Failed." >> $LOGS | ||
clean_config_files | ||
return 1 | ||
fi | ||
|
||
test_status=0 | ||
$DSSBIN --reset >> $LOGS 2>&1 | ||
if [ $? -ne 0 ]; then | ||
# Test failed. | ||
test_status=1 | ||
elif [ -e /etc/sysconfig/docker-storage ]; then | ||
# Test failed. | ||
test_status=1 | ||
fi | ||
if [ ${test_status} -eq 1 ]; then | ||
echo "ERROR: $testname: $DSSBIN --reset Failed." >> $LOGS | ||
fi | ||
|
||
clean_config_files | ||
return $test_status | ||
} | ||
|
||
# Create a overlay docker backend and then make sure the | ||
# docker-storage-setup --reset | ||
# cleans it up properly. | ||
test_reset_overlay |