Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-10434: Migrate to Github action #7870

Merged
merged 2 commits into from Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
140 changes: 140 additions & 0 deletions .github/workflows/gradle.yml
@@ -0,0 +1,140 @@
#
# 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 under the License.
#

name: develop

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'liberica'
- name: Run 'build install javadoc spotlessCheck rat checkPom resolveDependencies pmdMain' with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: --console=plain --no-daemon build install javadoc spotlessCheck rat checkPom resolveDependencies pmdMain -x test

apiCheck:
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
distribution: [ 'liberica' ]
java: ['11']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK (include all 3 JDKs in the env)
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.distribution }}
java-version: |
8
11
17
- name: Set JAVA_TEST_PATH to 11
run: |
echo "JAVA_TEST_PATH=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
if: matrix.java == '11'
- name: Java API Check
run: |
GRADLE_JVM_PATH=${JAVA_HOME_8_X64}
JAVA_BUILD_PATH=${JAVA_HOME_8_X64}
JAVA_BUILD_VERSION=8 # Use jdk 8 for build
JAVA_TEST_VERSION=${{ matrix.java }}
cp gradlew gradlewStrict
sed -e 's/JAVA_HOME/GRADLE_JVM/g' -i.back gradlewStrict
GRADLE_JVM=${GRADLE_JVM_PATH} JAVA_TEST_PATH=${JAVA_TEST_PATH} ./gradlewStrict \
-PcompileJVM=${JAVA_BUILD_PATH} \
-PcompileJVMVer=${JAVA_BUILD_VERSION} \
-PtestJVM=${JAVA_TEST_PATH} \
-PtestJVMVer=${JAVA_TEST_VERSION} \
-PtestJava8Home=${JAVA_HOME_8_X64} \
-PtestJava11Home=${JAVA_HOME_11_X64} \
-PtestJava17Home=${JAVA_HOME_17_X64} \
japicmp --console=plain --no-daemon

unitTest:
needs: apiCheck
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
distribution: ['liberica']
java: ['8', '11', '17']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK (include all 3 JDKs in env)
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.distribution }}
java-version: |
8
11
17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Set JAVA_TEST_PATH to 8
run: |
echo "JAVA_TEST_PATH=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
if: matrix.java == '8'
- name: Set JAVA_TEST_PATH to 11
run: |
echo "JAVA_TEST_PATH=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
if: matrix.java == '11'
- name: Set JAVA_TEST_PATH to 17
run: |
echo "JAVA_TEST_PATH=${JAVA_HOME_17_X64}" >> $GITHUB_ENV
if: matrix.java == '17'
- name: Run unit tests
run: |
GRADLE_JVM_PATH=${JAVA_HOME_8_X64}
JAVA_BUILD_PATH=${JAVA_HOME_8_X64}
JAVA_BUILD_VERSION=8 # Use jdk 8 for build
JAVA_TEST_VERSION=${{ matrix.java }}
cp gradlew gradlewStrict
sed -e 's/JAVA_HOME/GRADLE_JVM/g' -i.back gradlewStrict
GRADLE_JVM=${GRADLE_JVM_PATH} JAVA_TEST_PATH=${JAVA_TEST_PATH} ./gradlewStrict \
-PcompileJVM=${JAVA_BUILD_PATH} \
-PcompileJVMVer=${JAVA_BUILD_VERSION} \
-PtestJVM=${JAVA_TEST_PATH} \
-PtestJVMVer=${JAVA_TEST_VERSION} \
-PtestJava8Home=${JAVA_HOME_8_X64} \
-PtestJava11Home=${JAVA_HOME_11_X64} \
-PtestJava17Home=${JAVA_HOME_17_X64} \
test --console=plain --no-daemon
- uses: actions/upload-artifact@v3
if: failure()
with:
name: unit-test-reports-${{ matrix.os }}-${{ matrix.java }}
path: build/reports
retention-days: 5
Expand Up @@ -56,7 +56,7 @@
import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
import org.apache.geode.internal.tcp.ConnectExceptions;

