Wednesday, April 5, 2023

gRPC request testing using Vugen Load runner | gRPC performance testing load runner

gRPC is a modern open source high performance RPC frame work that can run in any environment and it's now been around fo4 several years with a growing user base. Here is the process to create a script in vugen
  1. Start by creating a new VuGen script and selecting the "gRPC" protocol under "Web Services" in the protocol selection window.

  2. In the "Vuser_init" section of the script, add the following code to create a gRPC channel and stub

#include "grpc.h"

grpc_channel* channel;
grpc_stub* stub;

int vuser_init()
{
    channel = grpc_insecure_channel_create("localhost:50051", NULL, NULL);
    stub = grpc_stub_create(channel);
    return 0;
}
In the "Action" section of the script, add the gRPC method call code that you want to test. Here's an example using the "SayHello" method from the gRPC "helloworld" example:

#include "helloworld.grpc.pb.h"

int Action()
{
    hello::Greeter::Stub* greeter_stub = hello::Greeter::NewStub(channel);
    hello::HelloRequest request;
    hello::HelloReply reply;
    grpc::ClientContext context;

    request.set_name("world");

    grpc::Status status = greeter_stub->SayHello(&context, request, &reply);

    if (status.ok()) {
        lr_output_message("Greeting: %s", reply.message().c_str());
    } else {
        lr_output_message("RPC failed: %s", status.error_message().c_str());
    }

    return 0;
}

  1. Finally, in the "Vuser_end" section of the script, add the code to clean up the gRPC channel and stub:
int vuser_end()
{
    grpc_channel_destroy(channel);
    grpc_stub_destroy(stub);
    return 0;
}

That's it! You should now have a functional gRPC script in VuGen that you can use for load testing. Just make sure to replace the example method call with the actual gRPC method you want to test.

Sunday, March 19, 2023

'npm' is not recognised as an internal or external command operable program or batch file error windows 10 fix

The error message "npm is not recognized as an internal or external command" typically means that Node.js and/or npm (Node Package Manager) is not installed on your system, or it is not added to the system's PATH environment variable.

To resolve this error, you can follow these steps:
  • Install Node.js: Download and install the latest version of Node.js from the official website https://nodejs.org/. Follow the installation instructions for your operating system.
  • Verify Node.js installation: After the installation is complete, open a new terminal window and run the following command to verify that Node.js is installed:
node -v

This command should print the version number of Node.js. If you see an error message, try restarting your terminal or computer and running the command again.
  • Verify npm installation: Run the following command to verify that npm is installed:
npm -v

This command should print the version number of npm. If you see an error message, it means that npm is not installed or not added to the system's PATH environment variable.

Add npm to PATH: If npm is not added to the system's PATH environment variable, you can add it manually. Here are the steps to add npm to the PATH variable on Windows:
Open the Start menu and search for "Environment Variables"
Click "Edit the system environment variables"
Click the "Environment Variables" button
Under "System Variables", find the "Path" variable and click "Edit"
Click "New" and enter the path to the npm installation directory (e.g. C:\Program Files\nodejs\node_modules\npm\bin)
Click "OK" to close all windows

Verify npm installation again: Open a new terminal window and run the following command to verify that npm is added to the PATH variable:

npm -v

This command should print the version number of npm. If you still see an error message, try restarting your terminal or computer and running the command again.After completing these steps, you should be able to use npm commands without getting any error.