Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/telemetry/instrument.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<std::string>(label);
}
if (!labels[i].compare_exchange_weak(current_value, label_copy.get(),
std::memory_order_acq_rel)) {
Expand Down
7 changes: 3 additions & 4 deletions src/core/telemetry/instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<MapShard[]>(map_shards_size_)),
name_(std::move(name)) {}
Expand Down Expand Up @@ -881,7 +881,6 @@ class MetricsQuery {
void Apply(InstrumentLabelList label_names,
absl::FunctionRef<void(MetricsSink&)> fn, MetricsSink& sink) const;

private:
void ApplyLabelChecks(InstrumentLabelList label_names,
absl::FunctionRef<void(MetricsSink&)> fn,
MetricsSink& sink) const;
Expand Down Expand Up @@ -1162,7 +1161,7 @@ class InstrumentDomain {

protected:
template <typename... Label>
static const FixedInstrumentLabelList<sizeof...(Label)> MakeLabels(
static FixedInstrumentLabelList<sizeof...(Label)> MakeLabels(
Label... labels) {
InstrumentLabel l[] = {InstrumentLabel(labels)...};
for (size_t i = 0; i < sizeof...(Label); ++i) {
Expand Down
8 changes: 4 additions & 4 deletions test/core/telemetry/instrument_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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());
}
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion test/cpp/interop/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,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);
Expand Down
8 changes: 4 additions & 4 deletions test/cpp/interop/interop_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1378,13 +1378,13 @@ bool InteropClient::DoMcsConnectionScaling() {
LOG(ERROR) << "DoMcsConnectionScaling(): stream1->Write() failed.";
return TransientFailureOrAbort();
}

if (!stream1->Read(&response1)) {
LOG(ERROR) << "DoMcsConnectionScaling(): stream1->Read() failed.";
return TransientFailureOrAbort();
}
std::string clientSocketAddressInCall1 = response1.payload().body();
GRPC_CHECK(clientSocketAddressInCall1.length() > 0);
GRPC_CHECK(!clientSocketAddressInCall1.empty());

VLOG(2) << "Sending Mcs connection scaling streaming rpc2 ...";

Expand All @@ -1402,7 +1402,7 @@ bool InteropClient::DoMcsConnectionScaling() {
if (!stream2->Read(&response2)) {
LOG(ERROR) << "DoMcsConnectionScaling(): stream2->Read() failed.";
return TransientFailureOrAbort();
}
}
std::string clientSocketAddressInCall2 = response2.payload().body();

// The same connection should have been used for both streams.
Expand All @@ -1424,7 +1424,7 @@ bool InteropClient::DoMcsConnectionScaling() {
if (!stream3->Read(&response3)) {
LOG(ERROR) << "DoMcsConnectionScaling(): stream3->Read() failed.";
return TransientFailureOrAbort();
}
}
std::string clientSocketAddressInCall3 = response3.payload().body();

// A new connection should have been used for the 3rd stream.
Expand Down
39 changes: 26 additions & 13 deletions tools/run_tests/run_interop_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1807,39 +1811,45 @@ 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]
for l in _LANGUAGES_WITH_HTTP2_CLIENTS_FOR_HTTP2_SERVER_TEST_CASES
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,
manual_cmd_log=client_manual_cmd_log,
)
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():
Expand All @@ -1850,15 +1860,18 @@ 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,
newline_on_success=True,
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:
Expand Down