4 पॉइंट द्वारा GN⁺ 2024-02-28 | 1 टिप्पणियां | WhatsApp पर शेयर करें
  • Docker containers में चल सकने वाले database, message broker, web browser आदि उपलब्ध कराने वाला open source framework
  • जटिल environment setup या mock objects की ज़रूरत नहीं होती; code में test dependencies define करके test चलाने पर container बनते और हटाए जाते हैं
  • यह कई languages और test frameworks को support करता है, और सिर्फ Docker होने पर शुरुआत की जा सकती है
  • Modules: जो कुछ भी containerize किया जा सकता है, उसे test करें
    • database, message broker आदि सहित 50 से अधिक modules के ज़रिए विभिन्न components को test किया जा सकता है.
  • समर्थित भाषाएँ: Java, Go, .NET, Node.js, Python, Rust, Haskell, Ruby, Clojure, Elixir आदि कई लोकप्रिय भाषाओं के लिए Testcontainers implementations उपलब्ध हैं.

उपयोग के मामले: Testcontainers कैसे मदद कर सकता है

  • data access layer integration testing: containerized database instances का उपयोग करके data access layer code को test करें
  • UI/acceptance testing: Selenium-compatible containerized web browsers का उपयोग करके automated UI tests चलाएँ
  • application integration testing: database, message queue, web server जैसी dependencies के साथ short-lived test mode में application चलाकर समृद्ध interaction और exploratory testing environment प्रदान करें

GN⁺ की राय

  • Testcontainers डेवलपर्स को वास्तविक environment जैसे हालात में tests चलाने में सक्षम बनाता है, जिससे software quality बेहतर करने में मदद मिलती है.
  • वास्तविक dependencies के साथ testing, mock objects के उपयोग की तुलना में अधिक सटीक test results दे सकती है, लेकिन जटिल systems में setup और management कठिन हो सकते हैं.
  • Testcontainers जैसी सुविधाएँ देने वाले अन्य projects में Docker Compose, Kubernetes Minikube आदि शामिल हैं; इन्हें भी development environment में testing में मदद करने वाले tools के रूप में इस्तेमाल किया जा सकता है.
  • Testcontainers अपनाते समय Docker की समझ आवश्यक होती है, और container management तथा network configuration के बारे में तकनीकी ज्ञान की ज़रूरत पड़ सकती है.
  • इस तकनीक को चुनने से मिलने वाले लाभ हैं development और test environments में consistency तथा tests की reliability में सुधार, जबकि Docker environment पर निर्भरता और उससे जुड़ी जटिलता इसकी कमियाँ हो सकती हैं.

