Skip to content
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

Use IP Range or CIDR for K6 source IP addresses #1654

Closed
wants to merge 2 commits into from
Closed

Use IP Range or CIDR for K6 source IP addresses #1654

wants to merge 2 commits into from

Conversation

divfor
Copy link
Contributor

@divfor divfor commented Oct 6, 2020

An alternative PR for using IP range option #1293 , no Network Interface required.
Example of run script:

#!/bin/bash
s=${1:-"ax.js:1000:10m:rps_http"}
read jsfile vus duration casename <<<${s//:/ }
shift
echo -e "testfile[$jsfile] testcase[$casename] vus[$vus] duration[$duration]\noptions[$*]"

set_k6_local_route(){ #$1:net $2:ifname
  net="$1" ifname=${2-"lo"}
  ip r s t local |grep -q "^local $net" || \
  ip -6 r s t local |grep -q "^local $net" || \
  ip route add local "$net" dev $ifname
  ip r s t local |grep "^local $net" || ip -6 r s t local |grep "^local $net"
}

# k6 client ip -- use local type route instead
set_k6_local_route "10.50.0.0/16" "eth0"
set_k6_local_route "fd00:0:1::0/120" "eth0"

# Linux: echo "ulimit -n 1000000" >> ~/.bashrc
# MacOS: sudo launchctl limit maxfiles 65536 1000000
ulimit -n 1000000

# run k6 for ipv4 targets
TESTCASE=$casename VUS=$vus DURATION=$duration k6 run --ip="10.50.0.62-10.50.2.100" --verbose --no-thresholds $* $jsfile
# run k6 for ipv6 targets
sysctl -w net.ipv6.ip_nonlocal_bind=1
TESTCASE=$casename VUS=$vus DURATION=$duration k6 run --ip="fd00:0:188::/120" --verbose --no-thresholds $* $jsfile
sysctl -w net.ipv6.ip_nonlocal_bind=0

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ divfor
❌ Fred Huang


Fred Huang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@divfor divfor closed this Oct 6, 2020
@na--
Copy link
Member

na-- commented Oct 7, 2020

Hey, @divfor, can we help in some way? If the issue is caused by a wrong commit author, maybe this will help - https://www.git-tower.com/learn/git/faq/change-author-name-email/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants