zoukankan      html  css  js  c++  java
  • web test LoadRunner FTP / vsftpd / vsftp / WebUploader 0.1.5 / shangchuan

    s

    FTP的ASCII和Binary传输模式

    http://blog.csdn.net/lwei_998/article/details/6025410

     WINDOWS用FTP上传文本文件到UNIX.在unix下编辑上传的文本文件时

      经常会出现^M,虽然我们可以通过命令替换掉^M。但上传的文件比较多时,  逐个替换还是比较麻烦。

      下面通过小实验来解决这个问题。

      FTP有ASCII和Binary两种传输模式。

      Binary模式不会对数据进行任何处理。

      Ascii模式会将回车换行转换为本机的回车字符。

      由于WINDOWS和UNIX的行结束符不一样。所以从WINDOWS用Binary传输

      方式传输文本文件到UNIX时可能会出现^M。同样从UNIX用Binary方式

      传输文件到WINDOWS时,也可能出现回车换行显示不正确的问题。

     WINDOWS下新建ftp_ascii.txt内容如下:

    hello word!

    WINDOWD TO UNIX !

    TEST FTP ASCII;我们分别用两种模式上传到UNIX. ASCII模式正常

    /oracle$vi ftp_ascii.txt

    hello word!

    WINDOWD TO UNIX !

    TEST FTP ASCII;  二进制模式 Binary有问题

    /oracle$vi ftp_ascii.txt

    hello word!^M

    WINDOWD TO UNIX !^M

    TEST FTP Binary; 由此可知我们采用ASCII模式传输文本可以避免传输中的^M问题。

    在FlashFXP中可以在菜单

    会话->传输模式中选择ASCII ,BINARY ,自动三种模式

    命令行中

    ftp> help binary

    binary          设置二进制传输类型

    ftp> help ascii

    ascii           设置 ASCII 传输类型

    ftp> ascii

    200 Type set to A.

    ftp> bin

    200 Type set to I.

     FTP中虽然ASCII模式可以避免^M的问题。

    但大多数情况FTP还是选择Binary方式,这样可以保证传输的内容不会被改变。

     

    【转】编写LoadRunner的FTP脚本

    http://www.cnblogs.com/dahui4266/archive/2012/03/29/2424057.html

    3、  遇到的问题:

    A、 在生命ftp连接句柄时,我看网上的一些资料中介绍声明称FTP ftp1 = 0 ;

    但是这样写会出现语法错误,当我把它修改成unsigned long *ftp_session=NULL;后就没有问题了,其中原因不明

    B、 当使用SSH加密后,使用loadrunner就无法连接成功,这个问题也没搞清楚原因,出现的错误提示是Logon Session failed SSH-1.99-OpenSSH_3.9p1

    C、 为什么loadrunner能捕捉到事件,但没有生成脚本?

     

    LoadRunner FTP 图片FTP上传脚本

    D:\TestCase\20141105_b2c_uimg\tc_uimg_upload_ftp\vuser_init.c

    vuser_init()
    {
    	lr_start_transaction("2-1 ftp 登录");
    
    	ftp_logon_ex(&ftp_session,"FtpLogon", 
    		"URL=ftp://tpysftpuser:tpysftpuser@192.168.35.109:21", 
    		LAST);
    	  
    	lr_end_transaction("2-1 ftp 登录", LR_AUTO);
    
    	return 0;
    }
    

    D:\TestCase\20141105_b2c_uimg\tc_uimg_upload_ftp\Action.c

    Action()
    {
    	  int i = 0;
    
    	  lr_start_transaction("2-2 ftp创建文件夹并传图50张");
    
    	  ftp_mkdir_ex(&ftp_session, "Ftp_Make_Directory", "PATH=/b2ctest/{data}_{random}");
    // 每个{data}_{radom}文件夹里传图50张
    	  for(i=0;i<50;i++){
    		  ftp_put_ex(&ftp_session,"Put_Files", 
    					   "SOURCE_PATH=D:\\TestCase\\20141105_b2c_uimg\\20k.jpg", 
    	               "TARGET_PATH=/b2ctest/{data}_{random}/{image_name}.jpg", 
    					   "MODE=BINARY",
    					   "PASSIVE=TRUE", 
    					   ENDITEM , 
    				 LAST); 
    	  }
    // /opt/b2c/b2ctest 文件夹在linux系统里修改权限为777最大权限
    	lr_end_transaction("2-2 ftp创建文件夹并传图50张", LR_AUTO);
    
    	return 0;
    } 

    D:\TestCase\20141105_b2c_uimg\tc_uimg_upload_ftp\vuser_end.c

    vuser_end()
    {
    	lr_start_transaction("2-3 登出");
            
            ftp_logout_ex(&ftp_session);
        
    	lr_end_transaction("2-3 登出", LR_AUTO);
    
    	return 0;
    } 

    D:\TestCase\20141105_b2c_uimg\tc_uimg_upload_ftp\globals.c

    #ifndef _GLOBALS_H 
    #define _GLOBALS_H
    #include "mic_ftp.h"
    //定义全局变量 ftp_sessioin
    unsigned long *ftp_session=NULL;
    #endif // _GLOBALS_H  
    
    

     

     

        

    dd

     

    loadrunner web页面上传文件web upload / WebUploader 0.1.5

    http://fex.baidu.com/webuploader/

    WebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件。在现代的浏览器里面能充分发挥HTML5的优势,同时又不摒弃主流IE浏览器,沿用原来的FLASH运行时,兼容IE6+,iOS 6+, android 4+。两套运行时,同样的调用方式,可供用户任意选用。 采用大文件分片并发上传,极大的提高了文件上传效率。 

    Webuploader由fex-team团队负责维护 https://github.com/fex-team ©2013-2018 Baidu Fex Team 

    Loadrunner ,CloundStack 公有云 / web页面上传文件模块 ,关于token没有传递给服务器就上传不了文件的问题解决

    http://10.255.255.250/console.html#/oss/bucket

    sn_cloundstack_webuploader.rar 

    C:\Users\Lindows\Desktop\webuploader\Uploader.swf

    C:\Users\Lindows\Desktop\webuploader\cloudupload.js

    C:\Users\Lindows\Desktop\webuploader\webuploader.js

     

    、、、其他的js脚本(略)
    //上传文件时必须带的token用于建权,javascript文件常在head里传递一些参数,如X-Auth-Token
    //http://10.255.255.250/console.html#/oss/token
    	uploader.on('uploadBeforeSend', function(object, data, headers){
    		headers['Content-Type'] = data.type;
    		headers['X-Auth-Token'] = window.currentToken;
    		headers['Content-Disposition'] = "attachment;filename=" + encodeURI(data.name);
    	});
    、、、其他的js脚本(略)
    
      

    D:\TestCase\20150504_public_clound\tc_bucket_upload2\tc_bucket_upload2.usr

    Action()
    {
    
    	lr_start_transaction("1登录");
    
    	web_reg_find("Text=苏*宁公有云-打造数据分享平台", 
    		LAST);
    
    	web_reg_save_param("jsession",
    		"LB=Set-Cookie:",
    		"RB=.master:server-one; path=/",
    		"Ord=1",
    		"NotFound=ERROR",
    		"Search=All",
    		LAST);
    
    	web_url("10.255.255.250", 
    		"URL=http://10.255.255.250/", 
    		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=", 
    		"Snapshot=t2.inf", 
    		"Mode=HTML", 
    		LAST);
    
    	web_submit_data("emailIsActive.htm", 
    		"Action=http://10.255.255.250/logon/emailIsActive.htm", 
    		"Method=POST", 
    		"TargetFrame=", 
    		"RecContentType=application/json", 
    		"Referer=http://10.255.255.250/", 
    		"Snapshot=t3.inf", 
    		"Mode=HTML", 
    		"EncodeAtSign=YES", 
    		ITEMDATA, 
    		"Name=userName", "Value=test345@sws_test.com", ENDITEM, 
    		LAST);
    
    	web_submit_data("login.htm", 
    		"Action=http://10.255.255.250/logon/login.htm", 
    		"Method=POST", 
    		"TargetFrame=", 
    		"RecContentType=application/json", 
    		"Referer=http://10.255.255.250/", 
    		"Snapshot=t4.inf", 
    		"Mode=HTML", 
    		"EncodeAtSign=YES", 
    		ITEMDATA, 
    		"Name=userName", "Value=test345@sws_test.com", ENDITEM, 
    		"Name=passwd", "Value=as123456", ENDITEM, 
    		EXTRARES, 
    		"Url=../manager/essentialInfo.htm?noCache=1430797557545", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		LAST);
    
    	web_url("nav.html", 
    		"URL=http://10.255.255.250/partials/portal/nav.html?noCache=1430797557553", 		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Snapshot=t5.inf", 
    		"Mode=HTML", 
    		LAST);
    
    	web_url("console.html", 
    		"URL=http://10.255.255.250/partials/console/console.html?noCache=1430797557560", 
    		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Snapshot=t6.inf", 
    		"Mode=HTML", 
    		EXTRARES, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797557739", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/rdsInstance/rdsInstanceConsole.htm?noCache=1430797557851", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?noCache=1430797557851&command=queryBucket", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/logon/console.htm?noCache=1430797557851", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797558186", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797558191", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797558462", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797568469", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		LAST);
    
    	lr_end_transaction("1登录",LR_AUTO);
    
    	lr_start_transaction("2点击bucket");
    
    	web_url("index.html", 
    		"URL=http://10.255.255.250/partials/oss/bucket/index.html?noCache=1430797568936", 
    		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Snapshot=t7.inf", 
    		"Mode=HTML", 
    		EXTRARES, 
    		"Url=/oss/checkValideToken.htm?noCache=1430797569026", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?noCache=1430797569176&command=queryBucket", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797569176", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797569269", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797579269", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		LAST);
    
    	lr_end_transaction("2点击bucket",LR_AUTO);
    
    	lr_start_transaction("3点击bucket id");
    
    	web_url("objectList.html", 
    		"URL=http://10.255.255.250/partials/oss/bucket/objectList.html?noCache=1430797580752", 
    		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Snapshot=t8.inf", 
    		"Mode=HTML", 
    		LAST);
    
    	web_url("pager.html", 
    		"URL=http://10.255.255.250/templates/pager/pager.html?noCache=1430797580820", 
    		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Snapshot=t9.inf", 
    		"Mode=HTML", 
    		EXTRARES, 
    		"Url=/oss/listObjects.htm?noCache=1430797580820&bucketUuid=buc-8EejzliNjHQ", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797581063", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797591065", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797601066", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797611067", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=/api.htm?command=queryJobs&noCache=1430797621068", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		LAST);
    
    	lr_end_transaction("3点击bucket id",LR_AUTO);
    
    	lr_start_transaction("4上传文件");
    
    	web_submit_data("getUploadUrl.htm", 
    		"Action=http://10.255.255.250/oss/getUploadUrl.htm", 
    		"Method=POST", 
    		"TargetFrame=", 
    		"RecContentType=application/json", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Snapshot=t10.inf", 
    		"Mode=HTML", 
    		ITEMDATA, 
    		"Name=fileName", "Value=shopXml.txt", ENDITEM, 
    		"Name=bucketUuid", "Value=buc-8EejzliNjHQ", ENDITEM, 
    		LAST);
    
    	web_custom_request("shopXml.txt", 
    		"URL=http://10.255.254.34/v1/AUTH_7873753ea4bc4840bb9a1c2a9eda1580/bucket-test3/shopXml.txt?id=WU_FILE_0&name=shopXml.txt&type=text%2Fplain&lastModifiedDate=Wed+Oct+30+2013+21%3A23%3A43+GMT%2B0800&size=89", 
    		"Method=OPTIONS", 
    		"TargetFrame=", 
    		"Resource=1", 
    		"Referer=", 
    		LAST);
    
    // 这里设置js head 里传递的 X-Auth-Token进行建权
    	web_add_header("X-Auth-Token","7892499f6092426a8958a052a7a7497e");
    
    	web_custom_request("shopXml.txt_2", 
    		"URL=http://10.255.254.34/v1/AUTH_7873753ea4bc4840bb9a1c2a9eda1580/bucket-test3/shopXml.txt?id=WU_FILE_0&name=shopXml.txt&type=text%2Fplain&lastModifiedDate=Wed+Oct+30+2013+21%3A23%3A43+GMT%2B0800&size=89", 
    		"Method=PUT", 
    		"TargetFrame=", 
    		"Resource=0", 
    		"RecContentType=text/html", 
    		"Referer=http://10.255.255.250/console.html", 
    		"Mode=HTML", 
    		"Body=90000483,4000483,4000483,4000483,4000483,4000483,4000483,4002415,4002415,4007245,10036225", 
    		EXTRARES, 
    		"Url=http://10.255.255.250/oss/listObjects.htm?noCache=1430797622631&bucketUuid=buc-8EejzliNjHQ", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=http://10.255.255.250/api.htm?command=queryJobs&noCache=1430797622729", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		"Url=http://10.255.255.250/api.htm?command=queryJobs&noCache=1430797632732", "Referer=http://10.255.255.250/console.html", ENDITEM, 
    		LAST);
    
    	lr_end_transaction("4上传文件",LR_AUTO);
    
    	return 0;
    }
    

    loadrunner  Generation log 中出现了token,X-Auth-Token

    ****** Request Header For Transaction With Id 131 ******
    PUT /v1/AUTH_7873753ea4bc4840bb9a1c2a9eda1580/bucket-test3/account.txt?id=WU_FILE_0&name=account.txt&type=text%2Fplain&lastModifiedDate=Mon+Jun+30+2014+10%3A41%3A46+GMT%2B0800&size=650 HTTP/1.1
    Host: 10.255.254.34
    User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:31.0) Gecko/20100101 Firefox/31.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Content-Type: text/plain
    X-Auth-Token: 7892499f6092426a8958a052a7a7497e
    Content-Disposition: attachment;filename=account.txt
    Referer: http://10.255.255.250/console.html
    Content-Length: 650
    Origin: http://10.255.255.250
    Connection: keep-alive
    $$$$$$ Request Header For Transaction With Id 131 Ended $$$$$$

     、、、

    ****** Response Body For Transaction With Id 127 ******
    {"uploadUrl":"http://10.255.254.34/v1/AUTH_7873753ea4bc4840bb9a1c2a9eda1580/bucket-test3/account.txt","token":"7892499f6092426a8958a052a7a7497e"}
    $$$$$$ Response Body For Transaction With Id 127 Ended $$$$$$

    、、、 

     

    Loadrunner 上传后的文件将存储在对象存储系统里CloundStack  OSS (open )

    https://www.zybuluo.com/yummy/note/28041

    上传对象

    Example

    curl -i $publicURL/photo_private/1.jpg -X PUT -T /root/1.jpg -H "Content-Type: image/jpeg" -H "X-Auth-Token: $token"

    Normal response codes

    HTTP/1.1 100 Continue

    HTTP/1.1 201 Created

    loadrunner自动下载文件并保存到本地脚本

    http://xitong.iteye.com/blog/1778492 

    Action()
    {
    int flen; //定义一个整型变量保存获得文件的大小
    long filedes; //保存文件句柄
    char file[256]="\0"; //保存文件路径及文件名
    char * chNumber ;
    int time;
    web_set_max_html_param_len("1024000"); //设置页面接收最大的字节数,该设置应大于下载文件的大小
    // lr_rendezvous("下载");
    web_concurrent_start(NULL);//并发开始
    web_reg_save_param("filecontent",
    "LB=",
    "RB=",
    "Search=BODY",
    LAST); //使用关联函数获取下载文件的内容
    web_url("android.apk",
    "URL=http://res.t.ifeng.com/download/android/ifeng_weibo_android_v1.01beta.apk",//下载链接
    "Resource=1",
    "RecContentType=application/force-download",
    "Referer=",
    LAST);
    web_concurrent_end(NULL); //并发结束
    flen =web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); //获得下载文件大小
    time=web_get_int_property (HTTP_INFO_DOWNLOAD_TIME);
    lr_output_message("下载时间是%d",time);
    chNumber=lr_eval_string("{NewParam}"); //生成随机数
    strcat(file,"F:\\android\\android");//将下载文件要保存的路径存到android里
    strcat(file,chNumber);//在文件名后自动生成随机数
    strcat(file,".apk");//下载的文件后缀名称
    if(flen > 0)
    {
    if((filedes = fopen(file,"wb")) == NULL)
    {
    lr_output_message("Open FileFailed!", lr_eval_string("{filecontent}"));
    return -1;
    }
    fwrite(lr_eval_string("{filecontent}"),flen,1,filedes );
    fclose( filedes );
    }
    return 0;
    }

    end

  • 相关阅读:
    exports 与 module.exports 的区别
    [读书笔记] JavaScript设计模式: 单例模式
    mybaits及mybaits generator 插件使用指南(亲测原创)
    【转】系统吞吐量等知识相关
    java的JDBC驱动使用链接数据库
    java程序引用别的jar包打包方法
    ftp服务器不能上传文件故障
    lftp下载文件无法覆盖,提示" file already existst and xfer:clobber is unset" 问题解决
    jar/war文件的解释
    linux 自动输入用户名和密码 ftp
  • 原文地址:https://www.cnblogs.com/lindows/p/14390232.html
Copyright © 2011-2022 走看看