EgorBaranovEnjoysTyping commented on code in PR #13285: URL: https://github.com/apache/ignite/pull/13285#discussion_r3821159724
########## modules/ducktests/DEV_GUIDE.md: ########## @@ -0,0 +1,518 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +# How to Write a New DuckTest + +The ignite-ducktests framework is a bilingual integration testing framework: + +| Layer | Language | Purpose | +|----------------------|----------|-------------------------------------------------------------------| +| Test orchestration | Python | Manages Docker containers, starts/stops nodes, asserts results | +| In-cluster workloads | Java | Runs inside Ignite nodes (cache ops, transactions, queries, etc.) | + +Each Ignite node runs in a separate Docker container. The Python layer manages container lifecycle and simulates network failures via iptables. + +--- +## Write a Java Application (if needed) + +All Java applications extend IgniteAwareApplication. Create a new file under: +modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/<your_package>/<YourApp>.java + +### Example: +```java +package org.apache.ignite.internal.ducktest.tests.mytest; + +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication; + +public class MyTestApp extends IgniteAwareApplication { + @Override + protected void run(JsonNode params) throws Exception { + // 1. Signal initialization — Python side waits for this + markInitialized(); + // 2. Parse parameters passed from Python + String cacheName = params.get("cacheName").asText(); + int range = params.get("range").asInt(1000); + + // 3. Use the cluster (depends on service type) + // NODE mode → this.ignite (full Ignite node) + // THIN_CLIENT → this.client (IgniteClient) + // THIN_JDBC → this.thinJdbcDataSource + IgniteCache<Integer, String> cache = ignite.cache(cacheName); + for (int i = 0; i < range; i++) + cache.put(i, "val-" + i); + // 4. Record a result back to Python (readable via extract_result()) + recordResult("putCount", String.valueOf(range)); + + // 5. For long-running apps, loop until SIGTERM: + // while (!terminated()) { U.sleep(100); } + + // 6. Signal completion — Python side waits for this on stop() + markFinished(); + } +} +``` +--- +## Application Lifecycle Methods Review Comment: This is the contract between the Java app and the Python runner. Without it, a developer writing a new Java app wouldn't know which token to print, or why `start()` doesn't return until `markInitialized()`. I'd argue it's the most important section for Java-side authors. Keeping it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