1 टिप्पणियां

 
GN⁺ 2024-02-28
Hacker News टिप्पणियाँ
  • पहली टिप्पणी का सार:

    • Testcontainers की इतनी तारीफ़ की उम्मीद नहीं थी.
    • अगर आप ऐसे माहौल से आते हैं जहाँ Docker इस्तेमाल नहीं होता, तो यह आकर्षक लग सकता है.
    • कई use cases में यह उपयोगी है, लेकिन दूसरे containerized workflows के साथ इसे अच्छी तरह काम कराना मुश्किल है.
    • Testcontainers एक ऐसी लाइब्रेरी है जो अपने core feature के लिए Docker CLI पर custom shell calls का इस्तेमाल करती है, जिससे दूसरे containerized workflows अपनाते समय समस्याएँ और complexity पैदा होती हैं.
    • यह मानकर चलती है कि यह सिर्फ host machine पर चलेगी और Docker से जुड़े अन्य काम नहीं होंगे, इसलिए कई बार non-Docker environments की libraries से भी खराब साबित हो सकती है.
  • दूसरी टिप्पणी का सार:

    • integration testing में Testcontainers एक game changer है.
    • यह language-specific Docker APIs देता है, जिससे containers को आसानी से चलाया जा सकता है और readiness check किया जा सकता है.
    • हर नए project में integration tests के लिए Testcontainers इस्तेमाल किया जाता है.
    • CI setup में linting, build, unit tests, और Testcontainers के साथ integration tests शामिल होते हैं.
    • language bindings database operations के लिए उपयोगी helper functions देती हैं.
  • तीसरी टिप्पणी का सार:

    • यह समझ नहीं आता कि docker-compose.yml का इस्तेमाल बेहतर क्यों नहीं है.
    • जब ज़रूरी containers के बीच complex dependencies हों, तब Testcontainers अपेक्षाकृत कमजोर है.
    • इसे 5 साल पहले इस्तेमाल करने का अनुभव है, लेकिन अब स्थिति काफी बेहतर हुई हो सकती है.
  • चौथी टिप्पणी का सार:

    • असली database/Elasticsearch/Redis/Varnish आदि का इस्तेमाल करने वाले integration tests को बहुत मूल्यवान माना गया है.
    • Testcontainers test suite के दौरान नया Elasticsearch index बनाना और बाद में उसे बंद करना जैसे काम संभाल लेता है.
    • strategy यह पसंद है कि application functionality को जितना संभव हो end-to-end integration style tests से cover किया जाए.
    • unit tests सिर्फ उन code हिस्सों के लिए उपयोग किए जाते हैं जिनके input/output pairs स्पष्ट हों, और mock objects का उपयोग उन चीज़ों के लिए किया जाता है जैसे external API calls जिन्हें नियंत्रित नहीं किया जा सकता.
  • पाँचवीं टिप्पणी का सार:

    • लगभग 7 साल पहले Go के लिए Testcontainers जैसा conex लिखा गया था.
    • यह Go के official testing framework के साथ first-class integration देता है.
  • छठी टिप्पणी का सार:

    • यह राय है कि हर test के लिए नया और साफ browser instance देना धीमा होता है.
    • अगर आप पहले से container world में निवेश कर चुके हैं, तो कुछ अतिरिक्त containers स्वीकार करना ठीक है.
    • नहीं तो अतिरिक्त complexity या overhead के मुकाबले इसका खास फायदा नहीं है.
  • सातवीं टिप्पणी का सार:

    • Testcontainers को देखकर उसका अपना version बनाया गया.
    • Docker एक leaky abstraction है, और tests को अलग-अलग environments में चलाना पड़ता है.
    • Mac, Linux VM, और Linux VM के अंदर Docker socket mount किए हुए Docker container में networking पूरी तरह अलग होती है.
    • tests को parallel में चलाना है और हर test के अनुरूप logs भी चाहिए.
    • यह स्पष्ट नहीं है कि Testcontainers ने इन समस्याओं को हल किया है या नहीं, लेकिन यह समझ आया कि असली मुश्किलें details में छिपी होती हैं.
  • आठवीं टिप्पणी का सार:

    • local test environment को docker-compose से बनाया जाता है.
    • Testcontainers एक programming language abstraction जैसा लगता है, जिससे Docker Compose syntax सीखे बिना Docker environment define किया जा सकता है.
    • test environment इस्तेमाल के लिए तैयार है या नहीं, यह समझने के लिए फिर भी Docker networking, dependencies, और health checks की समझ चाहिए.
  • नौवीं टिप्पणी का सार:

    • mock objects या complex environment setup की ज़रूरत नहीं होती.
    • test dependencies को code में define करके test चलाने पर containers बनते हैं और बाद में हट जाते हैं.
    • सिर्फ इसलिए कि containers के साथ integration tests चल सकते हैं, यह मान लेना गलत है कि unit tests की ज़रूरत नहीं रही.
    • Docker containers को configure करना आसान है, लेकिन containers को start करना दर्दनाक और धीमा है.
  • दसवीं टिप्पणी का सार:

    • यह Java के logo में Duke के इस्तेमाल पर एक सवाल है.