IT

Generating Test Data with TDCV2: Integration with Custom Services

Learn how to generate a million test users using TDCV2 and an external HTTP service while keeping passwords secure and reproducible.

·2 min read
Generating Test Data with TDCV2: Integration with Custom Services

The article series "Data Without Contradictions" focuses on TDCV2, an open-source test data constructor that helps generate realistic datasets ranging from a few rows to hundreds of thousands. In the seventh part, the author explores scenarios where internal tools are not enough and values must be computed by an external server.

Why Use a Custom Service for Data Generation In real-world applications, passwords are never stored in plaintext; instead, they are hashed using a unique salt and a secret pepper via slow hashing functions like scrypt. The pepper resides strictly in the server environment variables and should never be exposed in configuration files. Duplicating hashing logic inside a configuration file is risky because algorithms can silently diverge over time. Therefore, delegating the hashing process to the actual application code while the generator simply queries it is the most robust architecture.

Architecture of TDCV2 and HTTP Generator Interaction The TDCV2 constructor sends HTTP requests to a specified address, delivering data in batches of 10,000 rows to optimize memory usage. Request headers carry essential metadata such as the total row count, offset, and seed identifier. The protocol is intentionally simple: the constructor sends a POST request with one value per line in the body, and the service replies with a plain text response matching the exact order, enabling high-performance processing without heavy libraries.

Ensuring Determinism and Reproducibility The primary requirement for a test data generator is byte-for-byte reproducibility given the same initial seed. The external service must accept the provided seed and compute row values strictly based on it and the row's absolute index. Using Math.random() or system clocks is strictly prohibited because network packets may arrive out of order or be processed concurrently. A row's value must solely depend on the column seed and the row offset.

Practical Implications for Developers and Testing This approach enables the creation of fully functional test environments with millions of valid user accounts ready for automated testing. At the same time, sensitive security keys and peppers never leave the secure application server boundary. For engineering teams, this provides a clean architectural pattern to integrate test data generation with real business logic without compromising security or consistency.

Source: Все публикации подряд на Хабре

Related articles