Pass the checked device nodes to the OSD in vitastor-disk exec-osd #110
@@ -1265,6 +1265,24 @@ jobs:
|
||||
echo ""
|
||||
done
|
||||
|
||||
test_disk_exec_osd:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
container: ${{env.TEST_IMAGE}}:${{github.sha}}
|
||||
steps:
|
||||
- name: Run test
|
||||
id: test
|
||||
timeout-minutes: 3
|
||||
run: /root/vitastor/tests/test_disk_exec_osd.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_root_node:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
|
||||
@@ -313,16 +313,30 @@ int disk_tool_t::exec_osd(std::string device)
|
||||
return 1;
|
||||
}
|
||||
std::string osd_binary = "vitastor-osd";
|
||||
if (options["osd-binary"] != "")
|
||||
if (options["osd_binary"] != "")
|
||||
{
|
||||
osd_binary = options["osd-binary"];
|
||||
osd_binary = options["osd_binary"];
|
||||
}
|
||||
// Pass the nodes checked above, not the by-partuuid links: a link can move to another node meanwhile
|
||||
std::string real_data = sb["real_data_device"].string_value();
|
||||
std::string real_meta = sb["real_meta_device"].string_value() != "" ? sb["real_meta_device"].string_value() : real_data;
|
||||
std::map<std::string, std::string> real_devices = {
|
||||
{ "data_device", real_data },
|
||||
{ "meta_device", real_meta },
|
||||
{ "journal_device", sb["real_journal_device"].string_value() != "" ? sb["real_journal_device"].string_value() : real_meta },
|
||||
};
|
||||
std::vector<std::string> argstr;
|
||||
argstr.push_back(osd_binary.c_str());
|
||||
for (auto & kv: sb["params"].object_items())
|
||||
{
|
||||
std::string value = kv.second.is_string() ? kv.second.string_value() : kv.second.dump();
|
||||
auto real_it = real_devices.find(kv.first);
|
||||
if (real_it != real_devices.end() && value != "")
|
||||
{
|
||||
value = real_it->second;
|
||||
}
|
||||
argstr.push_back("--"+kv.first);
|
||||
argstr.push_back(kv.second.is_string() ? kv.second.string_value() : kv.second.dump());
|
||||
argstr.push_back(value);
|
||||
}
|
||||
char *argv[argstr.size()+1];
|
||||
for (int i = 0; i < argstr.size(); i++)
|
||||
|
||||
@@ -102,6 +102,8 @@ OLD=1 SCHEME=ec IMMEDIATE_COMMIT=1 ./test_rebalance_verify.sh
|
||||
|
||||
./test_cli_help.sh
|
||||
|
||||
./test_disk_exec_osd.sh
|
||||
|
||||
./test_root_node.sh
|
||||
|
||||
./test_switch_primary.sh
|
||||
|
||||
25
tests/test_disk_exec_osd.sh
Executable file
25
tests/test_disk_exec_osd.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
# vitastor-disk exec-osd must start the binary given with --osd-binary
|
||||
|
||||
. `dirname $0`/common.sh
|
||||
|
||||
[[ -e build/src/disk_tool/vitastor-disk-test ]] || ln -s vitastor-disk build/src/disk_tool/vitastor-disk-test
|
||||
|
||||
dd if=/dev/zero of=./testdata/bin/sb.bin bs=4096 count=8
|
||||
echo '{"osd_num":1,"data_device":"'`realpath ./testdata/bin/sb.bin`'"}' | \
|
||||
build/src/disk_tool/vitastor-disk-test write-sb --io cached ./testdata/bin/sb.bin
|
||||
|
||||
ARGS=`build/src/disk_tool/vitastor-disk exec-osd --io cached --osd-binary echo ./testdata/bin/sb.bin` || \
|
||||
format_error "exec-osd did not run the --osd-binary"
|
||||
[[ "$ARGS" == "--data_device "*" --osd_num 1" ]] || format_error "exec-osd passed unexpected arguments: $ARGS"
|
||||
|
||||
# exec-osd must pass the device it checked, not the superblock's link: the link can move meanwhile
|
||||
ln -s `realpath ./testdata/bin/sb.bin` ./testdata/bin/sb-link
|
||||
echo '{"osd_num":1,"data_device":"'`realpath ./testdata/bin`/sb-link'"}' | \
|
||||
build/src/disk_tool/vitastor-disk-test write-sb --io cached ./testdata/bin/sb.bin
|
||||
ARGS=`build/src/disk_tool/vitastor-disk exec-osd --io cached --osd-binary echo ./testdata/bin/sb.bin`
|
||||
[[ "$ARGS" == "--data_device `realpath ./testdata/bin/sb.bin` --osd_num 1" ]] || \
|
||||
format_error "exec-osd passed the superblock's link instead of the checked device: $ARGS"
|
||||
|
||||
format_green OK
|
||||
Reference in New Issue
Block a user