You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2023/11/27 08:23:57 UTC

[PR] IGNITE-20969 Decrease default data region sizes in tests [ignite-3]

ibessonov opened a new pull request, #2879:
URL: https://github.com/apache/ignite-3/pull/2879

   https://issues.apache.org/jira/browse/IGNITE-20969
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20969 Decrease default data region sizes in tests [ignite-3]

Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #2879:
URL: https://github.com/apache/ignite-3/pull/2879#discussion_r1405978579


##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/TestIgnitionManager.java:
##########
@@ -76,20 +94,36 @@ public static CompletableFuture<Ignite> start(String nodeName, @Nullable String
         try {
             Files.createDirectories(workDir);
             Path configPath = workDir.resolve(DEFAULT_CONFIG_NAME);
-            if (configStr == null) {
-                if (Files.notExists(configPath)) {
-                    Files.createFile(configPath);
-                }
-            } else {
-                Files.writeString(configPath, configStr,
-                        StandardOpenOption.SYNC, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
-            }
+
+            addDefaultsToConfigurationFile(configStr, configPath);
+
             return IgnitionManager.start(nodeName, configPath, workDir);
         } catch (IOException e) {
             throw new IgniteException("Couldn't write node config.", e);
         }
     }
 
+    /**
+     * Writes default values into the configuration file, according to the same rules that are used in {@link #start(String, String, Path)}.
+     */
+    public static void addDefaultsToConfigurationFile(Path configPath) {
+        try {
+            addDefaultsToConfigurationFile(null, configPath);
+        } catch (IOException e) {
+            throw new IgniteException("Couldn't update node configuration file", e);
+        }
+    }
+
+    private static void addDefaultsToConfigurationFile(@Nullable String configStr, Path configPath) throws IOException {
+        if (configStr == null && Files.exists(configPath)) {
+            // Nothing to do.
+            return;
+        }
+
+        Files.writeString(configPath, applyTestDefaultsToConfig(configStr, DEFAULT_NODE_CONFIG),
+                StandardOpenOption.SYNC, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);

Review Comment:
   Same here about the static import



##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/TestIgnitionManager.java:
##########
@@ -108,33 +142,34 @@ private static InitParameters applyTestDefaultsToClusterConfig(InitParameters pa
                 .metaStorageNodeNames(params.metaStorageNodeNames())
                 .cmgNodeNames(params.cmgNodeNames());
 
+        builder.clusterConfiguration(applyTestDefaultsToConfig(params.clusterConfiguration(), DEFAULT_CLUSTER_CONFIG));
+
+        return builder.build();
+    }
+
+    private static String applyTestDefaultsToConfig(@Nullable String configStr, Map<String, String> defaults) {
+        if (configStr == null) {
+            configStr = "{}";
+        }
+
         ConfigDocument configDocument;
 
-        if (params.clusterConfiguration() == null) {
-            configDocument = ConfigDocumentFactory.parseString("{}");
-        } else {
-            configDocument = ConfigDocumentFactory.parseString(params.clusterConfiguration());
+        try {
+            configDocument = ConfigDocumentFactory.parseString(configStr);
+        } catch (ConfigException e) {
+            // Preserve original broken content, it might be broken on purpose.

Review Comment:
   Sorry, what do you mean by "broken on purpose"?



##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/TestIgnitionManager.java:
##########
@@ -45,6 +49,20 @@ public class TestIgnitionManager {
     /** Default partition idle SafeTime interval in ms used for tests that is set on node init. */
     public static final int DEFAULT_PARTITION_IDLE_SYNC_TIME_INTERVAL_MS = 100;
 
+    /** Map with default node configuration values. */
+    private static final Map<String, String> DEFAULT_NODE_CONFIG = Map.of(
+            "aipersist.defaultRegion.size", Integer.toString(256 * Constants.MiB),

Review Comment:
   I'd have a static import for `Constants` but that's up to you



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20969 Decrease default data region sizes in tests [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #2879:
URL: https://github.com/apache/ignite-3/pull/2879


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20969 Decrease default data region sizes in tests [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2879:
URL: https://github.com/apache/ignite-3/pull/2879#discussion_r1405983925


##########
modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/TestIgnitionManager.java:
##########
@@ -108,33 +142,34 @@ private static InitParameters applyTestDefaultsToClusterConfig(InitParameters pa
                 .metaStorageNodeNames(params.metaStorageNodeNames())
                 .cmgNodeNames(params.cmgNodeNames());
 
+        builder.clusterConfiguration(applyTestDefaultsToConfig(params.clusterConfiguration(), DEFAULT_CLUSTER_CONFIG));
+
+        return builder.build();
+    }
+
+    private static String applyTestDefaultsToConfig(@Nullable String configStr, Map<String, String> defaults) {
+        if (configStr == null) {
+            configStr = "{}";
+        }
+
         ConfigDocument configDocument;
 
-        if (params.clusterConfiguration() == null) {
-            configDocument = ConfigDocumentFactory.parseString("{}");
-        } else {
-            configDocument = ConfigDocumentFactory.parseString(params.clusterConfiguration());
+        try {
+            configDocument = ConfigDocumentFactory.parseString(configStr);
+        } catch (ConfigException e) {
+            // Preserve original broken content, it might be broken on purpose.

Review Comment:
   Sometimes we test what happens if configuration file is corrupted/contains error. We must preserve the exception



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org