Compare commits

..

5 Commits

Author SHA1 Message Date
Vitaliy Filippov f1f8531fd4 Make tests compatible with antietcd, add 2 antietcd tests to CI
Test / test_rebalance_verify_imm (push) Successful in 4m31s Details
Test / test_root_node (push) Successful in 10s Details
Test / test_rebalance_verify (push) Successful in 5m18s Details
Test / test_switch_primary (push) Successful in 38s Details
Test / test_write (push) Successful in 48s Details
Test / test_write_no_same (push) Successful in 19s Details
Test / test_write_xor (push) Successful in 53s Details
Test / test_rebalance_verify_ec_imm (push) Successful in 3m58s Details
Test / test_rebalance_verify_ec (push) Successful in 7m50s Details
Test / test_heal_pg_size_2 (push) Successful in 4m10s Details
Test / test_heal_antietcd (push) Successful in 4m16s Details
Test / test_heal_ec (push) Successful in 4m54s Details
Test / test_heal_csum_32k_dmj (push) Successful in 5m52s Details
Test / test_heal_csum_32k_dj (push) Successful in 6m29s Details
Test / test_heal_csum_32k (push) Successful in 6m14s Details
Test / test_osd_tags (push) Successful in 35s Details
Test / test_heal_csum_4k_dmj (push) Successful in 6m51s Details
Test / test_enospc (push) Successful in 1m42s Details
Test / test_enospc_xor (push) Successful in 2m32s Details
Test / test_enospc_imm (push) Successful in 1m40s Details
Test / test_heal_csum_4k_dj (push) Successful in 6m8s Details
Test / test_scrub (push) Successful in 1m3s Details
Test / test_heal_csum_4k (push) Successful in 5m5s Details
Test / test_enospc_imm_xor (push) Successful in 1m23s Details
Test / test_scrub_zero_osd_2 (push) Successful in 26s Details
Test / test_scrub_xor (push) Successful in 31s Details
Test / test_scrub_ec (push) Successful in 33s Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Successful in 37s Details
Test / test_nfs (push) Successful in 15s Details
Test / test_scrub_pg_size_3 (push) Successful in 48s Details
2024-07-20 02:16:38 +03:00
Vitaliy Filippov 8d79d59964 Update antietcd to 1.1.0 2024-07-20 02:15:48 +03:00
Vitaliy Filippov 551a209a50 Fix persistence filter initialization 2024-07-20 02:15:48 +03:00
Vitaliy Filippov 06cafd7702 Do not merge config an extra unneeded time 2024-07-20 02:15:48 +03:00
Vitaliy Filippov 3018352443 Fix clustered Antietcd support 2024-07-19 18:58:58 +03:00
14 changed files with 145 additions and 65 deletions

View File

@ -197,6 +197,24 @@ jobs:
echo "" echo ""
done done
test_etcd_fail_antietcd:
runs-on: ubuntu-latest
needs: build
container: ${{env.TEST_IMAGE}}:${{github.sha}}
steps:
- name: Run test
id: test
timeout-minutes: 10
run: ANTIETCD=1 /root/vitastor/tests/test_etcd_fail.sh
- name: Print logs
if: always() && steps.test.outcome == 'failure'
run: |
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
echo "-------- $i --------"
cat $i
echo ""
done
test_interrupted_rebalance: test_interrupted_rebalance:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
@ -665,6 +683,24 @@ jobs:
echo "" echo ""
done done
test_heal_antietcd:
runs-on: ubuntu-latest
needs: build
container: ${{env.TEST_IMAGE}}:${{github.sha}}
steps:
- name: Run test
id: test
timeout-minutes: 10
run: ANTIETCD=1 /root/vitastor/tests/test_heal.sh
- name: Print logs
if: always() && steps.test.outcome == 'failure'
run: |
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
echo "-------- $i --------"
cat $i
echo ""
done
test_heal_csum_32k_dmj: test_heal_csum_32k_dmj:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build

View File

