hubcio commented on code in PR #4703:
URL: https://github.com/apache/iggy/pull/4703#discussion_r4470483053


##########
core/partitions/src/iggy_partition_tests/persistence_consensus.rs:
##########
@@ -0,0 +1,1365 @@
+// 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
+
+#[test]
+fn 
given_topic_durability_when_installed_should_tell_consensus_whether_restarts_keep_acks()
 {
+    let mut partition = test_partition();
+    assert!(
+        !partition.consensus().recovered_log_complete(),
+        "the default `replicated` policy acknowledges before the write"
+    );
+    for (durability, consumer_offset_durability, complete) in [
+        (Persisted, Persisted, true),
+        (Replicated, Persisted, false),
+        (Persisted, Replicated, false),
+        (Replicated, Replicated, false),
+    ] {
+        partition.set_runtime_options(TopicRuntimeOptions {
+            durability,
+            consumer_offset_durability,
+            ..TopicRuntimeOptions::default()
+        });
+        assert_eq!(
+            partition.consensus().recovered_log_complete(),
+            complete,
+            "{durability:?} messages, {consumer_offset_durability:?} offsets"
+        );
+    }
+}
+
+/// Replace the fixture's initial segment with real files and offset stores.
+/// Keep the returned directory alive until every read using those files ends.
+async fn disk_poll_partition(
+    config: &PartitionsConfig,
+) -> (tempfile::TempDir, IggyPartition<IggyMessageBus>) {
+    Box::pin(disk_poll_partition_with_replicas(config, 1)).await
+}
+
+async fn disk_poll_partition_with_replicas(
+    config: &PartitionsConfig,
+    replica_count: u8,
+) -> (tempfile::TempDir, IggyPartition<IggyMessageBus>) {
+    let directory = tempfile::tempdir().expect("create partition directory");
+    let mut partition = test_partition_with_replicas(replica_count);
+    
partition.set_partition_dir(directory.path().to_string_lossy().into_owned());
+    partition.log.retire_front().expect("retire empty segment");
+    partition
+        .install_empty_segment(config, 0)
+        .await
+        .expect("install segment with real writers");
+
+    let consumer_path = directory.path().join("consumer_offsets");
+    let group_path = directory.path().join("consumer_group_offsets");
+    let external_path = directory.path().join("external_group_offsets");
+    for path in [&consumer_path, &group_path, &external_path] {
+        compio::fs::create_dir_all(path)
+            .await
+            .expect("create offsets directory");
+    }
+    partition.configure_consumer_offset_storage(
+        [&consumer_path, &group_path, &external_path]
+            .map(|path| path.to_string_lossy().into_owned()),
+        ConsumerOffsets::with_capacity(1),
+        ConsumerGroupOffsets::with_capacity(1),
+    );
+    (directory, partition)
+}
+
+// /// A SOLO partition, the shape the offset reservation is scoped to.
+// fn solo_recording_partition() -> IggyPartition<IggyMessageBus, 
RecordingSuperblock> {

Review Comment:
   simplification: these commented helpers duplicate active definitions in the 
parent test module. delete both commented blocks.



-- 
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]

Reply via email to