YONGFEIUALL

izheyi.com


  • Home

  • Archives

  • Categories

  • Tags

  • About

  • Search

QTP can't get the latest update after updating in extenal library file

Posted on 2015-12-21 | In QTP |

Sometimes QTP doesn’t pick up the latest library file change if the script is already open.

When we update an external library file, in QTP, even if close the updating file and open it again, the change might not get picked up the next time you run it.

Solution

Open the library in QTP and do a syntax check by using Ctrl+F7.
That seems to force QTP to read the latest content.

Load Runner - VuGen Get & Post

Posted on 2015-12-20 | In Load Runner |

性能测试中大部的都是基于HTTP协议的,脚本里的90%都是Get和Post,多数是Get请求。我们用以下两个方法来实现HTTP请求:

Get - web_url()

此函数用来模拟用户请求,它也是在脚本中最常使用的函数之一。
语法:

1
Int Web_url(const char *StepName, const char * url, <Lists of Attributes>, [EXTRARES,<Lists of Resource Attributes>,LAST)

例子:

1
2
3
4
5
6
7
8
9
10
11
12
web_url("Open Login Page",
"URL=http://10.11.2.22/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"URL=/common/login/button.gif", ENDITEM,
"URL=/common/login/main.jpg", ENDITEM,
"URL=/common/login/head_bg.gif", ENDITEM,
LAST);

返回值:
成功时返回LR_PASS (0),失败时返回 LR_FAIL (1)。

参数的几点说明:

  1. 最基本的三个参数是StepName,url, LAST,在不能录制的情况下,可以自己用这三个参数写代码。
  2. Resource - 指定一个值说明这个URL是否是一个资源,0 表示非资源,1 表示资源。
  3. RecContentType - 指定接受服务器什么格式文件。
  4. EXTRARES 是由script、active、java applet、flash、CSS产生的请求,在页面上都找不到。
    • 每一个都是一个请求。
    • 加不加额外资源,会影响下载量。
    • 能不能删除此处脚本,取决于是不是全部都是图片或样式的请求,有没有特殊的请求存在。(原则上只要是录制时录下来的,不是无关的内容,就保留下来。)
    • 如果在脚本回放时不想下载图片、样式表等,设置:
      Run-time Setting -> Browser Emulation -> Download non-html resources。只关心业务处理能力,带宽受限时取消此选项。默认是选中的。

Notes: 排错,只关注url部分即可,数据要是有变化的话,要进行参数化。

Post - web_submit_data()

与Get请求的web_url函数相比,多了ITEMDATA。

1
int web_submit_data( const char *StepName, const char *Action, <List of Attributes>, ITEMDATA, <List of data>, [ EXTRARES, <List of Resource Attributes>,] LAST );

例子:

1
2
3
4
5
6
7
8
web_submit_data("start", 
"Action=login.asp",
"Method=POST",
ITEMDATA,
"name=user", "value=yongfeiuall", ENDITEM,
"name=password", "value=yongfeiuall", ENDITEM,
"name=sessionID", "value=20151220", ENDITEM,
LAST);

返回值:
成功时返回LR_PASS (0),失败时返回 LR_FAIL (1)。

参数的几点说明:

  1. Action:Form中的ACTION属性,指定了完成Form中的操作用到的URL。
  2. Method:表单提交方法:POST或GET(默认是POST)。
  3. ITEMDATA:数据域和属性的分隔符。
    • List of Data:
      数据域列表定义了表单提交的内容。由于此请求是上下文无关的,因此数据域包含了所有的隐含域。使用Form的编码规则组织数据域。
      数据域列表可以使用下面任意一种格式:
      “name=n1”, “value=v1”, ENDITEM,
      “name=n2”, “EncryptedValue=qwerty”, ENDITEM,
    • 如果要自己写脚本的话,用HTTPWATCH工具,在POST_DATA中可以看到提交对应的参数名和参数值,与脚本一致。

Notes:排错,两个地方:1. Action 2. ITEMDATA提交的数据不合法。

Linux运行级别和chkconfig/service

Posted on 2015-12-18 | In Linux |

运行级别

什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别。级别是从0到6(7个运行级别),具有不同的功能。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@Automation ~]# more /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