@ -34,6 +34,10 @@ for my $line (<>)
{ {
$test_name .= '_imm'; $test_name .= '_imm';
} }
elsif ($1 eq 'ANTIETCD')
{
$test_name .= '_antietcd';
}
else else
{ {
$test_name .= '_'.lc($1).'_'.$2; $test_name .= '_'.lc($1).'_'.$2;

View File

@ -1,8 +1,6 @@
// Copyright (c) Vitaliy Filippov, 2019+ // Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.1 (see README.md for details) // License: VNPL-1.1 (see README.md for details)
const fs = require('fs');
const AntiEtcd = require('antietcd'); const AntiEtcd = require('antietcd');
const vitastor_persist_filter = require('./vitastor_persist_filter.js'); const vitastor_persist_filter = require('./vitastor_persist_filter.js');
@ -15,21 +13,15 @@ class AntiEtcdAdapter
let antietcd; let antietcd;
if (config.use_antietcd) if (config.use_antietcd)
{ {
let fileConfig = {}; let cluster = config.etcd_address;
if (fs.existsSync(config.config_path||'/etc/vitastor/vitastor.conf'))
{
fileConfig = JSON.parse(fs.readFileSync(config.config_path||'/etc/vitastor/vitastor.conf', { encoding: 'utf-8' }));
}
let mergedConfig = { ...fileConfig, ...config };
let cluster = mergedConfig.etcd_address;
if (!(cluster instanceof Array)) if (!(cluster instanceof Array))
cluster = cluster ? (''+(cluster||'')).split(/,+/) : []; cluster = cluster ? (''+(cluster||'')).split(/,+/) : [];
cluster = Object.keys(cluster.reduce((a, url) => cluster = Object.keys(cluster.reduce((a, url) =>
{ {
a[url.toLowerCase().replace(/^https?:\/\//, '').replace(/\/.*$/, '')] = true; a[url.toLowerCase().replace(/^(https?:\/\/)/, '').replace(/\/.*$/, '')] = true;
return a; return a;
}, {})); }, {}));
const cfg_port = mergedConfig.antietcd_port; const cfg_port = config.antietcd_port;
const is_local = local_ips(true).reduce((a, c) => { a[c] = true; return a; }, {}); const is_local = local_ips(true).reduce((a, c) => { a[c] = true; return a; }, {});
const selected = cluster.map(s => s.split(':', 2)).filter(ip => is_local[ip[0]] && (!cfg_port || ip[1] == cfg_port)); const selected = cluster.map(s => s.split(':', 2)).filter(ip => is_local[ip[0]] && (!cfg_port || ip[1] == cfg_port));
if (selected.length > 1) if (selected.length > 1)
@ -42,12 +34,13 @@ class AntiEtcdAdapter
const antietcd_config = { const antietcd_config = {
ip: selected[0][0], ip: selected[0][0],
port: selected[0][1], port: selected[0][1],
data: mergedConfig.antietcd_data_file || ((mergedConfig.antietcd_data_dir || '/var/lib/vitastor') + '/mon_'+selected[0][1]+'.json.gz'), data: config.antietcd_data_file || ((config.antietcd_data_dir || '/var/lib/vitastor') + '/mon_'+selected[0][1]+'.json.gz'),
persist_filter: vitastor_persist_filter(mergedConfig.etcd_prefix || '/vitastor'), persist_filter: vitastor_persist_filter({ vitastor_prefix: config.etcd_prefix || '/vitastor' }),
node_id: selected[0][0]+':'+selected[0][1], // node_id = ip:port node_id: selected[0][0]+':'+selected[0][1], // node_id = ip:port
cluster: (cluster.length == 1 ? null : cluster), cluster: (cluster.length == 1 ? null : cluster.reduce((a, c) => { a[c] = "http://"+c; return a; }, {})),
cluster_key: (mergedConfig.etcd_prefix || '/vitastor'), cluster_key: (config.etcd_prefix || '/vitastor'),
stale_read: 1, stale_read: 1,
log_level: 1,
}; };
for (const key in config) for (const key in config)
{ {
@ -60,6 +53,7 @@ class AntiEtcdAdapter
} }
} }
} }
console.log('Starting Antietcd node '+antietcd_config.node_id);
antietcd = new AntiEtcd(antietcd_config); antietcd = new AntiEtcd(antietcd_config);
await antietcd.start(); await antietcd.start();
} }
@ -128,20 +122,23 @@ class AntiEtcdAdapter
async become_master() async become_master()
{ {
if (!this.antietcd.raft) if (!this.antietcd.cluster)
{ {
console.log('Running in non-clustered mode'); console.log('Running in non-clustered mode');
} }
else else
{ {
console.log('Waiting to become master'); console.log('Waiting to become master');
await new Promise(ok => this.on_leader.push(ok)); if (this.antietcd.cluster.raft.state !== 'leader')
{
await new Promise(ok => this.on_leader.push(ok));
}
} }
const state = { ...this.mon.get_mon_state(), id: ''+this.mon.etcd_lease_id }; const state = { ...this.mon.get_mon_state(), id: ''+this.mon.etcd_lease_id };
await this.etcd_call('/kv/txn', { await this.etcd_call('/kv/txn', {
success: [ { requestPut: { key: b64(this.mon.config.etcd_prefix+'/mon/master'), value: b64(JSON.stringify(state)), lease: ''+this.mon.etcd_lease_id } } ], success: [ { requestPut: { key: b64(this.mon.config.etcd_prefix+'/mon/master'), value: b64(JSON.stringify(state)), lease: ''+this.mon.etcd_lease_id } } ],
}, this.mon.config.etcd_start_timeout, 0); }, this.mon.config.etcd_start_timeout, 0);
if (this.antietcd.raft) if (this.antietcd.cluster)
{ {
console.log('Became master'); console.log('Became master');
} }

View File

@ -30,7 +30,11 @@ async function create_http_server(cfg, handler)
} }
try try
{ {
let err;
server.once('error', e => err = e);
server.listen(cfg.mon_http_port || 8060, cfg.mon_http_ip || undefined); server.listen(cfg.mon_http_port || 8060, cfg.mon_http_ip || undefined);
if (err)
throw err;
} }
catch (e) catch (e)
{ {

View File

@ -9,7 +9,7 @@
"author": "Vitaliy Filippov", "author": "Vitaliy Filippov",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"antietcd": "^1.0.5", "antietcd": "^1.1.0",
"sprintf-js": "^1.1.2", "sprintf-js": "^1.1.2",
"ws": "^7.2.5" "ws": "^7.2.5"
}, },

View File

@ -24,7 +24,7 @@ function vitastor_persist_filter(cfg)
catch (e) catch (e)
{ {
console.error('invalid JSON in '+key+' = '+value+': '+e); console.error('invalid JSON in '+key+' = '+value+': '+e);
value = {}; value = '{}';
} }
} }
else else

View File

@ -24,6 +24,7 @@ ETCD=${ETCD:-etcd}
ETCD_IP=${ETCD_IP:-127.0.0.1} ETCD_IP=${ETCD_IP:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-12379} ETCD_PORT=${ETCD_PORT:-12379}
ETCD_COUNT=${ETCD_COUNT:-1} ETCD_COUNT=${ETCD_COUNT:-1}
ANTIETCD=${ANTIETCD}
if [ "$KEEP_DATA" = "" ]; then if [ "$KEEP_DATA" = "" ]; then
rm -rf ./testdata rm -rf ./testdata
@ -32,36 +33,59 @@ if [ "$KEEP_DATA" = "" ]; then
fi fi
ETCD_URL="http://$ETCD_IP:$ETCD_PORT" ETCD_URL="http://$ETCD_IP:$ETCD_PORT"
ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT+1))"
for i in $(seq 2 $ETCD_COUNT); do for i in $(seq 2 $ETCD_COUNT); do
ETCD_URL="$ETCD_URL,http://$ETCD_IP:$((ETCD_PORT+2*i-2))" ETCD_URL="$ETCD_URL,http://$ETCD_IP:$((ETCD_PORT+2*i-2))"
ETCD_CLUSTER="$ETCD_CLUSTER,etcd$i=http://$ETCD_IP:$((ETCD_PORT+2*i-1))"
done done
ETCDCTL="${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=5s --command-timeout=10s"
start_etcd() start_etcd()
{ {
local i=$1 local i=$1
local t=/run/user/$(id -u) if [[ -z "$ANTIETCD" ]]; then
findmnt $t >/dev/null || (sudo mkdir -p $t && sudo mount -t tmpfs tmpfs $t) local t=/run/user/$(id -u)
ionice -c2 -n0 $ETCD -name etcd$i --data-dir /run/user/$(id -u)/testdata_etcd$i \ findmnt $t >/dev/null || (sudo mkdir -p $t && sudo mount -t tmpfs tmpfs $t)
--advertise-client-urls http://$ETCD_IP:$((ETCD_PORT+2*i-2)) --listen-client-urls http://$ETCD_IP:$((ETCD_PORT+2*i-2)) \ ionice -c2 -n0 $ETCD -name etcd$i --data-dir /run/user/$(id -u)/testdata_etcd$i \
--initial-advertise-peer-urls http://$ETCD_IP:$((ETCD_PORT+2*i-1)) --listen-peer-urls http://$ETCD_IP:$((ETCD_PORT+2*i-1)) \ --advertise-client-urls http://$ETCD_IP:$((ETCD_PORT+2*i-2)) --listen-client-urls http://$ETCD_IP:$((ETCD_PORT+2*i-2)) \
--initial-cluster-token vitastor-tests-etcd --initial-cluster-state new \ --initial-advertise-peer-urls http://$ETCD_IP:$((ETCD_PORT+2*i-1)) --listen-peer-urls http://$ETCD_IP:$((ETCD_PORT+2*i-1)) \
--initial-cluster "$ETCD_CLUSTER" --max-request-bytes=104857600 \ --initial-cluster-token vitastor-tests-etcd --initial-cluster-state new \
--max-txn-ops=100000 --auto-compaction-retention=10 --auto-compaction-mode=revision &>./testdata/etcd$i.log & --initial-cluster "$ETCD_CLUSTER" --max-request-bytes=104857600 \
eval ETCD${i}_PID=$! --max-txn-ops=100000 --auto-compaction-retention=10 --auto-compaction-mode=revision &>./testdata/etcd$i.log &
eval ETCD${i}_PID=$!
else
node mon/mon-main.js $MON_PARAMS --antietcd_port $((ETCD_PORT+2*i-2)) --etcd_address $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 >>./testdata/mon$i.log 2>&1 &
eval ETCD${i}_PID=$!
fi
} }
for i in $(seq 1 $ETCD_COUNT); do start_etcd_cluster()
start_etcd $i {
done ETCD_CLUSTER="etcd1=http://$ETCD_IP:$((ETCD_PORT+1))"
for i in {1..30}; do for i in $(seq 2 $ETCD_COUNT); do
${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=1s --command-timeout=1s member list >/dev/null && break ETCD_CLUSTER="$ETCD_CLUSTER,etcd$i=http://$ETCD_IP:$((ETCD_PORT+2*i-1))"
if [[ $i = 30 ]]; then done
format_error "Failed to start etcd" for i in $(seq 1 $ETCD_COUNT); do
fi start_etcd $i
done done
}
wait_etcd()
{
for i in {1..30}; do
$ETCDCTL --dial-timeout=1s --command-timeout=1s get --prefix / && break
if [[ $i = 30 ]]; then
format_error "Failed to start etcd"
fi
sleep 1
done
}
if [[ -n "$ANTIETCD" ]]; then
ETCDCTL="node mon/node_modules/.bin/anticli -e $ETCD_URL"
MON_PARAMS="--use_antietcd 1 --antietcd_data_dir ./testdata --antietcd_persist_interval 500 $MON_PARAMS"
else
ETCDCTL="${ETCD}ctl --endpoints=$ETCD_URL --dial-timeout=5s --command-timeout=10s"
MON_PARAMS="$MON_PARAMS"
start_etcd_cluster
fi
echo leak:fio >> testdata/lsan-suppress.txt echo leak:fio >> testdata/lsan-suppress.txt
echo leak:tcmalloc >> testdata/lsan-suppress.txt echo leak:tcmalloc >> testdata/lsan-suppress.txt

View File

@ -18,6 +18,16 @@ else
OSD_COUNT=${OSD_COUNT:-3} OSD_COUNT=${OSD_COUNT:-3}
fi fi
if [[ -n "$ANTIETCD" ]]; then
for i in $(seq 1 $ETCD_COUNT); do
start_etcd $i
done
else
node mon/mon-main.js $MON_PARAMS --etcd_address $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 >>./testdata/mon.log 2>&1 &
MON_PID=$!
fi
wait_etcd
if [ "$IMMEDIATE_COMMIT" != "" ]; then if [ "$IMMEDIATE_COMMIT" != "" ]; then
NO_SAME="--journal_no_same_sector_overwrites true --journal_sector_buffer_count 1024 --disable_data_fsync 1 --immediate_commit all --log_level 10 --etcd_stats_interval 5" NO_SAME="--journal_no_same_sector_overwrites true --journal_sector_buffer_count 1024 --disable_data_fsync 1 --immediate_commit all --log_level 10 --etcd_stats_interval 5"
$ETCDCTL put /vitastor/config/global '{"recovery_queue_depth":1,"recovery_tune_util_low":1,"immediate_commit":"all","client_enable_writeback":true,"client_max_writeback_iodepth":32'$GLOBAL_CONFIG'}' $ETCDCTL put /vitastor/config/global '{"recovery_queue_depth":1,"recovery_tune_util_low":1,"immediate_commit":"all","client_enable_writeback":true,"client_max_writeback_iodepth":32'$GLOBAL_CONFIG'}'
@ -54,9 +64,6 @@ for i in $(seq 1 $OSD_COUNT); do
start_osd $i start_osd $i
done done
node mon/mon-main.js --etcd_address $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 >>./testdata/mon.log 2>&1 &
MON_PID=$!
if [ "$SCHEME" = "ec" ]; then if [ "$SCHEME" = "ec" ]; then
PG_SIZE=${PG_SIZE:-5} PG_SIZE=${PG_SIZE:-5}
PG_MINSIZE=${PG_MINSIZE:-4} PG_MINSIZE=${PG_MINSIZE:-4}

View File

@ -15,6 +15,7 @@ SCHEME=ec ./test_change_pg_count.sh
./test_create_nomaxid.sh ./test_create_nomaxid.sh
./test_etcd_fail.sh ./test_etcd_fail.sh
ANTIETCD=1 ./test_etcd_fail.sh
./test_interrupted_rebalance.sh ./test_interrupted_rebalance.sh
IMMEDIATE_COMMIT=1 ./test_interrupted_rebalance.sh IMMEDIATE_COMMIT=1 ./test_interrupted_rebalance.sh
@ -56,6 +57,7 @@ SCHEME=xor ./test_write.sh
PG_SIZE=2 ./test_heal.sh PG_SIZE=2 ./test_heal.sh
SCHEME=ec ./test_heal.sh SCHEME=ec ./test_heal.sh
ANTIETCD=1 ./test_heal.sh
TEST_NAME=csum_32k_dmj OSD_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_metadata false --inmemory_journal false" OFFSET_ARGS=$OSD_ARGS ./test_heal.sh TEST_NAME=csum_32k_dmj OSD_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_metadata false --inmemory_journal false" OFFSET_ARGS=$OSD_ARGS ./test_heal.sh
TEST_NAME=csum_32k_dj OSD_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_journal false" OFFSET_ARGS=$OSD_ARGS ./test_heal.sh TEST_NAME=csum_32k_dj OSD_ARGS="--data_csum_type crc32c --csum_block_size 32k --inmemory_journal false" OFFSET_ARGS=$OSD_ARGS ./test_heal.sh

View File

@ -2,6 +2,10 @@
. `dirname $0`/common.sh . `dirname $0`/common.sh
node mon/mon-main.js $MON_PARAMS --etcd_address $ETCD_URL --etcd_prefix "/vitastor" >>./testdata/mon.log 2>&1 &
MON_PID=$!
wait_etcd
TIME=$(date '+%s') TIME=$(date '+%s')
$ETCDCTL put /vitastor/config/global '{"placement_levels":{"rack":1,"host":2,"osd":3},"immediate_commit":"none"}' $ETCDCTL put /vitastor/config/global '{"placement_levels":{"rack":1,"host":2,"osd":3},"immediate_commit":"none"}'
$ETCDCTL put /vitastor/config/node_placement '{"rack1":{"level":"rack"},"rack2":{"level":"rack"},"host1":{"level":"host","parent":"rack1"},"host2":{"level":"host","parent":"rack1"},"host3":{"level":"host","parent":"rack2"},"host4":{"level":"host","parent":"rack2"}}' $ETCDCTL put /vitastor/config/node_placement '{"rack1":{"level":"rack"},"rack2":{"level":"rack"},"host1":{"level":"host","parent":"rack1"},"host2":{"level":"host","parent":"rack1"},"host3":{"level":"host","parent":"rack2"},"host4":{"level":"host","parent":"rack2"}}'
@ -22,12 +26,9 @@ $ETCDCTL get --print-value-only /vitastor/config/pools | jq -s -e '. == [{}]'
build/src/cmd/vitastor-cli --etcd_address $ETCD_URL create-pool testpool -s 2 -n 4 --failure_domain rack --force build/src/cmd/vitastor-cli --etcd_address $ETCD_URL create-pool testpool -s 2 -n 4 --failure_domain rack --force
$ETCDCTL get --print-value-only /vitastor/config/pools | jq -s -e '. == [{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":4,"failure_domain":"rack"}}]' $ETCDCTL get --print-value-only /vitastor/config/pools | jq -s -e '. == [{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":4,"failure_domain":"rack"}}]'
node mon/mon-main.js --etcd_address $ETCD_URL --etcd_prefix "/vitastor" >>./testdata/mon.log 2>&1 &
MON_PID=$!
sleep 2 sleep 2
etcdctl --endpoints=http://localhost:12379 get --prefix /vitastor/config/pgs --print-value-only | \ $ETCDCTL get --prefix /vitastor/config/pgs --print-value-only | \
jq -s -e '([ .[0].items["1"] | .[].osd_set | map_values(. | tonumber) | select((.[0] <= 4) != (.[1] <= 4)) ] | length) == 4' jq -s -e '([ .[0].items["1"] | .[].osd_set | map_values(. | tonumber) | select((.[0] <= 4) != (.[1] <= 4)) ] | length) == 4'
format_green OK format_green OK

View File

@ -1,5 +1,7 @@
#!/bin/bash -ex #!/bin/bash -ex
USE_ANTIETCD=""
. `dirname $0`/common.sh . `dirname $0`/common.sh
OSD_SIZE=1024 OSD_SIZE=1024

View File

@ -2,6 +2,10 @@
. `dirname $0`/common.sh . `dirname $0`/common.sh
node mon/mon-main.js $MON_PARAMS --etcd_address $ETCD_URL --etcd_prefix "/vitastor" >>./testdata/mon.log 2>&1 &
MON_PID=$!
wait_etcd
TIME=$(date '+%s') TIME=$(date '+%s')
$ETCDCTL put /vitastor/config/osd/1 '{"tags":["a"]}' $ETCDCTL put /vitastor/config/osd/1 '{"tags":["a"]}'
$ETCDCTL put /vitastor/config/osd/2 '{"tags":["a"]}' $ETCDCTL put /vitastor/config/osd/2 '{"tags":["a"]}'
@ -21,15 +25,12 @@ $ETCDCTL put /vitastor/osd/stats/7 '{"host":"stor4","size":1073741824,"time":"'$
$ETCDCTL put /vitastor/osd/stats/8 '{"host":"stor4","size":1073741824,"time":"'$TIME'"}' $ETCDCTL put /vitastor/osd/stats/8 '{"host":"stor4","size":1073741824,"time":"'$TIME'"}'
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":2,"pg_count":16,"failure_domain":"host","osd_tags":["a"],"immediate_commit":"none"}}' $ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":2,"pg_count":16,"failure_domain":"host","osd_tags":["a"],"immediate_commit":"none"}}'
node mon/mon-main.js --etcd_address $ETCD_URL --etcd_prefix "/vitastor" >>./testdata/mon.log 2>&1 &
MON_PID=$!
sleep 2 sleep 2
etcdctl --endpoints=http://localhost:12379 get --prefix /vitastor/config/pgs --print-value-only $ETCDCTL get --prefix /vitastor/config/pgs --print-value-only
if ! (etcdctl --endpoints=http://localhost:12379 get --prefix /vitastor/config/pgs --print-value-only | \ if ! ($ETCDCTL get --prefix /vitastor/config/pgs --print-value-only | \
jq -s -e '[ [ .[0].items["1"] | .[].osd_set | map(. | select(. != "" and (.|tonumber) < 5)) ][] | select((. | length) == 2) ] | length == 16'); then jq -s -e '[ [ .[] | select(has("items")) | .items["1"] | .[].osd_set | map(. | select(. != "" and (.|tonumber) < 5)) ][] | select((. | length) == 2) ] | length == 16'); then
format_error "Some PGs missing replicas" format_error "Some PGs missing replicas"
fi fi

