1.四大參數(shù)校驗(yàn)工具
cpu,內(nèi)存,磁盤io,網(wǎng)絡(luò)io。
部分參考了一下微軟msdn的這篇文章Tools To Simulate CPU / Memory / Disk Load
cpu
圖形化工具 CPUSTRES.EXE
這個(gè)工具比較簡單,直接選擇用幾個(gè)thread,選擇一下priority和activity優(yōu)先級,即可產(chǎn)生不同的壓力。

命令行工具,consume.exe。
consume 使用方法:
consume RESOURCE [-time SECONDS]
RESOURCE can be one of the following:
-physical-memory
-page-file
-disk-space
-cpu-time
-kernel-pool
內(nèi)存
內(nèi)存加壓工具:
testlimit.exe
Testlimit64.exe -d -c 2048
即占用2G內(nèi)存。

磁盤io
直接參考使用 fio
注意ioengine 使用windowsaio
fio.exe --direct=1 --iodepth=1 --rw=randrw --rwmixread=70 --bs=16k --size=1g --ioengine=windowsaio --group_reporting --name=file --runtime=300 --time_based --numjobs=1 --thread --filename=bench
網(wǎng)絡(luò)io
這個(gè)也可以使用和linux下相一致的 iperf
使用方式同linux。
server端
client端
iperf -u -c 223.252.223.153 -i 2 -b 40M -t 600
2.穿透vnc快捷鍵映射
首先講一下回歸測試windows盡可能自動化,降低手工操作的思路:
1.盡可能把測試工具,測試環(huán)境準(zhǔn)備好(例如關(guān)閉防火墻),然后打一個(gè)鏡像,使用這個(gè)鏡像進(jìn)行測試。
2.但是因?yàn)樾枰诓煌h(huán)境中進(jìn)行回歸,以及由于各種目的,需要測試一個(gè)純凈的鏡像等需求(例如在基礎(chǔ)鏡像中進(jìn)行了一些小的變更),導(dǎo)致未能滿足要求1.
3.所以考慮將測試工具打成一個(gè)壓縮包,上傳到對象存儲上去。
4.windows server2012使用瀏覽器下載十分繁瑣,因?yàn)榘踩颍枰芏嗍髽?biāo)點(diǎn)擊操作關(guān)閉安全策略才能下載,正好調(diào)研發(fā)現(xiàn)powershell 自帶一個(gè)curl,注意雖然和linux下curl不完全一樣,但是能實(shí)現(xiàn)下載并保存為文件的需求。下文有描述通過 scurl鍵映射一鍵下載對應(yīng)回歸的工具包。
實(shí)現(xiàn)穿透vnc快捷鍵映射的動機(jī):
1.windows不方便自動化。
2.遠(yuǎn)程操作涉及到許多gui交互。(關(guān)閉防火墻等)
3.vnc不能進(jìn)行復(fù)制粘貼。
目標(biāo),把gui操作盡可能的cli化(利用powershell)。
例如:關(guān)閉防火墻
1.手工鼠標(biāo)點(diǎn)擊操作極其復(fù)雜
2.如果使用powershell
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
掛載云硬盤操作
1.鼠標(biāo)點(diǎn)擊操作極其復(fù)雜
2.如果使用powershell
Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -Confirm:$false
但是通過vnc,不能和宿主機(jī)進(jìn)行復(fù)制黏貼,手輸入那么大一串命令行不現(xiàn)實(shí),而且容易出錯。
需要做一個(gè)鍵映射,類似vim中的map。將一個(gè)較長的命令映射成一個(gè)較短的字符串。
考慮使用autohotkey實(shí)現(xiàn)。直接使用它的sendraw模塊。將相關(guān)字符串已按鍵方式輸出,正好輸入到vnc中,進(jìn)行操作。
一個(gè)autohotkey demo 腳本。之前使用f1-f10鍵作為映射鍵。考慮到相關(guān)命令日積月累越來越長,于是使用短命令來映射,我是用s作為leader key。
::scurl::
sendraw curl http://testnos1.nos-eastchina1.126.net/windows_tool.zip -OutFile wintool.zip
sleep 10
return
::sdt::
sendraw http://testnos1.nos-eastchina1.126.net/windows_tool.zip
return
::sfire::
sendraw Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
return
;check MTU
::smtu::
sendraw netsh interface ipv4 show subinterfaces
return
::sfio::
sendraw fio.exe --direct=1 --iodepth=1 --rw=randrw --rwmixread=70 --bs=16k --size=1g --ioengine=windowsaio --group_reporting --name=file --runtime=300 --time_based --numjobs=1 --thread --filename=bench
return
::siperf::
sendraw iperf -u -c 223.252.223.153 -i 2 -b 40M -t 600
return
::svol::
sendraw Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -Confirm:$false
return
::sping::
sendraw ping 114.114.114.114
return
操作效果如下:

