Skip to content

Commit af430d3

Browse files
authored
GEODE-10434: Migrate to Github action (#7870)
* GEODE-10434: Migrate to Github Action * Added a build step for java 8 on ubuntu * Added a unit-test step for ubuntu that runs - using JDK 8 for build and tests using 8, 11 and 17 * Added apiCheck step
1 parent 018f2b4 commit af430d3

9 files changed

Lines changed: 236 additions & 12 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: develop
19+
20+
on:
21+
push:
22+
branches: [ "develop" ]
23+
pull_request:
24+
branches: [ "develop" ]
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
build:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v3
34+
- name: Set up JDK 8
35+
uses: actions/setup-java@v3
36+
with:
37+
java-version: '8'
38+
distribution: 'liberica'
39+
- name: Run 'build install javadoc spotlessCheck rat checkPom resolveDependencies pmdMain' with Gradle
40+
uses: gradle/gradle-build-action@v2
41+
with:
42+
arguments: --console=plain --no-daemon build install javadoc spotlessCheck rat checkPom resolveDependencies pmdMain -x test
43+
44+
apiCheck:
45+
needs: build
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os: [ubuntu-latest]
50+
distribution: [ 'liberica' ]
51+
java: ['11']
52+
runs-on: ${{ matrix.os }}
53+
steps:
54+
- uses: actions/checkout@v3
55+
- name: Set up JDK (include all 3 JDKs in the env)
56+
uses: actions/setup-java@v3
57+
with:
58+
distribution: ${{ matrix.distribution }}
59+
java-version: |
60+
8
61+
11
62+
17
63+
- name: Set JAVA_TEST_PATH to 11
64+
run: |
65+
echo "JAVA_TEST_PATH=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
66+
if: matrix.java == '11'
67+
- name: Java API Check
68+
run: |
69+
GRADLE_JVM_PATH=${JAVA_HOME_8_X64}
70+
JAVA_BUILD_PATH=${JAVA_HOME_8_X64}
71+
JAVA_BUILD_VERSION=8 # Use jdk 8 for build
72+
JAVA_TEST_VERSION=${{ matrix.java }}
73+
cp gradlew gradlewStrict
74+
sed -e 's/JAVA_HOME/GRADLE_JVM/g' -i.back gradlewStrict
75+
GRADLE_JVM=${GRADLE_JVM_PATH} JAVA_TEST_PATH=${JAVA_TEST_PATH} ./gradlewStrict \
76+
-PcompileJVM=${JAVA_BUILD_PATH} \
77+
-PcompileJVMVer=${JAVA_BUILD_VERSION} \
78+
-PtestJVM=${JAVA_TEST_PATH} \
79+
-PtestJVMVer=${JAVA_TEST_VERSION} \
80+
-PtestJava8Home=${JAVA_HOME_8_X64} \
81+
-PtestJava11Home=${JAVA_HOME_11_X64} \
82+
-PtestJava17Home=${JAVA_HOME_17_X64} \
83+
japicmp --console=plain --no-daemon
84+
85+
unitTest:
86+
needs: apiCheck
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
os: [ubuntu-latest]
91+
distribution: ['liberica']
92+
java: ['8', '11', '17']
93+
runs-on: ${{ matrix.os }}
94+
steps:
95+
- uses: actions/checkout@v3
96+
- name: Set up JDK (include all 3 JDKs in env)
97+
uses: actions/setup-java@v3
98+
with:
99+
distribution: ${{ matrix.distribution }}
100+
java-version: |
101+
8
102+
11
103+
17
104+
- name: Setup Gradle
105+
uses: gradle/gradle-build-action@v2
106+
- name: Set JAVA_TEST_PATH to 8
107+
run: |
108+
echo "JAVA_TEST_PATH=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
109+
if: matrix.java == '8'
110+
- name: Set JAVA_TEST_PATH to 11
111+
run: |
112+
echo "JAVA_TEST_PATH=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
113+
if: matrix.java == '11'
114+
- name: Set JAVA_TEST_PATH to 17
115+
run: |
116+
echo "JAVA_TEST_PATH=${JAVA_HOME_17_X64}" >> $GITHUB_ENV
117+
if: matrix.java == '17'
118+
- name: Run unit tests
119+
run: |
120+
GRADLE_JVM_PATH=${JAVA_HOME_8_X64}
121+
JAVA_BUILD_PATH=${JAVA_HOME_8_X64}
122+
JAVA_BUILD_VERSION=8 # Use jdk 8 for build
123+
JAVA_TEST_VERSION=${{ matrix.java }}
124+
cp gradlew gradlewStrict
125+
sed -e 's/JAVA_HOME/GRADLE_JVM/g' -i.back gradlewStrict
126+
GRADLE_JVM=${GRADLE_JVM_PATH} JAVA_TEST_PATH=${JAVA_TEST_PATH} ./gradlewStrict \
127+
-PcompileJVM=${JAVA_BUILD_PATH} \
128+
-PcompileJVMVer=${JAVA_BUILD_VERSION} \
129+
-PtestJVM=${JAVA_TEST_PATH} \
130+
-PtestJVMVer=${JAVA_TEST_VERSION} \
131+
-PtestJava8Home=${JAVA_HOME_8_X64} \
132+
-PtestJava11Home=${JAVA_HOME_11_X64} \
133+
-PtestJava17Home=${JAVA_HOME_17_X64} \
134+
test --console=plain --no-daemon
135+
- uses: actions/upload-artifact@v3
136+
if: failure()
137+
with:
138+
name: unit-test-reports-${{ matrix.os }}-${{ matrix.java }}
139+
path: build/reports
140+
retention-days: 5

geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionTest.java renamed to geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/DistributionIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
5757
import org.apache.geode.internal.tcp.ConnectExceptions;
5858

59-
public class DistributionTest {
59+
public class DistributionIntegrationTest {
6060

6161

6262
private DirectChannel dc;

geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
7272
import org.apache.commons.io.FileUtils;
7373
import org.apache.logging.log4j.Logger;
74+
import org.jetbrains.annotations.TestOnly;
7475

7576
import org.apache.geode.CancelCriterion;
7677
import org.apache.geode.CancelException;
@@ -198,7 +199,7 @@ public class DiskStoreImpl implements DiskStore {
198199
GeodeGlossary.GEMFIRE_PREFIX + "disk.recoverLruValues";
199200

200201
static final long DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT = 805306368;
201-
static final long DRF_HASHMAP_OVERFLOW_THRESHOLD =
202+
final long DRF_HASHMAP_OVERFLOW_THRESHOLD =
202203
Long.getLong(DRF_HASHMAP_OVERFLOW_THRESHOLD_NAME, DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT);
203204

204205
boolean RECOVER_VALUES = getBoolean(DiskStoreImpl.RECOVER_VALUE_PROPERTY_NAME, true);
@@ -3532,18 +3533,26 @@ static class OplogEntryIdSet {
35323533
private final List<LongOpenHashSet> allLongs;
35333534
private final AtomicReference<IntOpenHashSet> currentInts;
35343535
private final AtomicReference<LongOpenHashSet> currentLongs;
3536+
private final long drfHashMapOverFlowThreashold;
35353537

35363538
// For testing purposes only.
35373539
@VisibleForTesting
3538-
OplogEntryIdSet(List<IntOpenHashSet> allInts, List<LongOpenHashSet> allLongs) {
3540+
OplogEntryIdSet(List<IntOpenHashSet> allInts, List<LongOpenHashSet> allLongs,
3541+
long drfHashMapOverflowThreshold) {
35393542
this.allInts = allInts;
35403543
currentInts = new AtomicReference<>(this.allInts.get(0));
35413544

35423545
this.allLongs = allLongs;
35433546
currentLongs = new AtomicReference<>(this.allLongs.get(0));
3547+
this.drfHashMapOverFlowThreashold = drfHashMapOverflowThreshold;
35443548
}
35453549

3546-
public OplogEntryIdSet() {
3550+
@TestOnly
3551+
OplogEntryIdSet(List<IntOpenHashSet> allInts, List<LongOpenHashSet> allLongs) {
3552+
this(allInts, allLongs, DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT);
3553+
}
3554+
3555+
public OplogEntryIdSet(long drfHashMapOverflowThreshold) {
35473556
IntOpenHashSet intHashSet = new IntOpenHashSet((int) INVALID_ID);
35483557
allInts = new ArrayList<>();
35493558
allInts.add(intHashSet);
@@ -3553,6 +3562,11 @@ public OplogEntryIdSet() {
35533562
allLongs = new ArrayList<>();
35543563
allLongs.add(longHashSet);
35553564
currentLongs = new AtomicReference<>(longHashSet);
3565+
this.drfHashMapOverFlowThreashold = drfHashMapOverflowThreshold;
3566+
}
3567+
3568+
public OplogEntryIdSet() {
3569+
this(DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT);
35563570
}
35573571

35583572
public void add(long id) {
@@ -3580,14 +3594,14 @@ public void add(long id) {
35803594

35813595
boolean shouldOverflow(final long id) {
35823596
if (id > 0 && id <= 0x00000000FFFFFFFFL) {
3583-
return currentInts.get().size() == DRF_HASHMAP_OVERFLOW_THRESHOLD;
3597+
return currentInts.get().size() == drfHashMapOverFlowThreashold;
35843598
} else {
3585-
return currentLongs.get().size() == DRF_HASHMAP_OVERFLOW_THRESHOLD;
3599+
return currentLongs.get().size() == drfHashMapOverFlowThreashold;
35863600
}
35873601
}
35883602

35893603
void overflowToNewHashMap(final long id) {
3590-
if (DRF_HASHMAP_OVERFLOW_THRESHOLD == DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT) {
3604+
if (drfHashMapOverFlowThreashold == DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT) {
35913605
logger.warn(
35923606
"There is a large number of deleted entries within the disk-store, please execute an offline compaction.");
35933607
}

geode-core/src/main/java/org/apache/geode/internal/cache/PersistentOplogSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void recoverRegionsThatAreReady() {
440440
}
441441

442442
private long recoverOplogs(long byteCount) {
443-
OplogEntryIdSet deletedIds = new OplogEntryIdSet();
443+
OplogEntryIdSet deletedIds = new OplogEntryIdSet(parent.DRF_HASHMAP_OVERFLOW_THRESHOLD);
444444
TreeSet<Oplog> oplogSet = getSortedOplogs();
445445

446446
if (!getAlreadyRecoveredOnce().get()) {

geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.apache.commons.validator.routines.InetAddressValidator;
5656
import org.apache.logging.log4j.Logger;
5757
import org.jetbrains.annotations.NotNull;
58+
import org.jetbrains.annotations.TestOnly;
5859

5960
import org.apache.geode.CancelException;
6061
import org.apache.geode.SerializationException;
@@ -552,6 +553,12 @@ int getP2PConnectTimeout(DistributionConfig config) {
552553
return P2P_CONNECT_TIMEOUT;
553554
}
554555

556+
@TestOnly
557+
static void clearP2PConnectTimeout() {
558+
IS_P2P_CONNECT_TIMEOUT_INITIALIZED = false;
559+
P2P_CONNECT_TIMEOUT = 0;
560+
}
561+
555562
/**
556563
* @return true if this thread is a reader thread, otherwise false
557564
*/
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for additional information regarding
4+
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
5+
* "License"); you may not use this file except in compliance with the License. You may obtain a
6+
* copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software distributed under the License
11+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
* or implied. See the License for the specific language governing permissions and limitations under
13+
* the License.
14+
*/
15+
package org.apache.geode.internal.cache;
16+
17+
import static org.mockito.ArgumentMatchers.any;
18+
import static org.mockito.Mockito.mock;
19+
import static org.mockito.Mockito.when;
20+
21+
import java.io.File;
22+
23+
import org.assertj.core.api.Assertions;
24+
import org.junit.jupiter.api.Test;
25+
import org.junit.jupiter.api.io.TempDir;
26+
import org.junitpioneer.jupiter.SetSystemProperty;
27+
28+
import org.apache.geode.Statistics;
29+
import org.apache.geode.distributed.internal.InternalDistributedSystem;
30+
import org.apache.geode.internal.statistics.StatisticsManager;
31+
32+
class DiskStoreImplTest {
33+
@Test
34+
@SetSystemProperty(key = "gemfire.disk.drfHashMapOverflowThreshold", value = "10")
35+
public void testDrfHashMapOverflowThresholdSystemPropertyIsUsed(@TempDir File dir1,
36+
@TempDir File dir2) {
37+
InternalCache cache = mock(InternalCache.class);
38+
InternalDistributedSystem internalDistributedSystem = mock(InternalDistributedSystem.class);
39+
DiskStoreAttributes diskStoreAttributes = mock(DiskStoreAttributes.class);
40+
StatisticsManager statisticsManager = mock(StatisticsManager.class);
41+
42+
when(internalDistributedSystem.getStatisticsManager()).thenReturn(statisticsManager);
43+
when(cache.getInternalDistributedSystem()).thenReturn(internalDistributedSystem);
44+
when(diskStoreAttributes.getDiskDirs()).thenReturn(
45+
new File[] {dir1, dir2});
46+
when(diskStoreAttributes.getDiskDirSizes()).thenReturn(new int[] {1, 1});
47+
when(diskStoreAttributes.getDiskDirSizesUnit()).thenReturn(DiskDirSizesUnit.MEGABYTES);
48+
when(statisticsManager.createStatistics(any(), any())).thenReturn(mock(Statistics.class));
49+
50+
DiskStoreImpl diskStore = new DiskStoreImpl(cache, diskStoreAttributes);
51+
52+
Assertions.assertThat(diskStore.DRF_HASHMAP_OVERFLOW_THRESHOLD).isEqualTo(10);
53+
}
54+
}

geode-core/src/test/java/org/apache/geode/internal/cache/OplogEntryIdSetDrfHashSetThresholdTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
2626
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
2727
import org.junit.jupiter.api.Test;
28-
import org.junitpioneer.jupiter.SetSystemProperty;
2928

3029
import org.apache.geode.internal.cache.DiskStoreImpl.OplogEntryIdSet;
3130

@@ -34,9 +33,7 @@
3433
*/
3534
public class OplogEntryIdSetDrfHashSetThresholdTest {
3635
@Test
37-
@SetSystemProperty(key = "gemfire.disk.drfHashMapOverflowThreshold", value = "10")
3836
public void addMethodOverflowBasedOnDrfOverflowThresholdParameters() {
39-
4037
int testEntries = 41;
4138
IntOpenHashSet intOpenHashSet = new IntOpenHashSet();
4239
LongOpenHashSet longOpenHashSet = new LongOpenHashSet();
@@ -46,7 +43,7 @@ public void addMethodOverflowBasedOnDrfOverflowThresholdParameters() {
4643
List<LongOpenHashSet> longOpenHashSets =
4744
new ArrayList<>(Collections.singletonList(longOpenHashSet));
4845

49-
OplogEntryIdSet oplogEntryIdSet = new OplogEntryIdSet(intOpenHashSets, longOpenHashSets);
46+
OplogEntryIdSet oplogEntryIdSet = new OplogEntryIdSet(intOpenHashSets, longOpenHashSets, 10);
5047
IntStream.range(1, testEntries).forEach(oplogEntryIdSet::add);
5148
LongStream.range(0x00000000FFFFFFFFL + 1, 0x00000000FFFFFFFFL + testEntries)
5249
.forEach(oplogEntryIdSet::add);

geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.nio.ByteBuffer;
3636
import java.nio.channels.SocketChannel;
3737

38+
import org.junit.After;
3839
import org.junit.Test;
3940
import org.junit.experimental.categories.Category;
4041

@@ -54,6 +55,11 @@
5455
@Category(MembershipTest.class)
5556
public class ConnectionTest {
5657

58+
@After
59+
public void tearDown() {
60+
Connection.clearP2PConnectTimeout();
61+
}
62+
5763
@SuppressWarnings("ConstantConditions")
5864
@Test
5965
public void canBeMocked() throws Exception {

geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTransmissionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.concurrent.CompletableFuture;
4040
import java.util.concurrent.ExecutionException;
4141

42+
import org.junit.After;
4243
import org.junit.Test;
4344
import org.junit.experimental.categories.Category;
4445

@@ -59,6 +60,11 @@
5960
@Category(MembershipTest.class)
6061
public class ConnectionTransmissionTest {
6162

63+
@After
64+
public void tearDown() {
65+
Connection.clearP2PConnectTimeout();
66+
}
67+
6268
/**
6369
* Create a sender connection and a receiver connection and pass data from
6470
* one to the other.

0 commit comments

Comments
 (0)