View File

@ -2,6 +2,10 @@
. `dirname $0`/common.sh . `dirname $0`/common.sh
node mon/mon-main.js $MON_PARAMS --etcd_address $ETCD_URL --etcd_prefix "/vitastor" >>./testdata/mon.log 2>&1 &
MON_PID=$!
wait_etcd
TIME=$(date '+%s') TIME=$(date '+%s')
$ETCDCTL put /vitastor/config/global '{"placement_levels":{"rack":100,"host":101,"osd":102},"immediate_commit":"none"}' $ETCDCTL put /vitastor/config/global '{"placement_levels":{"rack":100,"host":101,"osd":102},"immediate_commit":"none"}'
$ETCDCTL put /vitastor/config/node_placement '{"rack1":{"level":"rack"},"rack2":{"level":"rack"},"stor1":{"level":"host","parent":"rack1"},"stor2":{"level":"host","parent":"rack1"},"stor3":{"level":"host","parent":"rack2"},"stor4":{"level":"host","parent":"rack2"}}' $ETCDCTL put /vitastor/config/node_placement '{"rack1":{"level":"rack"},"rack2":{"level":"rack"},"stor1":{"level":"host","parent":"rack1"},"stor2":{"level":"host","parent":"rack1"},"stor3":{"level":"host","parent":"rack2"},"stor4":{"level":"host","parent":"rack2"}}'
@ -15,14 +19,11 @@ $ETCDCTL put /vitastor/osd/stats/7 '{"host":"stor4","size":1073741824,"time":"'$
$ETCDCTL put /vitastor/osd/stats/8 '{"host":"stor4","size":1073741824,"time":"'$TIME'"}' $ETCDCTL put /vitastor/osd/stats/8 '{"host":"stor4","size":1073741824,"time":"'$TIME'"}'
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":2,"pg_count":16,"failure_domain":"host","root_node":"rack1"}}' $ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":2,"pg_count":16,"failure_domain":"host","root_node":"rack1"}}'
node mon/mon-main.js --etcd_address $ETCD_URL --etcd_prefix "/vitastor" >>./testdata/mon.log 2>&1 &
MON_PID=$!
sleep 2 sleep 2
etcdctl --endpoints=http://localhost:12379 get --prefix /vitastor/config/pgs --print-value-only $ETCDCTL get --prefix /vitastor/config/pgs --print-value-only
if ! (etcdctl --endpoints=http://localhost:12379 get --prefix /vitastor/config/pgs --print-value-only | \ if ! ($ETCDCTL get --prefix /vitastor/config/pgs --print-value-only | \
jq -s -e '[ [ .[0].items["1"] | .[].osd_set | map(. | select(. != "" and (.|tonumber) < 5)) ][] | select((. | length) == 2) ] | length == 16'); then jq -s -e '[ [ .[0].items["1"] | .[].osd_set | map(. | select(. != "" and (.|tonumber) < 5)) ][] | select((. | length) == 2) ] | length == 16'); then
format_error "Some PGs missing replicas" format_error "Some PGs missing replicas"
fi fi

