diff --git a/samples/apps/smallbank/clients/small_bank_client.cpp b/samples/apps/smallbank/clients/small_bank_client.cpp index 9911b10cb..254f32adb 100644 --- a/samples/apps/smallbank/clients/small_bank_client.cpp +++ b/samples/apps/smallbank/clients/small_bank_client.cpp @@ -257,7 +257,7 @@ private: } } - LOG_INFO_FMT("VERIFIED {}", prefix); + LOG_INFO_FMT("Verified {}", prefix); } void verify_initial_state(const nlohmann::json& expected) override diff --git a/samples/perf_client/perf_client.h b/samples/perf_client/perf_client.h index f1f99181e..bacad5b07 100644 --- a/samples/perf_client/perf_client.h +++ b/samples/perf_client/perf_client.h @@ -425,19 +425,15 @@ namespace client } } - const auto global_commit_response = wait_for_global_commit( - trigger_signature(create_connection(true, false))); - size_t last_commit = 0; if (!options.no_wait) { - const auto commit_ids = - timing::parse_commit_ids(global_commit_response); - last_commit = commit_ids.global; - } - else - { - last_commit = last_response_commit.seqno; + // Create a new connection, because we need to do some GETs + // and when all you have is a WebSocket, everything looks like a POST! + auto c = create_connection(true, false); + trigger_signature(c); + wait_for_global_commit(last_response_commit); } + const auto last_commit = last_response_commit.seqno; auto timing_results = end_timing(last_commit); LOG_INFO_FMT("Timing ended"); return timing_results; @@ -524,23 +520,27 @@ namespace client // Send a mkSign RPC to trigger next global commit const auto method = "mkSign"; const auto mk_sign = connection->gen_request(method); - if (response_times.is_timing_active()) - { - response_times.record_send(method, mk_sign.id, true); - } connection->write(mk_sign.encoded); // Do a blocking read for this final response const auto response = connection->read_response(); process_reply(response); - - const auto commit_ids = timing::parse_commit_ids(response); - LOG_INFO_FMT( - "Triggered signature at {}.{}", commit_ids.view, commit_ids.seqno); + LOG_INFO_FMT("Triggered signature"); return response; } + RpcTlsClient::Response get_tx_status( + const std::shared_ptr& connection, + size_t view, + size_t seqno) + { + nlohmann::json p; + p["seqno"] = seqno; + p["view"] = view; + return connection->get("tx", p); + } + virtual void verify_params(const nlohmann::json& expected) { // It's only reasonable to compare against expected state if the initial @@ -649,11 +649,14 @@ namespace client { const auto last_response = send_creation_transactions(); - if (last_response.has_value()) + if ( + last_response.has_value() && + http::status_success(last_response->status)) { // Ensure creation transactions are globally committed before // proceeding - wait_for_global_commit(trigger_signature(create_connection(true))); + trigger_signature(create_connection(true)); + wait_for_global_commit(last_response.value()); } } catch (std::exception& e) @@ -693,13 +696,13 @@ namespace client } } - RpcTlsClient::Response wait_for_global_commit( + timing::CommitPoint wait_for_global_commit( const timing::CommitPoint& target) { return response_times.wait_for_global_commit(target); } - RpcTlsClient::Response wait_for_global_commit( + timing::CommitPoint wait_for_global_commit( const RpcTlsClient::Response& response) { check_response(response); diff --git a/samples/perf_client/scenario_perf_client.cpp b/samples/perf_client/scenario_perf_client.cpp index 6b83ab3fa..5c14103fa 100644 --- a/samples/perf_client/scenario_perf_client.cpp +++ b/samples/perf_client/scenario_perf_client.cpp @@ -29,12 +29,13 @@ class ScenarioPerfClient : public Base private: nlohmann::json scenario_json; - RpcTlsClient::Response send_verbose_transactions( + std::optional send_verbose_transactions( const std::shared_ptr& connection, char const* element_name) { const auto it = scenario_json.find(element_name); RpcTlsClient::Response response; + bool sent = false; if (it != scenario_json.end()) { @@ -56,12 +57,16 @@ private: LOG_INFO_FMT("Sending {}: {}", method, params.dump(2)); response = connection->call(method, params); + sent = true; const auto response_body = connection->unpack_body(response); LOG_INFO_FMT("Response: {} {}", response.status, response_body.dump(2)); } } - return response; + if (sent) + return response; + else + return std::nullopt; } void pre_creation_hook() override diff --git a/samples/perf_client/timing.h b/samples/perf_client/timing.h index 68dd015b7..950613989 100644 --- a/samples/perf_client/timing.h +++ b/samples/perf_client/timing.h @@ -248,7 +248,7 @@ namespace timing // committed (or will never be committed), returns first confirming // response. Calls record_[send/response], if record is true. // Throws on errors, or if target is rolled back - RpcTlsClient::Response wait_for_global_commit( + CommitPoint wait_for_global_commit( const CommitPoint& target, bool record = true) { auto params = nlohmann::json::object(); @@ -302,7 +302,7 @@ namespace timing commit_ids.view, commit_ids.seqno, commit_ids.global); - return response; + return {commit_ids.view, commit_ids.seqno}; } else if (tx_status == "INVALID") {