潘泳權wpac-應用waPC (rust) 做軟件測試工具.pptx

編號:132092 PPTX 30頁 2.50MB 下載積分:VIP專享
下載報告請您先登錄!

潘泳權wpac-應用waPC (rust) 做軟件測試工具.pptx

1、第三屆中國第三屆中國Rust開發者大會開發者大會應用應用waPC(rust)做軟件測試工具做軟件測試工具Alan poon 潘泳權大家好!rustropy_gamingruito_89PhoTto/image/chartWebassembly Procedures CallwaPC 協議標準化了本機代碼調用 WebAssembly 和 WebAssembly 調用本機代碼的通信通信(messaging)和錯誤錯誤處理處理(error handling)。什么是waPC?WASM外部函數接口 FFIInput type Return typePlatform底層底層I32I32Unknownwa

2、PC&u8ResultVec,errorLinux x86_64,macOS x86_64,Windows x86_64,cargo build target wasm-unknown-unknownwaPC Host(Go)waPC Guest RustRead wasm fileSelect engineWazeroWasmer-goWasmertime-goDefine hostcall capabilityInstantiateInvoke-command with dataGuest 指wasmOperation是我們要在wasm里注冊命名以數據的長度,設置wasm 的linear

3、memory 的指針Guest可執行任務Guest也可返回請求hostInvoke(ctx,operation,payload)WAPC 流程Uses Length of response and error to return resultres,err:=InvokeWAPC 流程#no_manglepub fn wapc_init()wapc:register_function(ping,ping);fn ping(msg:&u8)-wapc:CallResult.Ok(msg.to_vec()waPC Guest RustwaPCUse wapc_init to register fu

4、nctionRegister_function can only be used inside WAPC_initRegister_function cannot be called inside ping_start is meant to support tinygos wasmwaPC host will still run both wapc_init and _start during intializationwaPC Guest RustwaPC Use wapc_init to register function _start also canUtil Lib uses wap