View File

@ -3,9 +3,13 @@
export KEEP_DATA=1 export KEEP_DATA=1
. `dirname $0`/common.sh . `dirname $0`/common.sh
etcdctl --endpoints=http://127.0.0.1:12379/v3 del --prefix /vitastor/mon/master node mon/mon-main.js $MON_PARAMS --etcd_address $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 >>./testdata/mon.log 2>&1 &
etcdctl --endpoints=http://127.0.0.1:12379/v3 del --prefix /vitastor/pg/state MON_PID=$!
etcdctl --endpoints=http://127.0.0.1:12379/v3 del --prefix /vitastor/osd/state wait_etcd
$ETCDCTL del --prefix /vitastor/mon/master
$ETCDCTL del --prefix /vitastor/pg/state
$ETCDCTL del --prefix /vitastor/osd/state
OSD_COUNT=3 OSD_COUNT=3
OSD_ARGS="$OSD_ARGS" OSD_ARGS="$OSD_ARGS"
@ -15,9 +19,6 @@ for i in $(seq 1 $OSD_COUNT); do
eval OSD${i}_PID=$! eval OSD${i}_PID=$!
done done
node mon/mon-main.js --etcd_address $ETCD_URL --etcd_prefix "/vitastor" --verbose 1 >>./testdata/mon.log 2>&1 &
MON_PID=$!
sleep 3 sleep 3
if ! ($ETCDCTL get /vitastor/pg/state/1/1 --print-value-only | jq -s -e '(. | length) != 0 and .[0].state == ["active"]'); then if ! ($ETCDCTL get /vitastor/pg/state/1/1 --print-value-only | jq -s -e '(. | length) != 0 and .[0].state == ["active"]'); then