1# Copyright 2018 VMware, Inc. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License 14 15*** Settings *** 16Documentation Suite 26-01 - Basic 17Resource ../../resources/Util.robot 18Resource ../../resources/Group26-Storage-Quota-Util.robot 19Suite Setup Install VIC Appliance To Test Server additional-args='--storage-quota=15' 20Suite Teardown Cleanup VIC Appliance On Test Server 21Test Timeout 30 minutes 22 23*** Test Cases *** 24Create a VCH with storage quota and docker info shows the storage quota and storage usage 25 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 26 Should Be Equal As Integers ${rc} 0 27 28 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 29 Should Be Equal As Integers ${limitval} 15 30 Should Be Equal As Integers ${usageval} 0 31 32Create a container and docker info shows the storage usage has changed 33 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -id ${busybox} 34 Should Be Equal As Integers ${rc} 0 35 36 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 37 Should Be Equal As Integers ${rc} 0 38 39 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 40 41 Should Be Equal As Integers ${limitval} 15 42 Should Be True ${usageval} > 9 43 Set Suite Variable ${pre_usage_val} ${usageval} 44 45Pull a debian image and docker info shows the storage usage has changed 46 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} pull ${debian} 47 Should Be Equal As Integers ${rc} 0 48 49 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 50 Should Be Equal As Integers ${rc} 0 51 52 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 53 Should Be Equal As Integers ${limitval} 15 54 Should Be True ${usageval} > ${pre_usage_val} 55 Set Suite Variable ${pre_usage_val} ${usageval} 56 57Create second container and get storage quota exceeding failure 58 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -id ${busybox} 59 Should Be Equal As Integers ${rc} 125 60 Should Contain ${output} Storage quota exceeds 61 62Configure VCH with a larger storage quota of 35GB 63 ${output}= Run bin/vic-machine-linux configure --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --timeout %{TEST_TIMEOUT} --storage-quota 35 64 Should Contain ${output} Completed successfully 65 66 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 67 Should Be Equal As Integers ${rc} 0 68 69 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 70 Should Be Equal As Integers ${limitval} 35 71 72Create second container successfully 73 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -id --name secondc ${busybox} 74 Should Be Equal As Integers ${rc} 0 75 76 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 77 Should Be Equal As Integers ${rc} 0 78 79 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 80 81 Should Be Equal As Integers ${limitval} 35 82 Should Be True ${usageval} > 18 83 84Remove a container successfully with storage usage changes 85 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rm -f secondc 86 Should Be Equal As Integers ${rc} 0 87 88 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 89 Should Be Equal As Integers ${rc} 0 90 91 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 92 93 Should Be Equal As Integers ${limitval} 35 94 Should Be Equal As Integers ${usageval} ${pre_usage_val} 95 96Create a busybox container with memory of 4GB successfully 97 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -m=4g -id ${busybox} 98 Should Be Equal As Integers ${rc} 0 99 100 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 101 Should Be Equal As Integers ${rc} 0 102 103 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 104 105 Should Be Equal As Integers ${limitval} 35 106 Should Be True ${usageval} > 20 107 108Create a debian container and commit to an image successfully 109 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -d --name commit1 ${debian} tail -f /dev/null 110 Should Be Equal As Integers ${rc} 0 111 112 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 113 Should Be Equal As Integers ${rc} 0 114 115 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 116 117 Should Be Equal As Integers ${limitval} 35 118 Should Be True ${usageval} > 29 119 Set Suite Variable ${pre_usage_val} ${usageval} 120 121 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} exec commit1 apt-get update 122 Should Be Equal As Integers ${rc} 0 123 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} exec commit1 apt-get install nano 124 Should Be Equal As Integers ${rc} 0 125 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} stop -t1 commit1 126 Should Be Equal As Integers ${rc} 0 127 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} commit commit1 debian-nano 128 Should Be Equal As Integers ${rc} 0 129 130 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 131 Should Be Equal As Integers ${rc} 0 132 133 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 134 135 Should Be Equal As Integers ${limitval} 35 136 Should Be True ${usageval} > ${pre_usage_val} 137 138Delete an image successfully with storage usage decreased 139 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rmi debian-nano 140 Should Be Equal As Integers ${rc} 0 141 142 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 143 Should Be Equal As Integers ${rc} 0 144 145 ${limitval} ${usageval}= Get storage quota limit and usage ${output} 146 147 Should Be Equal As Integers ${limitval} 35 148 Should Be Equal As Integers ${usageval} ${pre_usage_val} 149 150Create a busybox continainer afer unsetting storage quota 151 ${output}= Run bin/vic-machine-linux configure --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --timeout %{TEST_TIMEOUT} --storage-quota 0 152 Should Contain ${output} Completed successfully 153 154 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -id ${busybox} 155 Should Be Equal As Integers ${rc} 0 156 157 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} info 158 Should Be Equal As Integers ${rc} 0 159 Should Not Contain ${output} storage limit 160 161 ${usageval}= Get storage usage ${output} 162 163 Should Be True ${usageval} > 38 164