3.ansible批量執(zhí)行
如果需要批量進(jìn)行多臺windows云主機(jī)的測試,上述方法手工操作還是太多了,試想手工登錄100臺vnc然后進(jìn)行某個(gè)操作,orz。
windows云主機(jī)的批量處理工具貌似沒有l(wèi)inux那么豐富?調(diào)研發(fā)現(xiàn)某個(gè)博主這么說,然而我并沒有chef相關(guān)經(jīng)驗(yàn),而且ansible貌似在windows部署方面也有所進(jìn)展了。我調(diào)通了一個(gè)例子,能夠?qū)崿F(xiàn)一部分自動化。
凡是牽扯到工具選型的時(shí)候,如果你發(fā)現(xiàn)你處于一個(gè)非常糾結(jié)的地位,那可能是因?yàn)楦偲饭ぞ邲]有一個(gè)能突出重圍,導(dǎo)致你在它們各自的優(yōu)缺點(diǎn)之間難以取舍。我也理解,工具選型要考慮的因素太多。這個(gè)項(xiàng)目的選型其實(shí)沒經(jīng)過太大波折,很快就決定使用Chef。原因我可以簡單說一下,Puppet的API太不友好,ansible和salt對windows的支持程度未知,而根據(jù)我以前的經(jīng)驗(yàn),Chef對windows的支持還是比較成熟的。所以我們就快刀斬亂麻選擇了Chef。
使用方式
ansible 分為server端和client端。這里client端即為被操作的windows云主機(jī)。而server端必須使用一臺linux云主機(jī),不支持windows!(囧)
server安裝完ansible并進(jìn)行配置之后
root@debian:/opt/ansible# vi hosts.ini
[windows]
59.111.122.255
[windows:vars]
ansible_ssh_user=Administrator
ansible_ssh_pass=mypassword
ansible_ssh_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
client
windows云主機(jī)設(shè)置
1. 關(guān)閉防火墻 Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
2. 運(yùn)行ConfigureRemotingForAnsible.ps1 這個(gè)文件
ad-hoc方式
root@debian-test-master:/opt/ansible# ansible windows -i hosts.ini -m win_ping
59.111.122.255 | SUCCESS => {
"changed": false,
"ping": "pong"
}
查看主機(jī)基本狀況
root@debian-test-master:/opt/ansible# ansible windows -i hosts.ini -m setup
59.111.100.25 | SUCCESS => {
"ansible_facts": {
"ansible_distribution": "Microsoft Windows NT 6.3.9600.0",
"ansible_distribution_version": "6.3.9600.0",
"ansible_fqdn": "WIN-AQJ5DL6898A",
"ansible_hostname": "WIN-AQJ5DL6898A",
"ansible_ip_addresses": [
"10.173.32.16",
"fe80::617c:a9ee:f457:cc63",
"59.111.100.25",
"fe80::7d2a:e355:45c6:495f"
],
"ansible_os_family": "Windows",
"ansible_system": "Win32NT",
"ansible_totalmem": "4294967296"
},
"changed": false
}
使用play-book
root@debian-test-master:~/ansible-examples/windows# ansible-playbook -i hosts.ini ping.yml
PLAY [Ping] ********************************************************************
TASK [setup] *******************************************************************
ok: [59.111.100.25]
TASK [ping] ********************************************************************
ok: [59.111.100.25]
PLAY RECAP *********************************************************************
59.111.100.25 : ok=2 changed=0 unreachable=0 failed=0
傳入文件
root@debian-test-master:~/ansible-examples/windows# ansible-playbook -i hosts.ini copy.yml
PLAY [copy file] ***************************************************************
TASK [copy file test] **********************************************************
changed: [59.111.100.25]
PLAY RECAP *********************************************************************
59.111.100.25 : ok=1 changed=1 unreachable=0 failed=0
其中copy.yml內(nèi)容為
1 ---
2 - name: copy file
3 hosts: all
4 gather_facts: false
5 tasks:
6 - name: copy file test
7 win_copy:
8 src: /root/sssgo
9 dest: c:\sssgo
windows端可以看到,文件已傳入根目錄
刪除文件
root@debian-test-master:~/ansible-examples/windows# ansible windows -m win_file -a 'path=c:\\sssgo state=absent'
59.111.122.255 | SUCCESS => {
"changed": true
}
即可看到文件被刪除。
具體玩法和linux下的類似。這樣即可以達(dá)到批量控制windows云主機(jī)的目的。后續(xù)一些繁瑣的測試可以通過寫ansible playbook 自動化起來。當(dāng)然,最好能夠在windows命令行下找到對應(yīng)的cli工具,或者自己寫腳本或者工具實(shí)現(xiàn)。:)