5、c_init,users build on top of”_start”extern crate wapc_guest as guest;extern crate Regex;.fn echo_req_json(msg:&u8)-CallResult let mut req=foo_unmarshall:(msg)?;let re=Regex:new(r”/v2/matches/(a-zA-Z0-9_-+)/info).unwrap();if let Some(cap)=re.captures(&req.HttpPath)req.HttpProxyUrl=String:from(“localh

6、ost:8000);req.HttpScheme=String:from(http);let request=serde_json:to_string(&req)?;Ok(request.as_bytes().to_vec()fn do_nothing(msg:&u8)-CallResult Ok(msg.to_vec()#no_manglepub extern C fn _start()let mut reg=REGISTRY.lock().unwrap();reg.insert(“/v2/matches/.*/info_modify_req”.into(),echo_req_json);r

7、eg.insert(“/v2/matches/.*/info_modify_res”.into(),echo_res_json);reg.insert(“/v2/matches/.*/info_fiddler_ab”.into(),do_nothing);waPC in rust in HTTP(MITM)curl-X POST“http:/$MockServer:$Port/call/$Operation?targets=/v2/matches/.*/info -header Content-Type:application/octet-stream -data-binary target/

8、wasm32-unknown-unknown/release/examples/$3.wasmMock rule based on path matching regexextern crate wapc_guest as guest;#macro_useextern crate wasm_mock_util;#macro_useextern crate serde_json;use guest:prelude:*;use wasm_mock_util:*;fn echo_res_json(msg:&u8)-CallResult let mut res=foo_unmarshall:(msg)

9、?;res.HttpBody=json!(data:“hi);res.StatusCode=String:from(200)let res=serde_json:to_string(&res)?;Ok(res.as_bytes().to_vec()waPC in rust in HTTP(MITM)Modify_res functionextern crate wapc_guest as guest;.fn fiddler_ab(msg:&u8)-CallResult let fiddler_ab=foo_fiddler_ab(msg)?;if!fiddler_ab.UrlPath.conta

10、ins(flash_sale)let data_a=fiddler_ab.ResA;let data_b=fiddler_ab.ResB;foo_assert_eq!(data_a.HttpBody,data_b.HttpBody,String:from(data in echo);Ok(msg.to_vec()#no_manglepub extern C fn _start()。reg.insert(“/v2/matches/.*/info_fiddler_ab”.into(),fiddler_ab);AB testing 方案#allow(non_snake_case)#derive(Se

11、rialize,Deserialize,Debug)pub struct FiddlerAB#serde(rename=res_a)pub ResA:HttpResponse,#serde(rename=res_b)pub ResB:HttpResponse,#serde(rename=url_path)pub UrlPath:String,ResA:Response corresponding to unmodified requestResB:Response corresponding to modified request 模擬數據規則模擬數據規則 自動化測試自動化測試https:/

12、mock serverWhy use rust?Software testing tool 模擬數據規則模擬數據規則 自動化測試自動化測試Companys own protocolMicroservicesMultiple backend product line with complex upstreamCommon testing platform大公司抓包工具的需求大公司抓包工具的需求軟件測試工具 模擬數據規則模擬數據規則 自動化測試自動化測試Supports http/https/tcp/websocket(MITM)Can use rust to construct own prot

13、ocolCan MITM GRPCTesting platformSupport HTTP POST wasm APISupport websocket stand in for wasm API抓包抓包-Wasm Mock Serverwasm工具does not invent the wheel軟件測試工具 模擬數據規則模擬數據規則 自動化測試自動化測試ModifyRequest(req*http.Request)errorreq_,err:=wasm.Invoke(ctx,req.url.path,req_payload)req=req_ ModifyResponse(res*http.

14、Response)errorres_,err:=wasm.Invoke(ctx,res.url.path,req_payload)res=res_Wasm mock server 用了用了Google martian軟件測試工具 Websocket TCP mitm例子例子extern crate wapc_guest as guest;use guest:prelude:*;.fn _req(msg:&u8)-CallResult let tcp_payload:TcpPayload=rmp_serde:from_read_ref(msg)?;let c=|_c:&mut websocket

15、_codec:Message|-CallResult Ok(vec!);/change origin from 3334 to 3335(as the page is served in localhost:3334,but the mock server dial from port 3335)handle_ws_req(&tcp_payload,http:/localhost:3335,c)fn _res(msg:&u8)-CallResult let tcp_payload:TcpPayload=rmp_serde:from_read_ref(msg)?;let c=|c:&mut we

16、bsocket_codec:Message|-CallResult*c=websocket_codec:Message:text(echo);Ok(vec!);handle_ws_res(&tcp_payload,c)#no_manglepub extern C fn _start()let mut reg=REGISTRY.lock().unwrap();reg.insert(“3335-:3334_modify_req”.into(),_req);reg.insert(“3335-:3334_modify_res”.into(),_res);Example includes handsha

17、ke,websocket codec,and message modification模擬數據規則例子包括握手,數據解析,更改數據new Websocket(“ws:/localhost:3335)模擬前-before模擬后-afterWasm builds a req bufferIf wasm does not have enough bytes,send/continue back to hostElse send a list of TCP itemsTCP MITM例子 模擬數據規則模擬數據規則 自動化測試自動化測試驗證功能 Assertion穩定環境 Stable environm

18、ent報告能力(例如junit)ReportingBasic API testing requirementAPI測試也用rust軟件測試工具 模擬數據規則模擬數據規則 自動化測試自動化測試Multiple QA teamsUpgrading common library issuesAT framework consumes more and more memoryOne test case panics,crashes all the other AT jobsHigh maintenance due to programming language大公司大公司API測試的需求測試的需求軟件

19、測試工具 模擬數據規則模擬數據規則 自動化測試自動化測試Use rust to compile wasm and send to wasm mock serverLet Wasm Mock Server send http request升級平臺能解決不一致的問題Each rust file can be compiled into wasm separatelyWont exhaust memoryA test suite panic will not implicate the othersCan be compiled from many programming languageStor

20、e wasm files prevent maintenance issuesAPI測試測試-Wasm Mock Server用rust,好處多軟件測試工具Url param?loop=2index取取_iCommand 定義是定義是URLextern crate wapc_guest as guest;use guest:prelude:*;extern crate wasm_mock_util;use wasm_mock_util:*;fn command(msg:&u8)-CallResult let i=foo_index!();let mut command=String:from(

21、http:/localhost:8000/t.json);Ok(command.as_bytes().to_vec()#no_manglepub extern C fn _start()let mut reg=REGISTRY.lock().unwrap();reg.insert(“command”.into(),command);reg.insert(“request”.into(),request);reg.insert(“request_marshalling”.into(),request_marshalling);reg.insert(“response_marshalling”.i

22、nto(),response_marshalling);自動化HTTP請求例子自動化測試以循環循環方式執行Request用了用了http1xfoo_index!里取里取_i在在response_marshalling里里foo_assert_eq!()fn request(_msg:&u8)-CallResult /Change here let index=foo_index!();let mainHttpRes=match index 0=HttpRequest Http1x:format!(GET/HTTP/1.1rnHost:golang.orgrnConnection:closern

23、User-Agent:Mozilla/5.0(Macintosh;U;Intel Mac OS X;de-de)rnrn),HttpBody:vec!,ProxyUrl:String:from()_=.;let request=serde_json:to_string(&mainHttpRes)?;Ok(request.as_bytes().to_vec()fn response_marshalling(msg:&u8)-CallResult let http_res=foo_http_response(msg)?;foo_assert_eq!(http_res.HttpBody.get(da

24、ta).unwrap_or(&mut NULL),&json!(hi),data is hi);Ok(msg.to_vec()自動化HTTP請求例子自動化測試以循環循環方式執行測驗報告HTML/JSON 報告Wasm Mock Server 模擬數據規則模擬數據規則 自動化測試自動化測試 模擬數據規則模擬數據規則 自動化測試自動化測試Some of its Host callhttp request Tcp RequestTcp ResponseRedisGETSETMemcacheTimeSleepnowwebsocket standin for wasm可用Javascript在游覽器里面

25、模擬數據發RPC請求可以上傳proto文檔可以驗證數據前段鏈接Wasm Mock Server隨機隨機waPC注冊邏輯注冊邏輯Use wasm without fear支持以websocket代替wasm協議不可能為每個websocket鏈接編程新的wasm流氓做法(fork)-waPC guest rust 可改編成讓register_function在初始后使用Using“invoke”to register more functionhttps:/ Serialization in Rust is betterRust VS TinyGo(Serialization)Protobuf(with modified generated pb)JSON string TinygoQnAThank you!

友情提示

1、下載報告失敗解決辦法
2、PDF文件下載后,可能會被瀏覽器默認打開,此種情況可以點擊瀏覽器菜單,保存網頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站報告下載后的文檔和圖紙-無水印,預覽文檔經過壓縮,下載后原文更清晰。

本文(潘泳權wpac-應用waPC (rust) 做軟件測試工具.pptx)為本站 (2200) 主動上傳,三個皮匠報告文庫僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對上載內容本身不做任何修改或編輯。 若此文所含內容侵犯了您的版權或隱私,請立即通知三個皮匠報告文庫(點擊聯系客服),我們立即給予刪除!

溫馨提示:如果因為網速或其他原因下載失敗請重新下載,重復下載不扣分。
客服
商務合作
小程序
服務號
折疊
午夜网日韩中文字幕,日韩Av中文字幕久久,亚洲中文字幕在线一区二区,最新中文字幕在线视频网站