![](https://bestproxy.cc/wp-content/uploads/2022/12/1671619557-1642519138-slider-jms.png)
最近在做测试的时候遇到一个问题:就是内部网络做了限制,「部分服务只有在机房的网段内才能访问」。
虽然不清楚具体原因,不过的确给测试造成了一些麻烦,使用工具或者Git进行文件同步的话,虽然可行,但总归不是那么方便。再加上一些功能测试工具选择的问题,对我来讲添加了更多的麻烦。不过这倒是更有利于我的性能测试方案实施,具体情况如下:如何在Linux命令行界面愉快进行性能测试。
所以想到了在Java中使用proxy配置,然后通过在机房开发机中配置一个HTTP代理,然后本机请求从proxy配置得到一个代理服务器地址,然后绕去内网访问服务,这样就完美解决了这个方案。
目录
Demo代码
public static void main(String[] args) { def get = getHttpPost("?lang=zh-CN ") def response1 = getHttpResponse(get) output(response1) setProxy(get,"104.129.198.211:10605") def response = getHttpResponse(get) output(response) testOver() }控制台输出:
INFO-> 当前用户:fv,IP:10.60.192.21,工作目录:/Users/fv/Documents/workspace/fun/,系统编码格式:UTF-8,系统Mac OS X版本:10.15.6INFO-> 请求uri:?lang=zh-CN,耗时:982 msINFO-> ~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~ JSON ~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~> {> ① . "zip":"",> ① . "country":"中国",> ① . "city":"北京",> ① . "org":"Beijing Qishangzaixian Data Correspondence Technology Co., Ltd",> ① . "timezone":"Asia/Shanghai",> ① . "regionName":"北京市",> ① . "isp":"IDC, China Telecommunications Corporation",> ① . "query":"118.26.128.202",> ① . "lon":116.3889,> ① . "as":"AS23724 IDC, China Telecommunications Corporation",> ① . "countryCode":"CN",> ① . "region":"BJ",> ① . "lat":39.9288,> ① . "status":"success"> }~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~ JSON ~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~INFO-> 请求uri:?lang=zh-CN,耗时:488 msINFO-> ~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~ JSON ~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~> {> ① . "zip":"90014",> ① . "country":"美国",> ① . "city":"洛杉矶",> ① . "org":"Zscaler, Inc.",> ① . "timezone":"America/Los_Angeles",> ① . "regionName":"加利福尼亚州",> ① . "isp":"ZSCALER, INC.",> ① . "query":"104.129.198.211",> ① . "lon":-118.2641,> ① . "as":"AS22616 ZSCALER, INC.",> ① . "countryCode":"US",> ① . "region":"CA",> ① . "lat":34.0494,> ① . "status":"success"> }~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~ JSON ~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~~☢~Process finished with exit code 0