public class DistributionTest {
public class DistributionIntegrationTest {


private DirectChannel dc;
Expand Down
Expand Up @@ -71,6 +71,7 @@
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.TestOnly;

import org.apache.geode.CancelCriterion;
import org.apache.geode.CancelException;
Expand Down Expand Up @@ -198,7 +199,7 @@ public class DiskStoreImpl implements DiskStore {
GeodeGlossary.GEMFIRE_PREFIX + "disk.recoverLruValues";

static final long DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT = 805306368;
static final long DRF_HASHMAP_OVERFLOW_THRESHOLD =
final long DRF_HASHMAP_OVERFLOW_THRESHOLD =
Long.getLong(DRF_HASHMAP_OVERFLOW_THRESHOLD_NAME, DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT);

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

// For testing purposes only.
@VisibleForTesting
OplogEntryIdSet(List<IntOpenHashSet> allInts, List<LongOpenHashSet> allLongs) {
OplogEntryIdSet(List<IntOpenHashSet> allInts, List<LongOpenHashSet> allLongs,
long drfHashMapOverflowThreshold) {
this.allInts = allInts;
currentInts = new AtomicReference<>(this.allInts.get(0));

this.allLongs = allLongs;
currentLongs = new AtomicReference<>(this.allLongs.get(0));
this.drfHashMapOverFlowThreashold = drfHashMapOverflowThreshold;
}

public OplogEntryIdSet() {
@TestOnly
OplogEntryIdSet(List<IntOpenHashSet> allInts, List<LongOpenHashSet> allLongs) {
this(allInts, allLongs, DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT);
}

public OplogEntryIdSet(long drfHashMapOverflowThreshold) {
IntOpenHashSet intHashSet = new IntOpenHashSet((int) INVALID_ID);
allInts = new ArrayList<>();
allInts.add(intHashSet);
Expand All @@ -3553,6 +3562,11 @@ public OplogEntryIdSet() {
allLongs = new ArrayList<>();
allLongs.add(longHashSet);
currentLongs = new AtomicReference<>(longHashSet);
this.drfHashMapOverFlowThreashold = drfHashMapOverflowThreshold;
}

public OplogEntryIdSet() {
this(DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT);
}

public void add(long id) {
Expand Down Expand Up @@ -3580,14 +3594,14 @@ public void add(long id) {

boolean shouldOverflow(final long id) {
if (id > 0 && id <= 0x00000000FFFFFFFFL) {
return currentInts.get().size() == DRF_HASHMAP_OVERFLOW_THRESHOLD;
return currentInts.get().size() == drfHashMapOverFlowThreashold;
} else {
return currentLongs.get().size() == DRF_HASHMAP_OVERFLOW_THRESHOLD;
return currentLongs.get().size() == drfHashMapOverFlowThreashold;
}
}

void overflowToNewHashMap(final long id) {
if (DRF_HASHMAP_OVERFLOW_THRESHOLD == DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT) {
if (drfHashMapOverFlowThreashold == DRF_HASHMAP_OVERFLOW_THRESHOLD_DEFAULT) {
logger.warn(
"There is a large number of deleted entries within the disk-store, please execute an offline compaction.");
}
Expand Down
Expand Up @@ -440,7 +440,7 @@ void recoverRegionsThatAreReady() {
}

private long recoverOplogs(long byteCount) {
OplogEntryIdSet deletedIds = new OplogEntryIdSet();
OplogEntryIdSet deletedIds = new OplogEntryIdSet(parent.DRF_HASHMAP_OVERFLOW_THRESHOLD);
TreeSet<Oplog> oplogSet = getSortedOplogs();

if (!getAlreadyRecoveredOnce().get()) {
Expand Down
Expand Up @@ -55,6 +55,7 @@
import org.apache.commons.validator.routines.InetAddressValidator;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;

import org.apache.geode.CancelException;
import org.apache.geode.SerializationException;
Expand Down Expand Up @@ -552,6 +553,12 @@ int getP2PConnectTimeout(DistributionConfig config) {
return P2P_CONNECT_TIMEOUT;
}

@TestOnly
static void clearP2PConnectTimeout() {
IS_P2P_CONNECT_TIMEOUT_INITIALIZED = false;
P2P_CONNECT_TIMEOUT = 0;
}

/**
* @return true if this thread is a reader thread, otherwise false
*/
Expand Down
@@ -0,0 +1,54 @@
/*
* 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 under
* the License.
*/
package org.apache.geode.internal.cache;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.File;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junitpioneer.jupiter.SetSystemProperty;

import org.apache.geode.Statistics;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.statistics.StatisticsManager;

class DiskStoreImplTest {
@Test
@SetSystemProperty(key = "gemfire.disk.drfHashMapOverflowThreshold", value = "10")
public void testDrfHashMapOverflowThresholdSystemPropertyIsUsed(@TempDir File dir1,
@TempDir File dir2) {
InternalCache cache = mock(InternalCache.class);
InternalDistributedSystem internalDistributedSystem = mock(InternalDistributedSystem.class);
DiskStoreAttributes diskStoreAttributes = mock(DiskStoreAttributes.class);
StatisticsManager statisticsManager = mock(StatisticsManager.class);

when(internalDistributedSystem.getStatisticsManager()).thenReturn(statisticsManager);
when(cache.getInternalDistributedSystem()).thenReturn(internalDistributedSystem);
when(diskStoreAttributes.getDiskDirs()).thenReturn(
new File[] {dir1, dir2});
when(diskStoreAttributes.getDiskDirSizes()).thenReturn(new int[] {1, 1});
when(diskStoreAttributes.getDiskDirSizesUnit()).thenReturn(DiskDirSizesUnit.MEGABYTES);
when(statisticsManager.createStatistics(any(), any())).thenReturn(mock(Statistics.class));

DiskStoreImpl diskStore = new DiskStoreImpl(cache, diskStoreAttributes);

Assertions.assertThat(diskStore.DRF_HASHMAP_OVERFLOW_THRESHOLD).isEqualTo(10);
}
}
Expand Up @@ -25,7 +25,6 @@
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;

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

Expand All @@ -34,9 +33,7 @@
*/
public class OplogEntryIdSetDrfHashSetThresholdTest {
@Test
@SetSystemProperty(key = "gemfire.disk.drfHashMapOverflowThreshold", value = "10")
public void addMethodOverflowBasedOnDrfOverflowThresholdParameters() {

int testEntries = 41;
IntOpenHashSet intOpenHashSet = new IntOpenHashSet();
LongOpenHashSet longOpenHashSet = new LongOpenHashSet();
Expand All @@ -46,7 +43,7 @@ public void addMethodOverflowBasedOnDrfOverflowThresholdParameters() {
List<LongOpenHashSet> longOpenHashSets =
new ArrayList<>(Collections.singletonList(longOpenHashSet));

OplogEntryIdSet oplogEntryIdSet = new OplogEntryIdSet(intOpenHashSets, longOpenHashSets);
OplogEntryIdSet oplogEntryIdSet = new OplogEntryIdSet(intOpenHashSets, longOpenHashSets, 10);
IntStream.range(1, testEntries).forEach(oplogEntryIdSet::add);
LongStream.range(0x00000000FFFFFFFFL + 1, 0x00000000FFFFFFFFL + testEntries)
.forEach(oplogEntryIdSet::add);
Expand Down
Expand Up @@ -35,6 +35,7 @@
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

import org.junit.After;
import org.junit.Test;
import org.junit.experimental.categories.Category;

Expand All @@ -54,6 +55,11 @@
@Category(MembershipTest.class)
public class ConnectionTest {

@After
public void tearDown() {
Connection.clearP2PConnectTimeout();
}

@SuppressWarnings("ConstantConditions")
@Test
public void canBeMocked() throws Exception {
Expand Down
Expand Up @@ -39,6 +39,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import org.junit.After;
import org.junit.Test;
import org.junit.experimental.categories.Category;

Expand All @@ -59,6 +60,11 @@
@Category(MembershipTest.class)
public class ConnectionTransmissionTest {

@After
public void tearDown() {
Connection.clearP2PConnectTimeout();
}

/**
* Create a sender connection and a receiver connection and pass data from
* one to the other.
Expand Down