From 8594bd4d619a7d09797b2a07064e6825db4f70bc Mon Sep 17 00:00:00 2001 From: kannanjgithub <29600796+kannanjgithub@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:33:19 +0000 Subject: [PATCH] Automated change: Fix sanity tests --- src/core/telemetry/instrument.cc | 3 +- src/core/telemetry/instrument.h | 7 ++-- test/core/telemetry/instrument_test.cc | 8 ++--- test/cpp/interop/client.cc | 6 ++-- tools/run_tests/python_utils/jobset.py | 7 ++-- tools/run_tests/run_interop_tests.py | 49 ++++++++++++++++---------- 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/core/telemetry/instrument.cc b/src/core/telemetry/instrument.cc index 64f019ea67b7b..3d3ca3a84bd5b 100644 --- a/src/core/telemetry/instrument.cc +++ b/src/core/telemetry/instrument.cc @@ -43,6 +43,7 @@ #include "absl/functional/function_ref.h" #include "absl/hash/hash.h" #include "absl/log/log.h" +#include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" @@ -75,7 +76,7 @@ InstrumentLabel::InstrumentLabel(absl::string_view label) { auto* current_value = labels[i].load(std::memory_order_acquire); while (current_value == nullptr) { if (label_copy == nullptr) { - label_copy.reset(new std::string(label)); + label_copy = absl::make_unique(label); } if (!labels[i].compare_exchange_weak(current_value, label_copy.get(), std::memory_order_acq_rel)) { diff --git a/src/core/telemetry/instrument.h b/src/core/telemetry/instrument.h index d3720c1c3a82f..cb1a99c7537d7 100644 --- a/src/core/telemetry/instrument.h +++ b/src/core/telemetry/instrument.h @@ -232,7 +232,7 @@ class InstrumentLabel { InstrumentLabel() : index_(kSentinelIndex) {} explicit InstrumentLabel(absl::string_view label); - InstrumentLabel(const char* label) + explicit InstrumentLabel(const char* label) : InstrumentLabel(absl::string_view(label)) {} static InstrumentLabel FromIndex(uint8_t index) { @@ -634,7 +634,7 @@ class QueryableDomain { protected: QueryableDomain(std::string name, InstrumentLabelList label_names, size_t map_shards_size) - : label_names_(std::move(label_names)), + : label_names_(label_names), map_shards_size_(label_names_.empty() ? 1 : map_shards_size), map_shards_(std::make_unique(map_shards_size_)), name_(std::move(name)) {} @@ -881,7 +881,6 @@ class MetricsQuery { void Apply(InstrumentLabelList label_names, absl::FunctionRef fn, MetricsSink& sink) const; - private: void ApplyLabelChecks(InstrumentLabelList label_names, absl::FunctionRef fn, MetricsSink& sink) const; @@ -1162,7 +1161,7 @@ class InstrumentDomain { protected: template - static const FixedInstrumentLabelList MakeLabels( + static FixedInstrumentLabelList MakeLabels( Label... labels) { InstrumentLabel l[] = {InstrumentLabel(labels)...}; for (size_t i = 0; i < sizeof...(Label); ++i) { diff --git a/test/core/telemetry/instrument_test.cc b/test/core/telemetry/instrument_test.cc index bf326ef3eb3dd..0a9176296960f 100644 --- a/test/core/telemetry/instrument_test.cc +++ b/test/core/telemetry/instrument_test.cc @@ -1057,7 +1057,7 @@ TEST_F(InstrumentLabelTest, CopyAndMove) { EXPECT_EQ(label1, label2); EXPECT_EQ(label1.index(), label2.index()); - InstrumentLabel label3(std::move(label1)); + InstrumentLabel label3(label1); EXPECT_EQ(label2, label3); EXPECT_EQ(label2.index(), label3.index()); @@ -1067,7 +1067,7 @@ TEST_F(InstrumentLabelTest, CopyAndMove) { EXPECT_EQ(label2.index(), label4.index()); InstrumentLabel label5("baz"); - label5 = std::move(label2); + label5 = label2; EXPECT_EQ(label3, label5); EXPECT_EQ(label3.index(), label5.index()); } @@ -1114,7 +1114,7 @@ TEST_F(InstrumentLabelListTest, CopyAndMove) { EXPECT_EQ(list2[0].label(), "foo"); EXPECT_EQ(list2[1].label(), "bar"); - InstrumentLabelList list3(std::move(list1)); + InstrumentLabelList list3(list1); EXPECT_EQ(list3.size(), 2); EXPECT_EQ(list3[0].label(), "foo"); EXPECT_EQ(list3[1].label(), "bar"); @@ -1126,7 +1126,7 @@ TEST_F(InstrumentLabelListTest, CopyAndMove) { EXPECT_EQ(list4[1].label(), "bar"); InstrumentLabelList list5; - list5 = std::move(list2); + list5 = list2; EXPECT_EQ(list5.size(), 2); EXPECT_EQ(list5[0].label(), "foo"); EXPECT_EQ(list5[1].label(), "bar"); diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index ade7326a34d65..758186df91915 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -216,7 +216,8 @@ int main(int argc, char** argv) { } grpc::testing::ChannelCreationFunc channel_creation_func = [test_case, &additional_metadata](grpc::ChannelArguments arguments) { - std::cout << "channel creation function called for testcase " << test_case; + std::cout << "channel creation function called for testcase " + << test_case; std::cout.flush(); std::vector> @@ -231,7 +232,8 @@ int main(int argc, char** argv) { new grpc::testing::MetadataAndStatusLoggerInterceptorFactory()); } if (test_case == "mcs_cs") { - arguments.SetServiceConfigJSON("{\"connectionScaling\":{\"maxConnectionsPerSubchannel\": 2}}"); + arguments.SetServiceConfigJSON( + "{\"connectionScaling\":{\"maxConnectionsPerSubchannel\": 2}}"); } else { std::string service_config_json = absl::GetFlag(FLAGS_service_config_json); diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index 724ab294048e1..6be456ee1d055 100755 --- a/tools/run_tests/python_utils/jobset.py +++ b/tools/run_tests/python_utils/jobset.py @@ -323,7 +323,7 @@ def start(self): cmdline = ["time", "-p"] + cmdline else: measure_cpu_costs = False - print('Starting subprocess for cmdline: ' + str(cmdline), True) + print("Starting subprocess for cmdline: " + str(cmdline), True) try_start = lambda: subprocess.Popen( args=cmdline, stderr=subprocess.STDOUT, @@ -694,7 +694,10 @@ def run( max_time, ) for cmdline, remaining in tag_remaining(cmdlines): - print('jobset.run calling start on cmdline, shortname being: ' + cmdline.shortname) + print( + "jobset.run calling start on cmdline, shortname being: " + + cmdline.shortname + ) if not js.start(cmdline): break if remaining is not None: diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 33ccf2f9f2298..7a9674571fca1 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -1129,7 +1129,11 @@ def cloud_to_cloud_jobspec( def server_jobspec( - language, docker_image, transport_security="tls", manual_cmd_log=None, use_mcs=False + language, + docker_image, + transport_security="tls", + manual_cmd_log=None, + use_mcs=False, ): """Create jobspec for running a server""" container_name = dockerjob.random_name( @@ -1152,11 +1156,11 @@ def server_jobspec( server_cmd += ["--use_mcs=true"] cmdline = bash_cmdline(language.server_cmd(server_cmd)) for cmd in cmdline: - print('server_jobspec: cmd: ' + cmd) - if hasattr(cmd, 'shortname'): - print('cmd has shortname: ' + cmd.shortname) - else: - print('cmd doesnt have shortname.') + print("server_jobspec: cmd: " + cmd) + if hasattr(cmd, "shortname"): + print("cmd has shortname: " + cmd.shortname) + else: + print("cmd doesnt have shortname.") environ = language.global_env() docker_args = ["--name=%s" % container_name] if language.safename == "http2": @@ -1813,7 +1817,9 @@ def aggregate_http2_results(stdout): if args.mcs_cs: if not args.use_docker: - print('MCS connection scaling test can only be run with --use-docker') + print( + "MCS connection scaling test can only be run with --use-docker" + ) else: languages_for_mcs_cs = set( _LANGUAGES[l] @@ -1821,22 +1827,24 @@ def aggregate_http2_results(stdout): if "all" in args.language or l in args.language ) if len(languages_for_mcs_cs) > 0: - print('Using java for MCS connection scaling server ignoring any args for server languages') + print( + "Using java for MCS connection scaling server ignoring any args for server languages" + ) mcs_server_jobspec = server_jobspec( - _LANGUAGES['java'], - docker_images.get('java'), + _LANGUAGES["java"], + docker_images.get("java"), args.transport_security, manual_cmd_log=server_manual_cmd_log, use_mcs=True, ) mcs_server_job = dockerjob.DockerJob(mcs_server_jobspec) - + for language in languages_for_mcs_cs: test_job = cloud_to_cloud_jobspec( language, - 'mcs_cs', - 'java-mcs', - 'localhost', + "mcs_cs", + "java-mcs", + "localhost", mcs_server_job.mapped_port(_DEFAULT_SERVER_PORT), docker_image=docker_images.get(str(language)), transport_security=args.transport_security, @@ -1844,8 +1852,10 @@ def aggregate_http2_results(stdout): ) jobs.append(test_job) else: - print('MCS connection scaling tests will be skipped since none of the supported client languages for MCS connection scaling testcases was specified') - + print( + "MCS connection scaling tests will be skipped since none of the supported client languages for MCS connection scaling testcases was specified" + ) + if not jobs: print("No jobs to run.") for image in docker_images.values(): @@ -1856,7 +1866,10 @@ def aggregate_http2_results(stdout): print("All tests will skipped --manual_run option is active.") if args.verbose: - print(str(len(jobs)) + " jobs to run: \n%s\n" % "\n".join(str(job) for job in jobs)) + print( + str(len(jobs)) + + " jobs to run: \n%s\n" % "\n".join(str(job) for job in jobs) + ) num_failures, resultset = jobset.run( jobs, @@ -1864,7 +1877,7 @@ def aggregate_http2_results(stdout): maxjobs=args.jobs, skip_jobs=args.manual_run, ) - print('num_failures from jobset.run: ' + str(num_failures)) + print("num_failures from jobset.run: " + str(num_failures)) if args.bq_result_table and resultset: upload_interop_results_to_bq(resultset, args.bq_result_table) if num_failures: