blob: be4766ab05593d68577e64e9dadacf77e61f46f1 [file] [log] [blame]
Siddharth Rakesh922ea812015-06-04 17:32:31 -07001/*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#include <iostream>
35#include <memory>
36#include <string>
Siddharth Rakesh39824332015-06-08 13:44:51 -070037#include <cfloat>
Siddharth Rakesh922ea812015-06-04 17:32:31 -070038
39#include <grpc/grpc.h>
40#include <grpc++/channel_arguments.h>
41#include <grpc++/channel_interface.h>
42#include <grpc++/client_context.h>
43#include <grpc++/create_channel.h>
44#include <grpc++/credentials.h>
45#include <grpc++/status.h>
Siddharth Rakeshcc5857b2015-06-18 16:45:55 -070046#include "test/cpp/qps/perf_db.grpc.pb.h"
Siddharth Rakesh922ea812015-06-04 17:32:31 -070047
Siddharth Rakesh39824332015-06-08 13:44:51 -070048
49namespace grpc{
50namespace testing {
Siddharth Rakesh922ea812015-06-04 17:32:31 -070051
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070052//Manages data sending to performance database server
Siddharth Rakeshcc5857b2015-06-18 16:45:55 -070053class PerfDbClient {
Siddharth Rakesh39824332015-06-08 13:44:51 -070054public:
Siddharth Rakesh60111c02015-06-22 13:02:33 -070055 PerfDbClient() {
56 QPS_ = DBL_MIN;
57 QPSPerCore_ = DBL_MIN;
58 percentileLatency50_ = DBL_MIN;
59 percentileLatency90_ = DBL_MIN;
60 percentileLatency95_ = DBL_MIN;
61 percentileLatency99_ = DBL_MIN;
62 percentileLatency99Point9_ = DBL_MIN;
63 serverSystemTime_ = DBL_MIN;
64 serverUserTime_ = DBL_MIN;
65 clientSystemTime_ = DBL_MIN;
66 clientUserTime_ = DBL_MIN;
67 }
Siddharth Rakesh922ea812015-06-04 17:32:31 -070068
Siddharth Rakeshcc5857b2015-06-18 16:45:55 -070069 void init(std::shared_ptr<ChannelInterface> channel) { stub_ = PerfDbTransfer::NewStub(channel); }
70
71 ~PerfDbClient() {}
Siddharth Rakesh922ea812015-06-04 17:32:31 -070072
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070073 //sets the client and server config information
Siddharth Rakesh43645462015-06-22 12:21:57 -070074 void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig);
Siddharth Rakesh922ea812015-06-04 17:32:31 -070075
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070076 //sets the QPS
Siddharth Rakesh43645462015-06-22 12:21:57 -070077 void setQPS(double QPS);
Siddharth Rakesh922ea812015-06-04 17:32:31 -070078
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070079 //sets the QPS per core
Siddharth Rakesh43645462015-06-22 12:21:57 -070080 void setQPSPerCore(double QPSPerCore);
Siddharth Rakesh922ea812015-06-04 17:32:31 -070081
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070082 //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency
Siddharth Rakesh922ea812015-06-04 17:32:31 -070083 void setLatencies(double percentileLatency50, double percentileLatency90,
Siddharth Rakesh43645462015-06-22 12:21:57 -070084 double percentileLatency95, double percentileLatency99, double percentileLatency99Point9);
Siddharth Rakesh922ea812015-06-04 17:32:31 -070085
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070086 //sets the server and client, user and system times
Siddharth Rakesh922ea812015-06-04 17:32:31 -070087 void setTimes(double serverSystemTime, double serverUserTime,
Siddharth Rakesh43645462015-06-22 12:21:57 -070088 double clientSystemTime, double clientUserTime);
Siddharth Rakesh922ea812015-06-04 17:32:31 -070089
Siddharth Rakeshd0010ae2015-06-15 17:02:51 -070090 //sends the data to the performancew database server
Siddharth Rakeshdf77c582015-06-23 16:34:18 -070091 int sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag);
Siddharth Rakesh922ea812015-06-04 17:32:31 -070092
Siddharth Rakesh39824332015-06-08 13:44:51 -070093private:
Siddharth Rakeshcc5857b2015-06-18 16:45:55 -070094 std::unique_ptr<PerfDbTransfer::Stub> stub_;
Siddharth Rakesh43645462015-06-22 12:21:57 -070095 ClientConfig clientConfig_;
96 ServerConfig serverConfig_;
Siddharth Rakesh60111c02015-06-22 13:02:33 -070097 double QPS_;
98 double QPSPerCore_;
99 double percentileLatency50_;
100 double percentileLatency90_;
101 double percentileLatency95_;
102 double percentileLatency99_;
103 double percentileLatency99Point9_;
104 double serverSystemTime_;
105 double serverUserTime_;
106 double clientSystemTime_;
107 double clientUserTime_;
Siddharth Rakesh39824332015-06-08 13:44:51 -0700108};
109
110} //namespace testing
111} //namespace grpc
112
113