From 667cba8cd7cfba558561591e92941cc7b50f0326 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 8 Nov 2024 10:46:43 +0800 Subject: [PATCH] fix: app is localhost in graph from runtime (#245) Co-authored-by: Hu Yueh-Wei --- .../ten_utils/value/value_set.h | 4 - core/src/ten_rust/src/pkg_info/mod.rs | 12 ++- core/src/ten_utils/value/value_set.c | 11 --- tests/ten_runtime/integration/cpp/BUILD.gn | 1 + .../cpp/check_start_graph/BUILD.gn | 52 +++++++++++++ .../cpp/check_start_graph/__init__.py | 0 .../check_start_graph_source/manifest.json | 15 ++++ .../check_start_graph_source/property.json | 18 +++++ .../extension/default_extension_cpp/BUILD.gn | 20 +++++ .../default_extension_cpp/manifest.json | 17 +++++ .../default_extension_cpp/property.json | 1 + .../default_extension_cpp/src/main.cc | 62 ++++++++++++++++ .../cpp/check_start_graph/test_case.py | 74 +++++++++++++++++++ .../128_threads_attempt_to_suspend_1.cc | 6 +- .../32_threads_attempt_to_suspend_1.cc | 38 ++++++++++ .../32_threads_attempt_to_suspend_2.cc | 38 ++++++++++ .../32_threads_attempt_to_suspend_3.cc | 38 ++++++++++ .../32_threads_attempt_to_suspend_4.cc | 38 ++++++++++ .../32_threads_attempt_to_suspend_5.cc | 38 ++++++++++ .../32_threads_attempt_to_suspend_6.cc | 38 ++++++++++ 20 files changed, 503 insertions(+), 18 deletions(-) create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/__init__.py create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/manifest.json create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/property.json create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/BUILD.gn create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/manifest.json create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/property.json create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc create mode 100644 tests/ten_runtime/integration/cpp/check_start_graph/test_case.py diff --git a/core/include_internal/ten_utils/value/value_set.h b/core/include_internal/ten_utils/value/value_set.h index f2122db32..398d22210 100644 --- a/core/include_internal/ten_utils/value/value_set.h +++ b/core/include_internal/ten_utils/value/value_set.h @@ -39,10 +39,6 @@ TEN_UTILS_API bool ten_value_set_string(ten_value_t *self, const char *str); TEN_UTILS_API bool ten_value_set_string_with_size(ten_value_t *self, const char *str, size_t len); -TEN_UTILS_API bool ten_value_set_string_with_size(ten_value_t *self, - const char *value, - size_t len); - TEN_UTILS_API bool ten_value_set_array_with_move(ten_value_t *self, ten_list_t *value); diff --git a/core/src/ten_rust/src/pkg_info/mod.rs b/core/src/ten_rust/src/pkg_info/mod.rs index 059f6a7be..327c28cfd 100644 --- a/core/src/ten_rust/src/pkg_info/mod.rs +++ b/core/src/ten_rust/src/pkg_info/mod.rs @@ -26,7 +26,6 @@ use std::{ collections::{HashMap, HashSet}, hash::{Hash, Hasher}, path::{Path, PathBuf}, - str::FromStr, }; use anyhow::Result; @@ -432,6 +431,15 @@ pub fn ten_rust_check_graph_for_app( let pkgs_info = get_all_existed_pkgs_info_of_app(app_path)?; pkgs_of_app.insert(app_uri.to_string(), pkgs_info); - let graph = Graph::from_str(graph_json)?; + // `Graph::from_str` calls `validate`, and `validate` checks that there are + // no `localhost` entries in the graph JSON (as per our rule). However, the + // TEN runtime first processes the content of the graph JSON, inserting + // the appropriate `localhost` string before passing it to the Rust + // side. Therefore, the graph JSON received here might already includes the + // `localhost` string processed by the TEN runtime, so `Graph::from_str` + // cannot be used in this context. + // + // let graph = Graph::from_str(graph_json)?; + let graph: Graph = serde_json::from_str(graph_json)?; graph.check_for_single_app(&pkgs_of_app) } diff --git a/core/src/ten_utils/value/value_set.c b/core/src/ten_utils/value/value_set.c index 92f3353c1..d912b1b2f 100644 --- a/core/src/ten_utils/value/value_set.c +++ b/core/src/ten_utils/value/value_set.c @@ -131,17 +131,6 @@ bool ten_value_set_string_with_size(ten_value_t *self, const char *str, return true; } -TEN_UTILS_API bool ten_value_set_string_with_size(ten_value_t *self, - const char *value, - size_t len) { - TEN_ASSERT(self && ten_value_check_integrity(self), "Invalid argument."); - TEN_ASSERT(self->type == TEN_TYPE_STRING, "Invalid argument."); - - ten_string_init_formatted(&self->content.string, "%.*s", len, value); - - return true; -} - bool ten_value_set_array_with_move(ten_value_t *self, ten_list_t *value) { TEN_ASSERT(self, "Invalid argument."); TEN_ASSERT(self->type == TEN_TYPE_ARRAY, "Invalid argument."); diff --git a/tests/ten_runtime/integration/cpp/BUILD.gn b/tests/ten_runtime/integration/cpp/BUILD.gn index a20b06b88..ca5fdd77d 100644 --- a/tests/ten_runtime/integration/cpp/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/BUILD.gn @@ -8,6 +8,7 @@ import("//build/ten_runtime/options.gni") group("cpp") { deps = [ + "check_start_graph", "graph_env_var_1", "graph_env_var_2", "graph_env_var_3", diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn b/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn new file mode 100644 index 000000000..10d509746 --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn @@ -0,0 +1,52 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import("//build/ten_runtime/feature/test.gni") +import("//build/ten_runtime/ten.gni") + +ten_package_test_prepare_app("check_start_graph_app") { + src_app = "default_app_cpp" + src_app_language = "cpp" + generated_app_src_root_dir_name = "check_start_graph_source" + + replace_files_after_install_app = [ + "check_start_graph_source/manifest.json", + "check_start_graph_source/property.json", + ] + + replace_files_after_install_all = [ + "check_start_graph_source/ten_packages/extension/default_extension_cpp/manifest.json", + "check_start_graph_source/ten_packages/extension/default_extension_cpp/property.json", + "check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc", + ] + + if (ten_enable_package_manager) { + deps = [ + "//core/src/ten_manager", + "//core/src/ten_runtime:upload_ten_runtime_system_package_to_server", + "//packages/core_apps/default_app_cpp:upload_default_app_cpp_to_server", + "//packages/core_extensions/default_extension_cpp:upload_default_extension_cpp_to_server", + ] + } +} + +ten_package_test_prepare_auxiliary_resources("check_start_graph_test_files") { + resources = [ + "//tests/ten_runtime/integration/common=>common", + "__init__.py", + "test_case.py", + ] + if (enable_sanitizer && !is_clang) { + resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] + } +} + +group("check_start_graph") { + deps = [ + ":check_start_graph_app", + ":check_start_graph_test_files", + ] +} diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/__init__.py b/tests/ten_runtime/integration/cpp/check_start_graph/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/manifest.json b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/manifest.json new file mode 100644 index 000000000..8a2190d1c --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/manifest.json @@ -0,0 +1,15 @@ +{ + "dependencies": [ + { + "type": "system", + "name": "ten_runtime", + "version": "0.3.0" + }, + { + "type": "extension", + "name": "default_extension_cpp", + "version": "0.3.0" + } + ], + "api": {} +} \ No newline at end of file diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/property.json b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/property.json new file mode 100644 index 000000000..4883979a1 --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/property.json @@ -0,0 +1,18 @@ +{ + "_ten": { + "predefined_graphs": [ + { + "name": "default", + "auto_start": true, + "nodes": [ + { + "type": "extension", + "name": "default_extension_cpp", + "addon": "default_extension_cpp", + "extension_group": "default_extension_group" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/BUILD.gn b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/BUILD.gn new file mode 100644 index 000000000..2d84d97d7 --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/BUILD.gn @@ -0,0 +1,20 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import("//build/feature/ten_package.gni") + +ten_package("default_extension_cpp") { + package_kind = "extension" + enable_build = true + + resources = [ + "manifest.json", + "property.json", + ] + + sources = [ "src/main.cc" ] + include_dirs = [ "//core/include" ] +} diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/manifest.json b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/manifest.json new file mode 100644 index 000000000..8a0eff741 --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/manifest.json @@ -0,0 +1,17 @@ +{ + "api": { + "cmd_in": [ + { + "name": "hello_world" + } + ], + "cmd_out": [], + "data_in": [], + "data_out": [], + "video_frame_in": [], + "video_frame_out": [], + "audio_frame_in": [], + "audio_frame_out": [], + "interface_in": [] + } +} \ No newline at end of file diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/property.json b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/property.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/property.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc new file mode 100644 index 000000000..9eb834d48 --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc @@ -0,0 +1,62 @@ +// +// Copyright © 2024 Agora +// This file is part of TEN Framework, an open source project. +// Licensed under the Apache License, Version 2.0, with certain conditions. +// Refer to the "LICENSE" file in the root directory for more information. +// +#include +#include +#include + +#include "ten_runtime/binding/cpp/internal/msg/cmd/close_app.h" +#include "ten_runtime/binding/cpp/internal/ten_env.h" +#include "ten_runtime/binding/cpp/ten.h" + +bool started = false; + +class test_extension : public ten::extension_t { + public: + explicit test_extension(const std::string &name) : ten::extension_t(name) {} + + void on_init(ten::ten_env_t &ten_env) override { ten_env.on_init_done(); } + + void on_start(ten::ten_env_t &ten_env) override { + ten_env.on_start_done(); + + if (!started) { + started = true; + + ten_env.send_json( + R"({ + "_ten": { + "type": "start_graph", + "dest": [{ + "app": "localhost" + }], + "nodes": [ + { + "type": "extension", + "name": "default_extension_cpp", + "addon": "default_extension_cpp", + "extension_group": "default_extension_group" + } + ] + } + })", + [](ten::ten_env_t &env, std::unique_ptr result) { + // The graph check should be passed. + if (result->get_status_code() == TEN_STATUS_CODE_OK) { + auto close_app = ten::cmd_close_app_t::create(); + close_app->set_dest("localhost", nullptr, nullptr, nullptr); + env.send_cmd(std::move(close_app)); + } else { + std::cout << "Failed to start graph: " + << result->get_property_string("detail") << std::endl; + std::exit(1); + } + }); + } + } +}; + +TEN_CPP_REGISTER_ADDON_AS_EXTENSION(default_extension_cpp, test_extension); diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py b/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py new file mode 100644 index 000000000..b896773f6 --- /dev/null +++ b/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py @@ -0,0 +1,74 @@ +""" +Test check_start_graph. +""" + +import subprocess +import os +import sys +from sys import stdout + + +def test_check_start_graph(): + """Test client and app server.""" + base_path = os.path.dirname(os.path.abspath(__file__)) + root_dir = os.path.join(base_path, "../../../../../") + + my_env = os.environ.copy() + + app_root_path = os.path.join(base_path, "check_start_graph_app") + + tman_install_cmd = [ + os.path.join(root_dir, "ten_manager/bin/tman"), + "--config-file", + os.path.join(root_dir, "tests/local_registry/config.json"), + "install", + ] + + tman_install_process = subprocess.Popen( + tman_install_cmd, + stdout=stdout, + stderr=subprocess.STDOUT, + env=my_env, + cwd=app_root_path, + ) + tman_install_process.wait() + + if sys.platform == "win32": + my_env["PATH"] = ( + os.path.join( + app_root_path, + "ten_packages/system/ten_runtime/lib", + ) + + ";" + + my_env["PATH"] + ) + server_cmd = os.path.join( + app_root_path, "bin/check_start_graph_source.exe" + ) + elif sys.platform == "darwin": + server_cmd = os.path.join(app_root_path, "bin/check_start_graph_source") + else: + server_cmd = os.path.join(app_root_path, "bin/check_start_graph_source") + + if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + libasan_path = os.path.join( + app_root_path, + "ten_packages/system/ten_runtime/lib/libasan.so", + ) + if os.path.exists(libasan_path): + my_env["LD_PRELOAD"] = libasan_path + + server = subprocess.Popen( + server_cmd, + stdout=stdout, + stderr=subprocess.STDOUT, + env=my_env, + cwd=app_root_path, + ) + + server_rc = server.wait(10) + if server_rc != 0: + server.kill() + + print("server: ", server_rc) + assert server_rc == 0 diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/128_threads_attempt_to_suspend_1.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/128_threads_attempt_to_suspend_1.cc index 0860c0277..57bf703f2 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/128_threads_attempt_to_suspend_1.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/128_threads_attempt_to_suspend_1.cc @@ -843,11 +843,15 @@ class test_extension_2 : public ten::extension_t { // discarded, causing the test case to hang indefinitely. Therefore, we have // extended the path timeout to avoid this situation. - ten_env.init_property_from_json(R"({ + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ "_ten": { "path_timeout": 1200000000 } })"); + // clang-format on + ASSERT_EQ(rc, true); + ten_env.on_configure_done(); } diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_1.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_1.cc index 0f53d33b7..fd7c2e140 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_1.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_1.cc @@ -99,6 +99,25 @@ class test_extension_1 : public ten::extension_t { OUTER_THREAD_MAIN(31) OUTER_THREAD_MAIN(32) + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_start(ten::ten_env_t &ten_env) override { auto start_to_send_cmd = ten::cmd_t::create("start_to_send"); ten_env.send_cmd(std::move(start_to_send_cmd), @@ -295,6 +314,25 @@ class test_extension_2 : public ten::extension_t { public: explicit test_extension_2(const std::string &name) : ten::extension_t(name) {} + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_cmd(ten::ten_env_t &ten_env, std::unique_ptr cmd) override { if (cmd->get_name() == std::string("start_to_send")) { diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_2.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_2.cc index 88e239866..3e3ead5c4 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_2.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_2.cc @@ -106,6 +106,25 @@ class test_extension_1 : public ten::extension_t { OUTER_THREAD_MAIN(31) OUTER_THREAD_MAIN(32) + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_start(ten::ten_env_t &ten_env) override { auto start_to_send_cmd = ten::cmd_t::create("start_to_send"); ten_env.send_cmd(std::move(start_to_send_cmd), @@ -302,6 +321,25 @@ class test_extension_2 : public ten::extension_t { public: explicit test_extension_2(const std::string &name) : ten::extension_t(name) {} + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_cmd(ten::ten_env_t &ten_env, std::unique_ptr cmd) override { if (cmd->get_name() == std::string("start_to_send")) { diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_3.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_3.cc index 6ae012081..a019f262d 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_3.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_3.cc @@ -97,6 +97,25 @@ class test_extension_1 : public ten::extension_t { OUTER_THREAD_MAIN(31) OUTER_THREAD_MAIN(32) + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_start(ten::ten_env_t &ten_env) override { auto start_to_send_cmd = ten::cmd_t::create("start_to_send"); ten_env.send_cmd(std::move(start_to_send_cmd), @@ -293,6 +312,25 @@ class test_extension_2 : public ten::extension_t { public: explicit test_extension_2(const std::string &name) : ten::extension_t(name) {} + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_cmd(ten::ten_env_t &ten_env, std::unique_ptr cmd) override { if (cmd->get_name() == std::string("start_to_send")) { diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_4.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_4.cc index 4de2e71e6..aca6921fb 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_4.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_4.cc @@ -107,6 +107,25 @@ class test_extension_1 : public ten::extension_t { OUTER_THREAD_MAIN(31) OUTER_THREAD_MAIN(32) + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_start(ten::ten_env_t &ten_env) override { auto start_to_send_cmd = ten::cmd_t::create("start_to_send"); ten_env.send_cmd(std::move(start_to_send_cmd), @@ -303,6 +322,25 @@ class test_extension_2 : public ten::extension_t { public: explicit test_extension_2(const std::string &name) : ten::extension_t(name) {} + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_cmd(ten::ten_env_t &ten_env, std::unique_ptr cmd) override { if (cmd->get_name() == std::string("start_to_send")) { diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_5.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_5.cc index 49c529671..5172c228b 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_5.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_5.cc @@ -109,6 +109,25 @@ class test_extension_1 : public ten::extension_t { OUTER_THREAD_MAIN(31) OUTER_THREAD_MAIN(32) + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_start(ten::ten_env_t &ten_env) override { auto start_to_send_cmd = ten::cmd_t::create("start_to_send"); ten_env.send_cmd(std::move(start_to_send_cmd), @@ -311,6 +330,25 @@ class test_extension_2 : public ten::extension_t { public: explicit test_extension_2(const std::string &name) : ten::extension_t(name) {} + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_cmd(ten::ten_env_t &ten_env, std::unique_ptr cmd) override { if (cmd->get_name() == std::string("start_to_send")) { diff --git a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_6.cc b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_6.cc index 9d4042e78..be5408ce7 100644 --- a/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_6.cc +++ b/tests/ten_runtime/smoke/extension_test/outer_thread/32_threads_attempt_to_suspend_6.cc @@ -110,6 +110,25 @@ class test_extension_1 : public ten::extension_t { OUTER_THREAD_MAIN(31) OUTER_THREAD_MAIN(32) + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_start(ten::ten_env_t &ten_env) override { auto start_to_send_cmd = ten::cmd_t::create("start_to_send"); ten_env.send_cmd(std::move(start_to_send_cmd), @@ -316,6 +335,25 @@ class test_extension_2 : public ten::extension_t { expected_data_received_count(OUTER_THREAD_CNT, OUTER_THREAD_FOR_LOOP_CNT + 1) {} + void on_configure(ten::ten_env_t &ten_env) override { + // We have increased the path timeout to 20 minutes because, under limited + // computing resources, it is easy to exceed the path timeout without + // completing the data transmission. This can lead to the path being + // discarded, causing the test case to hang indefinitely. Therefore, we have + // extended the path timeout to avoid this situation. + + // clang-format off + bool rc = ten_env.init_property_from_json( R"({ + "_ten": { + "path_timeout": 1200000000 + } + })"); + // clang-format on + ASSERT_EQ(rc, true); + + ten_env.on_configure_done(); + } + void on_cmd(ten::ten_env_t &ten_env, std::unique_ptr cmd) override { if (cmd->get_name() == std::string("start_to_send")) {