Add: source-dev and fstype args && Remove: pty

This commit is contained in:
Dmitry Vlasov
2023-11-27 19:18:47 +03:00
parent de5c92aed2
commit 124f3a6f67
2 changed files with 47 additions and 34 deletions
+10 -29
View File
@@ -8,34 +8,6 @@ chmod +x create-vm.sh
./create-vm.sh --bootstrap-env env
vi env
sudo ./create-vm.sh -e ./env
sudo less -R /tmp/create-vm/Ubuntu22.04/serial.log # For observing the test
```
As a result you will get something like that:
```
Using uid:0, gid:0.
Writing a byte at a time...done
Writing intelligently...done
Rewriting...done
Reading a byte at a time...done
Reading intelligently...done
start 'em...done...done...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version 2.00 ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Name:Size etc /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
Ubuntu22 4G 751k 97 155m 33 35.4m 12 974k 96 41.8m 8 227.2 11
Latency 15686us 203ms 367ms 358ms 282ms 396ms
Version 2.00 ------Sequential Create------ --------Random Create--------
Ubuntu22 -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
16 1 2 +++++ +++ 724249376 2 1 1 +++++ +++ 724249376 1
Latency 1858ms 46383us 1105ms 2012ms 2620us 2165ms
1.98,2.00,Ubuntu22,1,1700182713,4G,,8192,5,751,97,159132,33,36287,12,974,96,42847,8,227.2,11,16,,,,,49,2,+++++,+++,95,2,45,1,+++++,+++,78,1,15686us,203ms,367ms,358ms,282ms,396ms,1858ms,46383us,1105ms,2012ms,2620us,2165ms
```
### Usage of `./create-vm.sh`:
@@ -62,6 +34,10 @@ required_args:
-p, --prefix PREFIX network prefix
-g, --gateway GATEWAY ip address of network gateway
-d, --dns DNS ip address of dns server
-S, --source-dev SOURCE_DEV size of the created image for
performing a test on it
-f, --fstype FSTYPE filesystem type
default: xfs
-t, --test-suite TEST_UTIL what should be used for the test
(bonnie++ and iozone are available)
default: bonnie++
@@ -96,10 +72,12 @@ env example:
PREFIX=24
GATEWAY=192.168.122.1
DNS=8.8.8.8
SOURCE_DEV=/dev/sdx # CHANGE IT!
FSTYPE=xfs
TEST_UTIL=bonnie++
TEST_UTIL_ARGS="-u 0"
RM=true
PUBKEY=/home/cloudadmin/.ssh/id_rsa.pub
PUBKEY=/root/.ssh/id_rsa.pub
VNC_PASSWORD=PASSWD1!
@@ -131,6 +109,9 @@ cloud-init example:
groups: sudo
shell: /bin/bash
runcmd:
- wipefs -a /dev/{{DEV_INTERNAL_NAME}}
- mkfs.{{FSTYPE}} /dev/{{DEV_INTERNAL_NAME}}
- mkdir -p {{TESTDIR}}
- mount /dev/{{DEV_INTERNAL_NAME}} {{TESTDIR}}
- {{TEST_UTIL}} {{TEST_UTIL_ARGS}}
```
+37 -5
View File
@@ -2,6 +2,7 @@
# Creating a new virtual (another virt-viewer wrapper, yes)
#
# == Defaults =================================================================
DEFAULT_DEV_INTERNAL_NAME=vdb
DEFAULT_BASE_PATH=/tmp/create-vm
DEFAULT_TESTDIR="/fs-test"
DEFAULT_USER_INIT="#cloud-config
@@ -31,7 +32,10 @@ users:
groups: sudo
shell: /bin/bash
runcmd:
- wipefs -a /dev/{{DEV_INTERNAL_NAME}}
- mkfs.{{FSTYPE}} /dev/{{DEV_INTERNAL_NAME}}
- mkdir -p {{TESTDIR}}
- mount /dev/{{DEV_INTERNAL_NAME}} {{TESTDIR}}
- {{TEST_UTIL}} {{TEST_UTIL_ARGS}}
"
DEFAULT_NETPLAN="network:
@@ -60,10 +64,12 @@ IP=192.168.122.2
PREFIX=24
GATEWAY=192.168.122.1
DNS=8.8.8.8
SOURCE_DEV=/dev/sdx # CHANGE IT!
FSTYPE=xfs
TEST_UTIL=bonnie++
TEST_UTIL_ARGS=\"-u 0\"
RM=true
PUBKEY=/home/cloudadmin/.ssh/id_rsa.pub
PUBKEY=/root/.ssh/id_rsa.pub
VNC_PASSWORD=PASSWD1!
"
# == Help =====================================================================
@@ -90,6 +96,10 @@ required_args:
-p, --prefix PREFIX network prefix
-g, --gateway GATEWAY ip address of network gateway
-d, --dns DNS ip address of dns server
-S, --source-dev SOURCE_DEV size of the created image for
performing a test on it
-f, --fstype FSTYPE filesystem type
default: xfs
-t, --test-suite TEST_UTIL what should be used for the test
(bonnie++ and iozone are available)
default: bonnie++
@@ -151,12 +161,11 @@ function rm_domain() {
}
function cleanup_known_host() {
ssh-keygen -f "/home/$(id -nu 1000)/.ssh/known_hosts" -R "$1"
ssh-keygen -f "/root/.ssh/known_hosts" -R "$1"
}
# == Args parse ===============================================================
options=$(getopt -n $0 -o n:o:m:c:i:s:b:a:p:g:d:t:T:he:rP:v:C: \
options=$(getopt -n $0 -o n:o:m:c:i:s:b:a:p:g:d:S:f:t:T:he:rP:v:C: \
--long bootstrap-env: \
--long name: \
--long os-variant: \
@@ -169,6 +178,8 @@ options=$(getopt -n $0 -o n:o:m:c:i:s:b:a:p:g:d:t:T:he:rP:v:C: \
--long prefix: \
--long gateway: \
--long dns: \
--long source-dev: \
--long fstype: \
--long test-suite: \
--long test-args: \
--long help \
@@ -247,6 +258,16 @@ while true; do
DNS=$1
shift
;;
-S | --source-dev)
shift
SOURCE_DEV=$1
shift
;;
-f | --fstype)
shift
FSTYPE=${1:-"xfs"}
shift
;;
-t | --test-suite)
shift
TEST_UTIL=${1:-"bonnie++"}
@@ -273,7 +294,7 @@ while true; do
;;
-p | --pubkey)
shift
PUBKEY=${1:-"/home/$USER/.ssh/id_rsa.pub"}
PUBKEY=${1:-"/root/.ssh/id_rsa.pub"}
shift
;;
-v | --vnc-password)
@@ -304,6 +325,7 @@ if [[ -z "$ENV" ]]; then
required $PREFIX
required $GATEWAY
required $DNS
required $SOURCE_DEV
fi
if [[ -n "$ENV" ]]; then
@@ -389,6 +411,10 @@ else
esac
user_init=${DEFAULT_USER_INIT//"{{PUBKEY}}"/"$(cat $PUBKEY 2>/dev/null)"}
user_init=${user_init//"{{FSTYPE}}"/"$FSTYPE"}
user_init=${user_init//"{{DEV_INTERNAL_NAME}}"/"$DEFAULT_DEV_INTERNAL_NAME"}
user_init=${user_init//"{{TESTDIR}}"/"$DEFAULT_TESTDIR"}
user_init=${user_init//"{{TEST_UTIL}}"/"$TEST_UTIL"}
user_init=${user_init//"{{TEST_UTIL_ARGS}}"/"${test_util_args_parsed:-$TEST_UTIL_ARGS$}"}
@@ -434,12 +460,18 @@ virt-install --name $NAME \
--network bridge:$BRIDGE \
--graphics vnc,listen=0.0.0.0,password=$VNC_PASSWORD \
--import \
--serial file,path=$BASE_PATH/serial.log \
--boot uefi \
--disk $BASE_PATH/cidata.iso,device=cdrom \
--noautoconsole \
--noreboot
# Attaching the drive for a test
virsh attach-disk $NAME \
--source $SOURCE_DEV \
--target $DEFAULT_DEV_INTERNAL_NAME \
--cache none \
--persistent
# Starting vm
virsh start $NAME