-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61db2fe
commit e18fe18
Showing
1 changed file
with
20 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
// Import gRPC and k6 check module for use in the script. | ||
|
||
import grpc from 'k6/net/grpc'; | ||
import { check } from "k6"; | ||
|
||
// Create a new gRPC client and load the protocol buffer definition. | ||
|
||
let client = new grpc.Client(); | ||
client.load([], "./grpc_server/route_guide.proto") | ||
client.load([], "./grpc_server/route_guide.proto"); | ||
|
||
// Define the default k6 script. | ||
|
||
export default () => { | ||
client.connect("127.0.0.1:10000", { plaintext: true }) | ||
// Connect to the gRPC server at 127.0.0.1:10000 using plaintext. | ||
|
||
client.connect("127.0.0.1:10000", { plaintext: true }); | ||
|
||
// Invoke the "main.FeatureExplorer/GetFeature" method with specific latitude and longitude values. | ||
|
||
const response = client.invoke("main.FeatureExplorer/GetFeature", { | ||
latitude: 410248224, | ||
longitude: -747127767 | ||
}) | ||
}); | ||
|
||
// Check the response for an "OK" status using the gRPC status code. | ||
|
||
check(response, { "status is OK": (r) => r && r.status === grpc.StatusOK }); | ||
console.log(JSON.stringify(response.message)) | ||
|
||
client.close() | ||
// Log the response message as a JSON string. | ||
|
||
console.log(JSON.stringify(response.message)); | ||
|
||
// Close the gRPC client connection. | ||
client.close(); | ||
} | ||
|