-
Notifications
You must be signed in to change notification settings - Fork 4.5k
stress: client logs total num of calls made #6762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"strconv" | ||
"strings" | ||
"sync" | ||
"sync/atomic" | ||
"time" | ||
|
||
"google.golang.org/grpc" | ||
|
@@ -55,7 +56,8 @@ var ( | |
tlsServerName = flag.String("server_host_override", "foo.test.google.fr", "The server name use to verify the hostname returned by TLS handshake if it is not empty. Otherwise, --server_host is used.") | ||
caFile = flag.String("ca_file", "", "The file containing the CA root cert file") | ||
|
||
logger = grpclog.Component("stress") | ||
totalNumCalls int64 | ||
logger = grpclog.Component("stress") | ||
) | ||
|
||
// testCaseWithWeight contains the test case type and its weight. | ||
|
@@ -206,7 +208,6 @@ func startServer(server *server, port int) { | |
s := grpc.NewServer() | ||
metricspb.RegisterMetricsServiceServer(s, server) | ||
s.Serve(lis) | ||
|
||
} | ||
|
||
// performRPCs uses weightedRandomTestSelector to select test case and runs the tests. | ||
|
@@ -241,6 +242,7 @@ func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTe | |
interop.DoCustomMetadata(client, grpc.WaitForReady(true)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Later PR... Same reasons as with moving to under |
||
} | ||
numCalls++ | ||
defer func() { atomic.AddInt64(&totalNumCalls, numCalls) }() | ||
gauge.set(int64(float64(numCalls) / time.Since(startTime).Seconds())) | ||
|
||
select { | ||
|
@@ -335,6 +337,6 @@ func main() { | |
close(stop) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional for this PR but would be nice to fix up soon if we are reviving this: More natural and simpler would be: ctx := context.Background
if *testDurationSecs > 0 {
ctx, cancel = context.WithTimeout(ctx, *testDurationSecs * time.Second)
defer cancel()
}
........
performRPCs(ctx, g, conn, testSelector)
......
func performRPCs() {
....
for ctx.Err() == nil {
....
}
} Even better would be to then pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (#6763 FYI) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to chat with you a bit more about this, not changing in this PR. |
||
} | ||
wg.Wait() | ||
logger.Infof("Total calls made: %v", totalNumCalls) | ||
logger.Infof(" ===== ALL DONE ===== ") | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move all of this stuff under
/interop
(i.e.cd grpc-go; mv stress interop/
)? I don't think it really wants to be a top-level thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that, but rather in a later PR so that this commit stays focused on one thing.