]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/ceph-helpers-root.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / qa / workunits / ceph-helpers-root.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
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
20function install() {
21 for package in "$@" ; do
22 install_one $package
23 done
24 return 0
25}
26
27function install_one() {
28 case $(lsb_release -si) in
29 Ubuntu|Debian|Devuan)
30 sudo apt-get install -y "$@"
31 ;;
32 CentOS|Fedora|RedHatEnterpriseServer)
33 sudo yum install -y "$@"
34 ;;
35 *SUSE*)
36 sudo zypper --non-interactive install "$@"
37 ;;
38 *)
39 echo "$(lsb_release -si) is unknown, $@ will have to be installed manually."
40 ;;
41 esac
42}
43
44#######################################################################
45
46function control_osd() {
47 local action=$1
48 local id=$2
49
11fdf7f2 50 sudo systemctl $action ceph-osd@$id
7c673cae 51
7c673cae
FG
52 return 0
53}
54
55#######################################################################
56
57function pool_read_write() {
58 local size=${1:-1}
59 local dir=/tmp
60 local timeout=360
61 local test_pool=test_pool
62
63 ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
64 ceph osd pool create $test_pool 4 || return 1
65 ceph osd pool set $test_pool size $size || return 1
66 ceph osd pool set $test_pool min_size $size || return 1
c07f9fc5 67 ceph osd pool application enable $test_pool rados
7c673cae
FG
68
69 echo FOO > $dir/BAR
70 timeout $timeout rados --pool $test_pool put BAR $dir/BAR || return 1
71 timeout $timeout rados --pool $test_pool get BAR $dir/BAR.copy || return 1
72 diff $dir/BAR $dir/BAR.copy || return 1
73 ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
74}
75
76#######################################################################
77
78set -x
79
80"$@"