File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
common/src/main/java/org/tron/common/setting Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ subprojects {
9898 reproducibleFileOrder = true
9999 duplicatesStrategy = DuplicatesStrategy . INCLUDE // allow duplicates
100100 }
101+ tasks. withType(Test ). configureEach {
102+ // https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:environment
103+ environment ' CI' , ' true'
104+ }
101105}
102106
103107task copyToParent (type : Copy ) {
Original file line number Diff line number Diff line change 11package org .tron .common .setting ;
22
3+ import java .util .Arrays ;
34import lombok .Getter ;
45import lombok .extern .slf4j .Slf4j ;
56import org .rocksdb .BlockBasedTableConfig ;
@@ -44,6 +45,15 @@ public class RocksDbSettings {
4445
4546 private static final LRUCache cache = new LRUCache (1 * 1024 * 1024 * 1024L );
4647
48+ private static final String [] CI_ENVIRONMENT_VARIABLES = {
49+ "CI" ,
50+ "JENKINS_URL" ,
51+ "TRAVIS" ,
52+ "CIRCLECI" ,
53+ "GITHUB_ACTIONS" ,
54+ "GITLAB_CI"
55+ };
56+
4757 private RocksDbSettings () {
4858
4959 }
@@ -185,6 +195,23 @@ public static Options getOptionsByDbName(String dbName) {
185195 options .setComparator (new MarketOrderPriceComparatorForRocksDB (comparatorOptions ));
186196 }
187197
198+ if (isRunningInCI ()) {
199+ // Disable fallocate calls to avoid issues with disk space
200+ options .setAllowFAllocate (false );
201+ // Set WAL size limits to avoid excessive disk
202+ options .setMaxTotalWalSize (2 * 1024 * 1024 );
203+ // Set recycle log file
204+ options .setRecycleLogFileNum (1 );
205+ // Enable creation of missing column families
206+ options .setCreateMissingColumnFamilies (true );
207+ // Set max background flushes to 1 to reduce resource usage
208+ options .setMaxBackgroundFlushes (1 );
209+ }
210+
188211 return options ;
189212 }
213+
214+ private static boolean isRunningInCI () {
215+ return Arrays .stream (CI_ENVIRONMENT_VARIABLES ).anyMatch (System .getenv ()::containsKey );
216+ }
190217}
You can’t perform that action at this time.
0 commit comments