简单说明:

  1. 查看运行级别用:runlevel
  2. 进入其它运行级别用:init N,如果init 3则进入终端模式,init 5则又登录图形GUI模式
  3. 标准的Linux运行级别为3或5,如果是3的话,系统就在多用户状态;如果是5的话,则是运行着X Window系统。
  4. 不同的运行级别有不同的用处,也应该根据自己的不同情形来设置。例如,如果丢失了root口令,那么可以让机器启动进入单用户状态来设置。
Read more »

Java线程状态及监控工具

Posted on 2015-12-18 | In Performance Testing |

线程状态

在监控的过程中,要弄明白下边这6种状态(我们主要关注分析的:Runnable, Blocked, Waiting):

  1. NEW
      当线程对象对创建后,即进入了新建状态
  2. RUNNABLE
      当调用线程对象的start()方法,线程即进入就绪状态。正在 Java 虚拟机中执行的线程处于这种状态。该状态的线程位于可运行线程池中,等待被线程调度选中,获取cpu 的使用权 。
  3. BLOCKED
      处于运行状态中的线程由于某种原因,暂时放弃对CPU的使用权,停止执行,此时进入阻塞状态,直到其进入到就绪状态,才有机会再次被CPU调用以进入到运行状态。根据阻塞产生的原因不同,阻塞状态又可以分为三种:
    • 等待阻塞:运行状态中的线程执行wait()方法,使本线程进入到等待阻塞状态;
    • 同步阻塞:线程在获取synchronized同步锁失败(因为锁被其它线程所占用),它会进入同步阻塞状态;
    • 其他阻塞:通过调用线程的sleep()或join()或发出了I/O请求时,线程会进入到阻塞状态。当sleep()状态超时、join()等待线程终止或者超时、或者I/O处理完毕时,线程重新转入就绪状态。
  4. WAITING
      无限期地等待另一个线程来执行某一特定操作的线程处于这种状态。某一线程因为调用下列方法之一而处于等待状态:
    • 不带超时值的 Object.wait
    • 不带超时值的 Thread.join
    • LockSupport.park
  5. TIMED_WAITING
      具有指定等待时间的某一等待线程的线程状态。某一线程因为调用以下带有指定正等待时间的方法之一而处于定时等待状态:
    • Thread.sleep
    • 带有超时值的 Object.wait
    • 带有超时值的 Thread.join
    • LockSupport.parkNanos
    • LockSupport.parkUntil
  6. TERMINATED
      已终止线程的线程状态。线程已经结束执行。
Read more »

Java运行环境、执行过程和JVM入门

Posted on 2015-12-15 | In Java |

Java运行过程

JVM

概念性的东西也不多说了,JVM的体系结构如下:

在系统监控和分析中,我们主要关心的是堆和栈

  • 栈是运行时单位,堆是存储单位
  • 栈解决程序运行问题,堆解决数据存储问题
  • 堆中存的是对象,栈中存的基本数据类型和堆中对象的引用
  • 栈代表了处理逻辑,而堆代表了数据
  • 栈异常:java.lang.StackOverflowError
  • 堆异常:java.lang.OutOfMemoryError
Read more »

HTTP协议基础

Posted on 2015-12-14 | In Performance Testing |

目前接触到的基本上都是Web端的性能测试,都是基于HTTP协议的,这里对HTTP协议做个简单的认识:

介绍

官方概念不多说,简单来说,就是一个基于应用层的通信规范:双方要进行通信,大家都要遵守一个规范,这个规范就是HTTP协议。
HTTP三点注意事项:

  • HTTP是无连接
    无连接的含义是限制每次连接只处理一个请求。服务器处理完客户的请求,并收到客户的应答后,即断开连接。采用这种方式可以节省传输时间。
  • HTTP是媒体独立的
    这意味着,只要客户端和服务器知道如何处理的数据内容,任何类型的数据都可以通过HTTP发送。客户端以及服务器指定使用适合的MIME-type内容类型。
  • HTTP是无状态
    HTTP协议是无状态协议。同一个客户端的这次请求和上次请求是没有对应关系,对http服务器来说,它并不知道这两个请求来自同一个客户端。 为了解决这个问题, Web程序引入了Cookie机制来维护状态.

HTTP 三次握手
第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SENT状态,等待服务器确认;SYN:同步序列编号(Synchronize Sequence Numbers)。
第二次握手:服务器收到syn包,必须确认客户的SYN(ack=j+1),同时自己也发送一个SYN包(syn=k),即SYN+ACK包,此时服务器进入SYN_RECV状态;
第三次握手:客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1),此包发送完毕,客户端和服务器进入ESTABLISHED(TCP连接成功)状态,完成三次握手。

