]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/ceph-helpers-root.sh
import 14.2.4 nautilus point release
[ceph.git] / ceph / qa / workunits / ceph-helpers-root.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2015 Red Hat <contact@redhat.com>
4 #
5 # Author: Loic Dachary <loic@dachary.org>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library Public License for more details.
16 #
17
18 #######################################################################
19
20 function distro_id() {
21 source /etc/os-release
22 echo $ID
23 }
24
25 function install() {
26 for package in "$@" ; do
27 install_one $package
28 done
29 }
30
31 function install_one() {
32 case $(distro_id) in
33 ubuntu|debian|devuan)
34 sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y "$@"
35 ;;
36 centos|fedora|rhel)
37 sudo yum install -y "$@"
38 ;;
39 opensuse*|suse|sles)
40 sudo zypper --non-interactive install "$@"
41 ;;
42 *)
43 echo "$(distro_id) is unknown, $@ will have to be installed manually."
44 ;;
45 esac
46 }
47
48 #######################################################################
49
50 function control_osd() {
51 local action=$1
52 local id=$2
53
54 sudo systemctl $action ceph-osd@$id
55
56 return 0
57 }
58
59 #######################################################################
60
61 function pool_read_write() {
62 local size=${1:-1}
63 local dir=/tmp
64 local timeout=360
65 local test_pool=test_pool
66
67 ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
68 ceph osd pool create $test_pool 4 || return 1
69 ceph osd pool set $test_pool size $size || return 1
70 ceph osd pool set $test_pool min_size $size || return 1
71 ceph osd pool application enable $test_pool rados
72
73 echo FOO > $dir/BAR
74 timeout $timeout rados --pool $test_pool put BAR $dir/BAR || return 1
75 timeout $timeout rados --pool $test_pool get BAR $dir/BAR.copy || return 1
76 diff $dir/BAR $dir/BAR.copy || return 1
77 ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
78 }
79
80 #######################################################################
81
82 set -x
83
84 "$@"