Hurl 4.0.0 रिलीज़
(hurl.dev)- Hurl 4.0.0 curl-आधारित CLI HTTP testing tool का नया version है, जो plain-text file में लिखे HTTP requests और response validations चलाने के flow को बेहतर बनाता है
- HTML report JavaScript के बिना, सिर्फ inline CSS इस्तेमाल करने वाले pure HTML के रूप में generate होती है, और request/response के हिसाब से waterfall timeline, execution log और inline errors साथ में दिखाती है
--error-format longfailed tests के response headers और body को output करता है, जिससे CI/CD debugging में दोबारा run किए बिना कारण समझने के लिए जरूरी context देखा जा सकता है- नए
decodeऔरxpathfilters से unclear charset वाले response bytes को सीधे decode किया जा सकता है, और HTML के कुछ हिस्सों पर XPath validation किया जा सकता है - JSONPath evaluation का कुछ behavior बदला है, और uppercase condition पूरी करने वाले custom HTTP methods को support किया गया है, जिससे
QUERYजैसे नए methods भी experiment किए जा सकते हैं
Hurl 4.0.0 का overview
- Hurl curl पर आधारित command-line tool है, जो simple plain-text format में defined HTTP requests execute करता है
- Hurl file में requests, expected HTTP status, headers, certificates, JSONPath जैसे validations (assert) साथ में लिखे जा सकते हैं
- Hurl 4.0.0 में मुख्य बदलाव HTML reports, error output, filters, JSONPath behavior, और custom HTTP method support के इर्द-गिर्द हैं
HTML report और waterfall timeline
- Hurl HTML report हर execution के लिए तीन तरह की जानकारी generate करती है
- Waterfall timeline: हर request/response को graph में दिखाती है और DNS, TCP handshake, time to first byte जैसी response timings check करने देती है
- Execution log: request/response headers और certificate information आदि शामिल करता है
- Syntax-highlighted source file: errors को inline दिखाती है
- Report JavaScript के बिना pure HTML और inline CSS से बनी होती है, इसलिए GitLab CI/CD या GitHub Actions जैसे CI/CD environments में integrate करना आसान है
- Waterfall timeline में इस्तेमाल timings
libcurlprovide करता है, और--jsonoption से भी expose होती हैं--jsonerrors, asserts, certificates, captures, cookies, timings सहित structured execution information देता है- इस JSON output से अपनी custom report बनाई जा सकती है
Visualization से सामने आया assert performance bottleneck
- Rich visualization छिपे हुए performance issues सामने ला सकती है
- कुछ executions में requests के बीच बड़े gaps दिखे, और कारण HTTP response पर asserts की बहुत बड़ी संख्या थी
- Hurl 4.0.0 के अनुसार assert calculation simple तरीके से काम करता है
- एक ही response का हर assert independent रूप से process होता है
- हर assert में शुरुआत से parsing और फिर से calculation होती है
- Hurl team को
libcurlऔर Rust combination की speed पर भरोसा था, लेकिन इस case के बाद उन्हें लगा कि अगले release में assert performance improvement जरूरी है
CI/CD के लिए detailed error output
- पहले test failure output expected values पर केंद्रित था, इसलिए analysis के लिए जरूरी information कम हो सकती थी
- नए
--error-formatoption से लंबा error description चुना जा सकता है --error-format longmode में response headers और response body automatically log में बचते हैं- Example में test
Control-Security-Policyheader ढूंढ रहा था, लेकिन actual response मेंContent-Security-Policyथा- Response headers और body log में शामिल होने से typo जैसी problem आसानी से check की जा सकती है
- यह option उन CI/CD environments में उपयोगी है जहां test दोबारा run किए बिना session debugging के लिए जरूरी context पाना हो
- Response body तक record होने की वजह से logs बहुत लंबे हो सकते हैं
नए filters: decode और xpath
- Hurl के text asserts response body bytes को automatically decode करते हैं, और इसके लिए
Content-Typeresponse header केcharsethint का इस्तेमाल करते हैं - कभी-कभी
Content-Typeमें encoding नहीं होती, या HTML document के अंदर<meta>tag में charset होता है - नया
decodefilter bytes को explicitly text में decode करके validate करने देता है- Example में GB2312-encoded body को
bytes decode "gb2312"से decode किया गया है
- Example में GB2312-encoded body को
- नया
xpathfilter response के किसी हिस्से पर XPath expression evaluate करने देता है- Example में
xpath "string(//body)"से HTMLbodytext validate किया गया है
- Example में
JSONPath evaluation method में बदलाव
- Hurl 4.0.0 ने JSONPath query evaluation में कुछ बदलाव किए हैं
- JSONPath के लिए ठीक-ठाक official specification नहीं है, और Hurl de facto standard की तरह इस्तेमाल होने वाले
goessner.netdocument को जितना हो सके follow करने की कोशिश करता है - Implementations के बीच edge cases अलग-अलग हैं
- Standard JSONPath हमेशा collection return करता है, लेकिन ज्यादातर cases में इसका अर्थ बहुत बड़ा नहीं होता और testing मुश्किल हो सकती है
- कुछ implementations definite path के node value और indefinite path के collection में अंतर करते हैं
- Hurl 4.0.0 में value return करने वाले selectors सिर्फ दो तरह के हैं
- Array index selector:
$.store.book[2] - Object key selector:
$.store.bicycle.color,$.store.bicycle['color']
- Array index selector:
- Filter इस्तेमाल करने वाले selectors या
$[*].idजैसे selectors collection return करते हैं- Collection से value निकालने के लिए
nthfilter इस्तेमाल किया जा सकता है
- Collection से value निकालने के लिए
Custom HTTP methods
- Hurl 4.0.0 arbitrary custom HTTP methods support करता है
- Method uppercase में लिखा होना चाहिए
- Example के तौर पर आने वाले नए
QUERYmethod को तुरंत experiment किया जा सकता है- संबंधित document: incoming new
QUERYmethod
- संबंधित document: incoming new
Release notes और participation request
- बाकी improvements और bug fixes release note में देखे जा सकते हैं
- Project GitHub star, Twitter sharing, improvement requests, और use cases sharing का अनुरोध करता है
1 टिप्पणियां
Hacker News की राय
Hurl का परिचय इस तरह शुरू होना अच्छा लगा: “curl-आधारित command-line टूल, जो simple plain-text format में परिभाषित HTTP requests चलाता है”
मैंने Hurl पहली बार देखा, और ऊपर दिए गए छोटे परिचय और code example को देखकर ही इसे तुरंत install करके आज़माने का मन हो गया; यह एक शानदार रिलीज़ लगती है
उदाहरण के लिए
Hurl: Run HTTP requests in a simple plain-text formatजैसा title बेहतर होताकाश यह API testing का industry standard बन जाए
QA द्वारा भेजे गए Postman screenshots देख-देखकर और fix के बाद QA के Send दबाने का इंतज़ार करते-करते थक गया हूँ; शायद QA भी developers का इंतज़ार करके थक गए होंगे
Hurl ऐसा लगता है जिसे developer और QA दोनों पढ़-लिख सकते हैं, automation और CI integration संभव है, expected behavior बताना आसान है, और इसे PR के साथ जोड़कर QA के लिए शुरुआती बिंदु बनाया जा सकता है, इसलिए जहाँ संभव हो वहाँ इसे न इस्तेमाल करने की कोई वजह नहीं दिखती
हर workflow के HTTP exchange flow को एक hurl file में रखा जा सकता है, और वह Git में जाने वाला test suite बन जाता है
फिर भी Hurl भी बहुत दिलचस्प है, और यह बात सही है कि editor पर निर्भर न होना इस समस्या के लिए बेहतर समाधान है
इसमें JS से load/performance tests लिखकर repository में commit किया जा सकता है, CI में आसानी से automate किया जा सकता है, metrics को कई backends में भेजा जा सकता है, HTTP के अलावा दूसरे protocols भी इस्तेमाल किए जा सकते हैं, और यह modern command-line interface व कई features देता है
Postman-to-k6 converter भी है: https://github.com/apideck-libraries/postman-to-k6
k6 का दर्शन यह है कि unit/integration tests की तरह developers ऐसे tests लिखें और पारंपरिक QA-dev cycle को तोड़ें; Hurl भी अच्छा लगता है, लेकिन मौजूदा performance testing tools की तुलना में इसकी functionality सीमित है, और व्यक्तिगत रूप से मैं dedicated text format की बजाय programming language में tests लिखना पसंद करता हूँ
भले ही source code से spec generate करने वाले tools इस्तेमाल किए जाएँ, endpoint metadata को गलत define करने वाली user error फिर भी हो सकती है, और Dredd उसे पकड़ लेता है
अब तक देखे गए आधुनिक Unix programs में यह सबसे अच्छे उदाहरणों में से एक के काफ़ी करीब है
यह standard input लेता है, standard output देता है, terminal भर में Unicode emoji नहीं बिखेरता, और इसकी man pages भी काफ़ी अच्छी हैं
hurl file extension का तीन की बजाय चार अक्षरों का होना भी अच्छा लगा; लगता है आखिरकार MS-DOS compatibility की चिंता से आगे बढ़ गए हैं
यह गंभीरता से इस्तेमाल करने लायक टूल लगता है
command-line HTTP tools में मुझे Httpie या उसका तेज़ Rust rewrite XH सबसे ज़्यादा पसंद है
इनकी syntax, curl की तुलना में HTTP के कहीं ज़्यादा करीब है, इसलिए command line से requests भेजना आसान है और ढेर सारे options सीखने की ज़रूरत नहीं पड़ती
अगर आप पहले से curl के आदी हैं तो यह बहुत उपयोगी न लगे, लेकिन हल्के इस्तेमाल के लिए यह कहीं ज़्यादा intuitive है
https://httpie.io/
https://github.com/ducaale/xh
Adaptive में हम test automation के लिए hurl.dev का व्यापक रूप से इस्तेमाल कर रहे हैं: https://adaptive.live
हम पूरे internal product flow को Hurl से test करते हैं, और product stabilization के लिहाज़ से संगठन में लाए गए फैसलों में यह सबसे अच्छा रहा है
हर deployment से पहले onboarding, signup, core flows आदि को validate करने वाले कई Hurl-based automated tests चलाते हैं, और containerized होने की वजह से इन्हें parallel में भी चलाया जा सकता है
हम hurl.dev के आसपास internal tools भी बना रहे हैं, और यह अच्छा है कि इसे सीखना आसान है, इसलिए analysts और business users भी tests बना सकते हैं
testing context में Selenium जैसा browser-based approach कहीं ज़्यादा शक्तिशाली और कुल मिलाकर ज़्यादा उपयोगी लगता है
मैंने docs देखे, लेकिन उससे जुड़ी जानकारी नहीं मिली
मैं कुछ समय से hurl को देख रहा हूँ, और दूसरी tools से इसे अलग करने वाली बात यह है कि testing के लिए इसका अपना DSL है
यह सिर्फ़ HTTP requests भेजने तक सीमित नहीं है; responses validate कर सकता है और data capture भी कर सकता है
लेकिन अगर maintainer यह पढ़ रहे हों, तो अच्छा होगा अगर validation को external scripts को सौंपने की सुविधा हो
उदाहरण के लिए, अगर किसी item collection की सभी properties का value एक जैसा है या नहीं यह validate करना हो, तो अभी
nthselector के बिना यह मुश्किल है, औरnth = *जैसा कुछ भी चाहिएहर use case को DSL में शामिल करना बहुत बड़ा काम है, इसलिए अगर jsonpath result को jq में पास करके true लौटने पर test pass कराया जा सके, तो वह उपयोगी होगा
हालाँकि ऐसा करने पर file कम self-contained रहेगी, और इससे काफ़ी जटिल समस्याएँ भी आ सकती हैं
Hurl तेज़ी से बढ़ रहा है, इसलिए यह अच्छा दिख रहा है
endpoint testing में हमेशा authentication चाहिए होती है; क्या authentication को एक file में लिखकर token की ज़रूरत वाली दूसरी files की शुरुआत में उसे लाने का कोई तरीका है?
वैसे भी यह पक्का नहीं कि secrets को store और use करने का यही सबसे अच्छा तरीका है
docs के अनुसार command-line arguments और environment variables के ज़रिए hurl files में variables पास किए जा सकते हैं: https://hurl.dev/docs/templates.html
इस काम के लिए httpyac भी काफ़ी पसंद है: https://httpyac.github.io
इसमें JS scripting की सुविधा है, इसलिए यह काफी मिलता-जुलता है, और command-line interface के अलावा VS Code integration भी शानदार है
.httpsupport के साथ भी अच्छी compatibility रखता हैJetBrains
.httpfiles से jUnit test reports बनाने के लिए एक free command-line tool भी देता हैअभी पता चला कि Visual Studio 2022 भी
.httpfiles के साथ ऐसा ही feature support करता है: https://learn.microsoft.com/en-us/aspnet/core/test/http-file...Hurl feature के मामले में काफ़ी आगे दिखता है