工作流程

一次HTTP操作称为一个事务,其工作过程可分为四步:

  1. 首先客户机与服务器需要建立连接。只要单击某个超级链接,HTTP的工作开始。
  2. 建立连接后,客户机发送一个请求给服务器,请求方式的格式为:统一资源标识符(URL)、协议版本号,后边是MIME信息包括请求修饰符、客户机信息和可能的内容。
  3. 服务器接到请求后,给予相应的响应信息,其格式为一个状态行,包括信息的协议版本号、一个成功或错误的代码,后边是MIME信息包括服务器信息、实体信息和可能的内容。
  4. 客户端接收服务器所返回的信息通过浏览器显示在用户的显示屏上,然后客户机与服务器断开连接。

如果在以上过程中的某一步出现错误,那么产生错误的信息将返回到客户端,有显示屏输出。对于用户来说,这些过程是由HTTP自己完成的,用户只要用鼠标点击,等待信息显示就可以了

Read more »

Load Runner - VuGen脚本开发基础

Posted on 2015-12-10 | In Load Runner |

Load Runner

主要由以下工具构成

  • VuGen(Virtual User Generator) - 开发脚本(录制+编写)
  • Controller - 体现多线程,VuGen中也有体现
  • Analysis - 结果分析
  • Load generator - 压力机(客户端),可以跨平台。

VuGen工具使用

录制

录制目的是帮助快速生成脚本。
录制原理:录制的是在B和S之间基本协议的数据包。Lr在B和S之间,相当于一个截取的功能。
录制设置:主要有以下两个方面

  1. 设置字符集编码:Advanced –> Support charset (选中Checkbox和UTF-8)
  2. 设置HTTP/HTML Level: Recording –> HTML-based script –> HTML Advanced –> Script type (选择第2个选项)

Notes:在‘开始录制’窗口,不选择‘Record the application startup’,打开页面后就不会自动录制,到希望录制的地方点击‘Record’再开始录制。

回放

回放原理:回放时不需要启动被测试程序(浏览器)不打开浏览器,LR可以模拟多线程。
回放设置:脚本运行顺序、迭代,思考时间,网速模拟等等。

脚本开发知识点

六个点
最难的是关联和思考时间,后边会一个一个单独详细介绍。

排错

这个是非常重要的,可在以下地方查看:

  1. 主界面Replay Log
    LR只能判断请求成功与否,不能判断业务是否正确。
  2. 业务是否成功View –>TestResults下 Submit Data
  3. 关联 General Log

脚本老是失败原因:参数化、关联、思考时间。

Notes: 脚本开发最好是用以下组合(LR11 + Win7 + IE9)

TestNG 命令行运行

Posted on 2015-12-10 | In Selenium Webdriver |

之前一直是在Eclipse里运行测试的,本次简单介绍一下怎么样来实现命令行来执行TestNG。
Assuming that you have TestNG in your class path, the simplest way to invoke TestNG is as follows:

1
java org.testng.TestNG testng1.xml [testng2.xml testng3.xml ...]

主要是在Windows下做的配置(有步骤已经做过,请忽略):

  1. 下载JDK安装,配置环境变量。
  2. 下载testng-6.8.8.jar包,放在C:\TestNG, 并配置了环境变量
    • TESTNG_HOME 为 C:\TESTNG
    • CLASSPATH 为 %CLASSPATH%;%TESTNG_HOME%\testng-6.8.jar;
  3. 在F:\testng下创建一个java文件command.java

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     import org.testng.annotations.Test;
    import static org.testng.Assert.assertEquals;

    public class A {
    @Test
    public void testAdd() {
    String str = "TestNG is working fine";
    assertEquals("TestNG is working fine", str);
    }
    }
  4. 编译java文件

    1
    javac Command.java
  5. 在同目录下,创建testng.xml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
    <suite name="Suite1">
    <test name="test1">
    <classes>
    <class name="Command"/>
    </classes>
    </test>
    </suite>
  6. 使用java调用testng.xml

    1
    2
    3
    4
    5
    6
    7
    8
    F:\testng>java org.testng.TestNG testng.xml
    [TestNG] Running:
    F:\testng\testng.xml

    ===============================================
    Suite1
    Total tests run: 1, Failures: 0, Skips: 0
    ===============================================

Linux操作系统监控

Posted on 2015-12-09 | In Performance Testing |

