mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Updated tests
This commit is contained in:
parent
d88de46312
commit
c9a0b1e28e
@ -262,17 +262,14 @@ std::unique_ptr<ShellCommand> ShellCommand::executeImpl(
|
||||
|
||||
std::unique_ptr<ShellCommand> ShellCommand::execute(const ShellCommand::Config & config)
|
||||
{
|
||||
const auto & command = config.command;
|
||||
auto config_copy = config;
|
||||
config_copy.command = "/bin/sh";
|
||||
config_copy.arguments = {"-c", config.command};
|
||||
|
||||
/// Arguments in non-constant chunks of memory (as required for `execv`).
|
||||
/// Moreover, their copying must be done before calling `vfork`, so after `vfork` do a minimum of things.
|
||||
std::vector<char> argv0("sh", &("sh"[3]));
|
||||
std::vector<char> argv1("-c", &("-c"[3]));
|
||||
std::vector<char> argv2(command.data(), command.data() + command.size() + 1);
|
||||
for (const auto & argument : config.arguments)
|
||||
config_copy.arguments.emplace_back(argument);
|
||||
|
||||
char * const argv[] = { argv0.data(), argv1.data(), argv2.data(), nullptr };
|
||||
|
||||
return executeImpl("/bin/sh", argv, config);
|
||||
return executeDirect(config_copy);
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,6 @@ public:
|
||||
|
||||
/// Run the command using /bin/sh -c.
|
||||
/// If terminate_in_destructor is true, send terminate signal in destructor and don't wait process.
|
||||
/// Config arguments are not used in execute.
|
||||
static std::unique_ptr<ShellCommand> execute(const Config & config);
|
||||
|
||||
/// Run the executable with the specified arguments. `arguments` - without argv[0].
|
||||
|
@ -75,12 +75,11 @@ Pipe StorageExecutable::read(
|
||||
}
|
||||
|
||||
ShellCommand::Config config(script_path);
|
||||
|
||||
config.arguments = arguments;
|
||||
for (size_t i = 1; i < inputs.size(); ++i)
|
||||
config.write_fds.emplace_back(i + 2);
|
||||
|
||||
auto process = ShellCommand::execute(config);
|
||||
auto process = ShellCommand::executeDirect(config);
|
||||
|
||||
std::vector<ShellCommandSource::SendDataTask> tasks;
|
||||
tasks.reserve(inputs.size());
|
||||
@ -88,7 +87,7 @@ Pipe StorageExecutable::read(
|
||||
for (size_t i = 0; i < inputs.size(); ++i)
|
||||
{
|
||||
BlockInputStreamPtr input_stream = inputs[i];
|
||||
WriteBufferFromFile * write_buffer;
|
||||
WriteBufferFromFile * write_buffer = nullptr;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
|
@ -35,6 +35,9 @@ def test_executable_function_no_input(started_cluster):
|
||||
def test_executable_function_input(started_cluster):
|
||||
assert node.query("SELECT * FROM executable('test_input.sh', 'TabSeparated', 'value String', (SELECT 1))") == 'Key 1\n'
|
||||
|
||||
def test_executable_function_argument(started_cluster):
|
||||
assert node.query("SELECT * FROM executable('test_argument.sh 1', 'TabSeparated', 'value String')") == 'Key 1\n'
|
||||
|
||||
def test_executable_storage_no_input(started_cluster):
|
||||
node.query("DROP TABLE IF EXISTS test_table")
|
||||
node.query("CREATE TABLE test_table (value UInt64) ENGINE=Executable('test_no_input.sh', 'TabSeparated')")
|
||||
@ -46,3 +49,9 @@ def test_executable_storage_input(started_cluster):
|
||||
node.query("CREATE TABLE test_table (value String) ENGINE=Executable('test_no_input.sh', 'TabSeparated', (SELECT 1))")
|
||||
assert node.query("SELECT * FROM test_table") == '1\n'
|
||||
node.query("DROP TABLE test_table")
|
||||
|
||||
def test_executable_storage_argument(started_cluster):
|
||||
node.query("DROP TABLE IF EXISTS test_table")
|
||||
node.query("CREATE TABLE test_table (value String) ENGINE=Executable('test_argument.sh 1', 'TabSeparated')")
|
||||
assert node.query("SELECT * FROM test_table") == 'Key 1\n'
|
||||
node.query("DROP TABLE test_table")
|
||||
|
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Key $1"
|
@ -1 +1,3 @@
|
||||
while read read_data; do printf "Key $read_data\n"; done
|
||||
#!/bin/bash
|
||||
|
||||
while read read_data; do printf "Key $read_data\n"; done
|
||||
|
@ -1 +1,3 @@
|
||||
echo '1'
|
||||
#!/bin/bash
|
||||
|
||||
echo "1"
|
||||
|
Loading…
Reference in New Issue
Block a user