#!/bin/bash

# Test node failure while reweighting
. ./common

_need_to_be_root

_make_device 0 $((200 * 1024 ** 2)) # 200 MB
_make_device 1 $((200 * 1024 ** 2)) # 200 MB
_make_device 2 $((400 * 1024 ** 2)) # 400 MB
_make_device 3 $((200 * 1024 ** 2))  # 200 MB

#start three in different size
for i in 0 1 2; do
	_start_sheep $i
done
_wait_for_sheep 3
_cluster_format -c 2

$DOG vdi create test 100M -P
_node_info
$DOG node list

$DOG node md plug $STORE/3
_wait_for_sheep_recovery 0
_node_info
$DOG node list

$DOG cluster reweight

# restart sheep1 while reweighting
_kill_sheep 2
_wait_for_sheep_recovery 0
_node_info | grep -v ^2 # the content of sheep 2 is non-deterministic
$DOG node list
_start_sheep 2

_wait_for_sheep_recovery 0
_node_info
$DOG node list
$DOG cluster info | _filter_cluster_info
