Skip to content

Commit

Permalink
load testing script initial phase
Browse files Browse the repository at this point in the history
  • Loading branch information
chakri642 committed Aug 31, 2023
1 parent ba049cc commit 508b027
Show file tree
Hide file tree
Showing 12 changed files with 1,642 additions and 0 deletions.
60 changes: 60 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions crates/load_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "load_test"
version = "0.1.0"
edition = "2021"

[lib]
path = "src/lib.rs"

[[bin]]
path = "src/main.rs"
name = "load_test"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = {version = "1.28.2", features = ["macros", "rt-multi-thread"]}
dotenv = "0.15.0"
redis = {version = "0.23.0"}
cargo-test = "0.3.1"
actix-web = "4.3.1"
reqwest = {version = "0.11.18", features = ["json"]}
serde = {version ="1.0.171", features = ["derive"]}
fred = { version = "6.0.0", features = ["metrics", "partial-tracing"] }
serde_json = "1.0.100"
rand = "0.8.5"
chrono = {version = "0.4.26", features = ["serde"]}
Binary file not shown.
77 changes: 77 additions & 0 deletions crates/load_test/generateconfig/generatetoken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const axios = require("axios");
const fs = require("fs");

const driverUrl = "http://localhost:8016/ui";
const customerUrl = "https://api.sandbox.beckn.juspay.in/dev/app/v2";

const mobileNoUser = [
"9999999955",
"9999999945"
];

const mobileNoDriver = [
"7888888881",
"7777777771",
"7777777772",
"7777777774",
"6666666668",
"6666666662",
"7888888771",
"7888888772",
"7888888773",
"7888888774",
"7888888775",
"7888888776",
"7888887776"
]

async function auth(BASE_URL, arr, fileName, merchantId) {
const allTokens = [];
for (let i = 0; i < arr.length; i++) {
const authData = {
mobileNumber: arr[i],
mobileCountryCode: "+91",
merchantId: merchantId,
};


try {
const authRes = await axios.post(BASE_URL + "/auth", authData, {
headers: { "Content-Type": "application/json" },
});

const authId = authRes.data.authId;

const authVerifyData = {
otp: "7891",
deviceToken: authId,
};

const authVerifyRes = await axios.post(
BASE_URL + `/auth/${authId}/verify`,
authVerifyData,
{
headers: { "Content-Type": "application/json" },
}
);

const token = authVerifyRes.data.token;
allTokens.push(token);
} catch (error) {
console.error("Error while fetching API ", error);
}
}

console.log(allTokens, "token");
fs.writeFileSync(`output/${fileName}`, JSON.stringify(allTokens, null, 2));

console.log("API response has been saved to the file:", fileName);
}

auth(customerUrl, mobileNoUser, "rider_token.json", "NAMMA_YATRI");
auth(
driverUrl,
mobileNoDriver,
"driver_token.json",
"7f7896dd-787e-4a0b-8675-e9e6fe93bb8f"
);
15 changes: 15 additions & 0 deletions crates/load_test/generateconfig/output/driver_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
"89865ef5-da51-4c1b-b383-862e57504a0e",
"75ba0a82-f750-4539-b067-d5c79fba4dad",
"7c722062-95a7-40f2-8edd-01e71b1c4122",
"c5c668f9-f127-4a86-b115-594e52b6829a",
"acbcdde0-ec76-4593-bf25-86c58638ea8d",
"1d653a3b-bde3-4fdd-96ff-a748c9e210bd",
"f9270164-5e20-4c44-b563-d062a02c80df",
"7009c594-1c5c-4d22-8071-0fdea8fd2b75",
"7f160752-8070-4fca-adc1-4735069b6812",
"576d20d6-896f-4719-ac7f-8dd5fe1e606b",
"e583da16-d331-4bd3-b8d6-a6f3bc5bb8bf",
"122bf13f-e873-40fa-84d1-c0a4cac1f854",
"77f05c66-5712-4e06-9bce-56420ae69557"
]
4 changes: 4 additions & 0 deletions crates/load_test/generateconfig/output/rider_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"4016b105-586d-48a3-bfa1-aa8ada87f64d",
"9850a25d-c17e-414c-b80a-a74023b055a8"
]
Loading

0 comments on commit 508b027

Please sign in to comment.