在性能测试的过程中,要监控的地方应该就是以下部分:

  • 操作系统
  • 中间件
  • Code
  • DB
  • 网络

这5部分来说,主要的瓶颈可能多是操作系统、代码和DB。会在下面把这两个部分说明,操作系统基于Linux,代码基于Java,DB视情况而定。

CPU

CPU监控的关键指标做一个大概的说明:

运行队列

正在执行和等待CPU处理的任务的总和,称为运行队列。运行队列越长,说明排队等待的任务越多,响应越慢。
Notes:运行队列长度最大不要超过当前内核数的3倍。
Another common system statistic is that of load average. The load on a system is the total amount of running and runnable process. For example, if two processes were running and three were available to run, the system’s load would be five. The load average is the amount of load over a given amount of time. Typically, the load average is taken over 1 minute, 5 minutes, and 15 minutes. This enables you to see how the load changes over time.

上下文切换

To create the illusion that a given single processor runs multiple tasks simultaneously, the Linux kernel constantly switches between different processes. The switch between different processes is called a context switch, because when it happens, the CPU saves all the context information from the old process and retrieves all the context information for the new process.
是CPU在不同进程间按时间片轮换,交互性强的需要高优先级,交互性弱的需要低优先级。在linux系统中,有两种优先级:普通优先级和实时优先级。上下文切换不可避免,如果可能最好减少上下文切换。

中断

一般来自于外部硬件中断,中断也是不可避免的。中断就会有上下文切换,但是上正文切换并不都是中断造成的。
性能测试不需要特别关心内核的问题(中断、上下文切换),而是关注有时因程序写的不好造成的频繁切换(不正常切换)。

资源利用率

CPU utilization is a straightforward concept. At any given time, the CPU can be doing one of seven things.
First, it can be idle, which means that the processor is not actually doing any work and is waiting for something to do. This is “idle“ time.
Second, the CPU can be running user code, which is specified as “user“ time.
Third, the CPU can be executing code in the Linux kernel on behalf of the application code. This is “system“ time.
Fourth, the CPU can be executing user code that has been “nice”ed or set to run at a lower priority than normal processes. (切换线程优先级时消耗的时间)
Fifth, the CPU can be in iowait, which mean the system is spending its time waiting for I/O (such as disk or network) to complete.
Sixth, the CPU can be in irq state, which means it is in high-priority kernel code handling a hardware interrupt.
Finally, the CPU can be in softirq mode, which means it is executing kernel code that was also triggered by an interrupt, but it is running at a lower priority (the bottom-half code). This can happen when a device interrupt occurs, but the kernel needs to do some work with it before it is ready to hand it over to user space (for example, with a network packet).
通常我们只关注:idle, user, system, (+wa)。
在正常情况下,用户态和系统态的CUP消耗比率是7:3.

Read more »

Centos下Nginx + php-fpm安装配置

Posted on 2015-12-08 | In Linux |

Nginx安装

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like协议下发行。

  1. 编译环境安装
    我们默认你是安装好了的,如果没有安装的话,请用下面命令安装
    make安装:

    1
    yum -y install gcc automake autoconf libtool make

    g++安装:

    1
    yum install gcc gcc-c++
  2. 依赖包安装
    我们选择/usr/local/src作为源码目录。Nginx需要依赖下面3个包:

    • rewrite模块需要 pcre 库

      1
      2
      3
      4
      5
      6
      7
      cd /usr/local/src
      wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
      tar -zxvf pcre-8.37.tar.gz
      cd pcre-8.37
      ./configure
      make
      make install
    • gzip模块需要 zlib 库

      1
      2
      3
      4
      5
      6
      7
      cd /usr/local/src
      wget http://zlib.net/zlib-1.2.8.tar.gz
      tar -zxvf zlib-1.2.8.tar.gz
      cd zlib-1.2.8
      ./configure
      make
      make install
    • ssl 功能需要openssl库

      1
      2
      3
      4
      5
      6
      7
      cd /usr/local/src
      wget http://www.openssl.org/source/openssl-1.0.1q.tar.gz
      tar -zxvf openssl-1.0.1q.tar.gz
      cd openssl-1.0.1q
      ./config
      make
      make install
Read more »
1…262728…40
唐胡璐

唐胡璐

i just wanna live while i am alive

393 posts
42 categories
74 tags
RSS
LinkedIn Weibo GitHub E-Mail
Creative Commons
© 2022 唐胡璐
Powered by Hexo
|
Theme — NexT.Pisces v5.1.4