Skip to content

Commit db6c7cc

Browse files
authored
chore: remove block data from the repo (#843)
Signed-off-by: Alex Kehayov <[email protected]>
1 parent 5a9f557 commit db6c7cc

15 files changed

+52
-61
lines changed

simulator/build.gradle.kts

-9
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ tasks.register<JavaExec>("runConsumer") {
7272
environment("PROMETHEUS_ENDPOINT_PORT_NUMBER", "9997")
7373
}
7474

75-
tasks.register<Sync>("untarTestBlockStream") {
76-
description = "Untar the test block stream data"
77-
78-
from(tarTree(resources.gzip(file("src/main/resources/block-0.0.3.tar.gz"))))
79-
into(layout.buildDirectory.dir("extracted-resources"))
80-
}
81-
82-
sourceSets.main { resources.srcDir(tasks.named("untarTestBlockStream")) }
83-
8475
// Vals
8576
val dockerProjectRootDirectory: Directory = layout.projectDirectory.dir("docker")
8677
var resourcesProjectRootDirectory: Directory = layout.projectDirectory.dir("src/main/resources")

simulator/docker/Dockerfile

+2-11
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,11 @@ COPY simulator-*.tar ./simulator.tar
1414
RUN mkdir -p /app/logs/config
1515
COPY logging.properties /app/logs/config/logging.properties
1616

17-
# Create resources directory and copy block data
18-
RUN mkdir -p src/main/resources
19-
COPY block-0.0.3.tar.gz src/main/resources/
20-
2117
# Extract the distribution and block data
2218
RUN tar -xf simulator.tar && \
2319
rm simulator.tar && \
24-
cd src/main/resources && \
25-
tar -xzf block-0.0.3.tar.gz && \
26-
rm block-0.0.3.tar.gz && \
27-
cd /app
28-
29-
RUN mkdir -p /opt/simulator/data
30-
RUN chown -R $UID:$GID /app /opt/simulator/data
20+
cd /app && \
21+
chown -R $UID:$GID /app
3122

3223
# Switch to non-root user
3324
USER $UNAME

simulator/src/main/java/org/hiero/block/simulator/config/data/BlockGeneratorConfig.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.swirlds.config.api.validation.annotation.Min;
77
import java.nio.file.Files;
88
import java.nio.file.Path;
9-
import java.nio.file.Paths;
9+
import org.hiero.block.common.utils.StringUtilities;
1010
import org.hiero.block.simulator.config.logging.Loggable;
1111
import org.hiero.block.simulator.config.types.GenerationMode;
1212

@@ -44,23 +44,27 @@ public record BlockGeneratorConfig(
4444
* @throws IllegalArgumentException if the folder root path is not absolute or the folder does not exist
4545
*/
4646
public BlockGeneratorConfig {
47-
// Verify folderRootPath property
48-
Path path = Path.of(folderRootPath);
47+
// Default generation mode is CRAFT.
48+
// If set to DIR, block files must be located in a directory on the file system.
49+
// Set location at app.properties
50+
if (generationMode == GenerationMode.DIR) {
51+
// Verify folderRootPath property
52+
// Check if not empty
53+
if (StringUtilities.isBlank(folderRootPath)) {
54+
throw new IllegalArgumentException("Root path is not provided");
55+
}
56+
Path path = Path.of(folderRootPath);
57+
// Check if absolute
58+
if (!path.isAbsolute()) {
59+
throw new IllegalArgumentException(folderRootPath + " Root path must be absolute");
60+
}
61+
// Check if the folder exists
62+
if (Files.notExists(path)) {
63+
throw new IllegalArgumentException("Folder does not exist: " + path);
64+
}
4965

50-
// If folderRootPath is empty, set it to the default data directory
51-
if (folderRootPath.isEmpty()) {
52-
path = Paths.get("").toAbsolutePath().resolve("build/resources/main//block-0.0.3");
66+
folderRootPath = path.toString();
5367
}
54-
// Check if absolute
55-
if (!path.isAbsolute()) {
56-
throw new IllegalArgumentException(folderRootPath + " Root path must be absolute");
57-
}
58-
// Check if the folder exists
59-
if (Files.notExists(path) && generationMode == GenerationMode.DIR) {
60-
throw new IllegalArgumentException("Folder does not exist: " + path);
61-
}
62-
63-
folderRootPath = path.toString();
6468

6569
if (endBlockNumber > -1 && endBlockNumber < startBlockNumber) {
6670
throw new IllegalArgumentException("endBlockNumber must be greater than or equal to startBlockNumber");
-6.36 KB
Binary file not shown.

simulator/src/test/java/org/hiero/block/simulator/BlockStreamSimulatorTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void start_constantRateStreaming() throws InterruptedException, BlockSimulatorPa
156156
"generator.managerImplementation",
157157
"BlockAsFileLargeDataSets",
158158
"generator.rootPath",
159-
getAbsoluteFolder("build/resources/test//block-0.0.3-blk/"),
159+
getAbsoluteFolder("build/resources/test/block-0.0.3-blk/"),
160160
"blockStream.streamingMode",
161161
"CONSTANT_RATE",
162162
"blockStream.blockItemsBatchSize",
@@ -242,7 +242,7 @@ void start_millisPerBlockStreaming() throws InterruptedException, IOException, B
242242
"generator.managerImplementation",
243243
"BlockAsFileLargeDataSets",
244244
"generator.rootPath",
245-
getAbsoluteFolder("build/resources/test//block-0.0.3-blk/"),
245+
getAbsoluteFolder("build/resources/test/block-0.0.3-blk/"),
246246
"blockStream.streamingMode",
247247
"MILLIS_PER_BLOCK"));
248248

@@ -286,7 +286,7 @@ void start_millisPerSecond_streamingLagVerifyWarnLog()
286286
"generator.managerImplementation",
287287
"BlockAsFileBlockStreamManager",
288288
"generator.rootPath",
289-
getAbsoluteFolder("build/resources/test//block-0.0.3-blk/"),
289+
getAbsoluteFolder("build/resources/test/block-0.0.3-blk/"),
290290
"blockStream.maxBlockItemsToStream",
291291
"2",
292292
"blockStream.streamingMode",

simulator/src/test/java/org/hiero/block/simulator/TestUtils.java

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.IOException;
1212
import java.net.ServerSocket;
1313
import java.nio.file.Path;
14+
import java.nio.file.Paths;
1415
import java.util.Map;
1516

1617
public class TestUtils {
@@ -48,4 +49,8 @@ public static int findFreePort() throws IOException {
4849
return socket.getLocalPort();
4950
}
5051
}
52+
53+
public static String getAbsoluteFolder(@NonNull String relativePath) {
54+
return Paths.get(relativePath).toAbsolutePath().toString();
55+
}
5156
}

simulator/src/test/java/org/hiero/block/simulator/config/data/BlockStreamConfigTest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private BlockStreamConfig.Builder getBlockStreamConfigBuilder() {
3333
}
3434

3535
private BlockGeneratorConfig.Builder getBlockGeneratorConfigBuilder() {
36-
String folderRootPath = "build/resources/main//block-0.0.3/";
36+
String folderRootPath = "build/resources/test/block-0.0.3-blk/";
3737
GenerationMode generationMode = GenerationMode.DIR;
3838

3939
String blockStreamManagerImplementation = "BlockAsFileBlockStreamManager";
@@ -85,7 +85,7 @@ void testLastKnownStatusesCapacity() {
8585
@Test
8686
void testValidAbsolutePath() {
8787
// Setup valid folder path and generation mode
88-
String gzRootFolder = "build/resources/main//block-0.0.3/";
88+
String gzRootFolder = "build/resources/test/block-0.0.3-blk/";
8989
String folderRootPath = getAbsoluteFolder(gzRootFolder);
9090
GenerationMode generationMode = GenerationMode.DIR;
9191

@@ -108,15 +108,15 @@ void testEmptyFolderRootPath() {
108108
// Setup empty folder root path and generation mode
109109
String folderRootPath = "";
110110
GenerationMode generationMode = GenerationMode.DIR;
111-
BlockGeneratorConfig.Builder builder =
112-
getBlockGeneratorConfigBuilder().folderRootPath(folderRootPath).generationMode(generationMode);
113111

114-
BlockGeneratorConfig config = builder.build();
112+
// Verify that an exception is thrown
113+
IllegalArgumentException exception =
114+
assertThrows(IllegalArgumentException.class, () -> getBlockGeneratorConfigBuilder()
115+
.folderRootPath(folderRootPath)
116+
.generationMode(generationMode)
117+
.build());
115118

116-
// Verify that the path is set to the default
117-
Path expectedPath = Paths.get("build/resources/main//block-0.0.3/").toAbsolutePath();
118-
assertEquals(expectedPath.toString(), config.folderRootPath());
119-
assertEquals(GenerationMode.DIR, config.generationMode());
119+
assertEquals("Root path is not provided", exception.getMessage());
120120
}
121121

122122
@Test

simulator/src/test/java/org/hiero/block/simulator/generator/BlockAsFileBlockStreamManagerTest.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package org.hiero.block.simulator.generator;
33

4+
import static org.hiero.block.simulator.TestUtils.getAbsoluteFolder;
45
import static org.junit.jupiter.api.Assertions.*;
56

67
import java.io.IOException;
7-
import java.nio.file.Paths;
88
import org.hiero.block.simulator.config.data.BlockGeneratorConfig;
99
import org.hiero.block.simulator.config.types.GenerationMode;
1010
import org.hiero.block.simulator.exception.BlockSimulatorParsingException;
@@ -13,13 +13,9 @@
1313

1414
class BlockAsFileBlockStreamManagerTest {
1515

16-
private final String gzRootFolder = "build/resources/main//block-0.0.3/";
16+
private final String gzRootFolder = "build/resources/test/block-0.0.3-blk/";
1717
private BlockStreamManager blockStreamManager;
1818

19-
private String getAbsoluteFolder(String relativePath) {
20-
return Paths.get(relativePath).toAbsolutePath().toString();
21-
}
22-
2319
@BeforeEach
2420
void setUp() {
2521
blockStreamManager = getBlockAsFileBlockStreamManager(getAbsoluteFolder(gzRootFolder));
@@ -40,14 +36,15 @@ void getNextBlock() throws IOException, BlockSimulatorParsingException {
4036

4137
@Test
4238
void getNextBlockItem() throws IOException, BlockSimulatorParsingException {
43-
for (int i = 0; i < 35000; i++) {
39+
// iterates the block items of the blocks in gzRootFolder
40+
for (int i = 0; i < 72; i++) {
4441
assertNotNull(blockStreamManager.getNextBlockItem());
4542
}
4643
}
4744

4845
@Test
4946
void loadBlockBlk() throws IOException, BlockSimulatorParsingException {
50-
String blkRootFolder = "build/resources/test//block-0.0.3-blk/";
47+
String blkRootFolder = "build/resources/test/block-0.0.3-blk/";
5148
BlockStreamManager blockStreamManager = getBlockAsFileBlockStreamManager(getAbsoluteFolder(blkRootFolder));
5249
blockStreamManager.init();
5350

@@ -59,7 +56,7 @@ void BlockAsFileBlockStreamManagerInvalidRootPath() {
5956
assertThrows(
6057
RuntimeException.class,
6158
() -> getBlockAsFileBlockStreamManager(
62-
getAbsoluteFolder("build/resources/test//BlockAsDirException/1/")));
59+
getAbsoluteFolder("build/resources/test/BlockAsDirException/1/")));
6360
}
6461

6562
private BlockStreamManager getBlockAsFileBlockStreamManager(String rootFolder) {

simulator/src/test/java/org/hiero/block/simulator/generator/BlockAsFileLargeDataSetsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
class BlockAsFileLargeDataSetsTest {
2424

25-
private static final String rootFolder = "build/resources/test//block-0.0.3-blk/";
25+
private static final String rootFolder = "build/resources/test/block-0.0.3-blk/";
2626
private static int filesInFolder;
2727

2828
@BeforeAll

simulator/src/test/java/org/hiero/block/simulator/generator/GeneratorInjectionModuleTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package org.hiero.block.simulator.generator;
33

4+
import static org.hiero.block.simulator.TestUtils.getAbsoluteFolder;
45
import static org.junit.jupiter.api.Assertions.*;
56

67
import java.io.IOException;
@@ -32,7 +33,9 @@ void providesBlockStreamManager_AsFileLargeDataSets() throws IOException {
3233
"generator.generationMode",
3334
"DIR",
3435
"generator.managerImplementation",
35-
"BlockAsFileLargeDataSets"))
36+
"BlockAsFileLargeDataSets",
37+
"generator.folderRootPath",
38+
getAbsoluteFolder("build/resources/test/block-0.0.3-blk/")))
3639
.getConfigData(BlockGeneratorConfig.class);
3740

3841
final BlockStreamManager blockStreamManager = GeneratorInjectionModule.providesBlockStreamManager(
@@ -49,7 +52,7 @@ void providesBlockStreamManager_AsFile() throws IOException {
4952
"generator.managerImplementation",
5053
"BlockAsFileBlockStreamManager",
5154
"generator.folderRootPath",
52-
""))
55+
getAbsoluteFolder("build/resources/test/block-0.0.3-blk/")))
5356
.getConfigData(BlockGeneratorConfig.class);
5457

5558
final BlockStreamManager blockStreamManager = GeneratorInjectionModule.providesBlockStreamManager(
@@ -66,7 +69,7 @@ void providesBlockStreamManager_default() throws IOException {
6669
"generator.managerImplementation",
6770
"",
6871
"generator.folderRootPath",
69-
""))
72+
getAbsoluteFolder("build/resources/test/block-0.0.3-blk/")))
7073
.getConfigData(BlockGeneratorConfig.class);
7174

7275
final BlockStreamManager blockStreamManager = GeneratorInjectionModule.providesBlockStreamManager(
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)