Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
fail-fast: false
matrix:
# Define the number of shards (1-based indexing)
shard_index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
total_shards: [15]
shard_index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
total_shards: [20]

env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
Expand Down
68 changes: 32 additions & 36 deletions .github/workflows/build-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ permissions:

jobs:
test:
name: MariaDB Tests (Shard ${{ matrix.shard_index }} of ${{ matrix.total_shards }})
runs-on: ubuntu-24.04
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
task: [test-core-1, test-core-2, test-core-3, test-core-4, test-core-5]
# Define the number of shards (1-based indexing)
shard_index: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
total_shards: [ 15 ]

services:
mariadb:
Expand Down Expand Up @@ -86,47 +89,40 @@ jobs:
sleep 10
docker exec localstack awslocal s3api create-bucket --bucket fineract-reports

- name: Generate test class list (only for test-core-X)
if: startsWith(matrix.task, 'test-core-')
- name: Generate test class list
run: |
chmod +x scripts/split-tests.sh
SHARD_INDEX=$(echo "${{ matrix.task }}" | awk -F'-' '{print $3}')
./scripts/split-tests.sh 5 $SHARD_INDEX
cat "shard-tests_${SHARD_INDEX}.txt"
./scripts/split-tests.sh ${{ matrix.total_shards }} ${{ matrix.shard_index }}
cat "shard-tests_${{ matrix.shard_index }}.txt"

- name: Run Gradle Task
run: |
set -e # Fail the script if any command fails
SHARD_INDEX=$(echo "${{ matrix.task }}" | awk -F'-' '{print $3}')
FAILED=0

case "${{ matrix.task }}" in
test-core-*)
echo "Grouping test classes by module..."
declare -A module_tests

while IFS=, read -r module class; do
module_tests["$module"]+="$class "
done < "shard-tests_${SHARD_INDEX}.txt"

for module in "${!module_tests[@]}"; do
echo "::group::Running tests in $module"
for class in ${module_tests[$module]}; do
echo " - $class"
done

# Build test args
test_args=$(for class in ${module_tests[$module]}; do echo --tests "$class"; done | xargs)

# Run test task for this module
if ! ./gradlew --no-daemon "$module:test" $test_args -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x spotlessCheck -x spotlessApply -x spotbugsMain -x spotbugsTest -x javadoc -x javadocJar -x modernizer -x buildJavaSdk ; then
echo "::error::Tests failed in module $module"
FAILED=1
fi
echo "::endgroup::"
done
;;
esac
echo "Grouping test classes by module..."
declare -A module_tests

while IFS=, read -r module class; do
module_tests["$module"]+="$class "
done < "shard-tests_${{ matrix.shard_index }}.txt"

for module in "${!module_tests[@]}"; do
echo "::group::Running tests in $module"
for class in ${module_tests[$module]}; do
echo " - $class"
done

# Build test args
test_args=$(for class in ${module_tests[$module]}; do echo --tests "$class"; done | xargs)

# Run test task for this module
if ! ./gradlew --no-daemon "$module:test" $test_args -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x spotlessCheck -x spotlessApply -x spotbugsMain -x spotbugsTest -x javadoc -x javadocJar -x modernizer -x buildJavaSdk ; then
echo "::error::Tests failed in module $module"
FAILED=1
fi
echo "::endgroup::"
done

# Exit with failure status if any test failed
if [ "$FAILED" -eq 1 ]; then
Expand All @@ -138,14 +134,14 @@ jobs:
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-results-mariadb-${{ matrix.task }}-attempt-${{ github.run_attempt }}
name: test-results-mariadb-shard-${{ matrix.shard_index }}-attempt-${{ github.run_attempt }}
path: '**/build/reports/'
retention-days: 5

- name: Archive server logs
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: server-logs-mariadb-${{ matrix.task }}-attempt-${{ github.run_attempt }}
name: server-logs-mariadb-shard-${{ matrix.shard_index }}-attempt-${{ github.run_attempt }}
path: '**/build/cargo/'
retention-days: 5
68 changes: 32 additions & 36 deletions .github/workflows/build-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ permissions:

jobs:
test:
name: MySQL Tests (Shard ${{ matrix.shard_index }} of ${{ matrix.total_shards }})
runs-on: ubuntu-24.04
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
task: [test-core-1, test-core-2, test-core-3, test-core-4, test-core-5]
# Define the number of shards (1-based indexing)
shard_index: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
total_shards: [ 15 ]

services:
mysql:
Expand Down Expand Up @@ -81,47 +84,40 @@ jobs:
sleep 10
docker exec localstack awslocal s3api create-bucket --bucket fineract-reports

- name: Generate test class list (only for test-core-X)
if: startsWith(matrix.task, 'test-core-')
- name: Generate test class list
run: |
chmod +x scripts/split-tests.sh
SHARD_INDEX=$(echo "${{ matrix.task }}" | awk -F'-' '{print $3}')
./scripts/split-tests.sh 5 $SHARD_INDEX
cat "shard-tests_${SHARD_INDEX}.txt"
./scripts/split-tests.sh ${{ matrix.total_shards }} ${{ matrix.shard_index }}
cat "shard-tests_${{ matrix.shard_index }}.txt"

- name: Run Gradle Task
run: |
set -e # Fail the script if any command fails
SHARD_INDEX=$(echo "${{ matrix.task }}" | awk -F'-' '{print $3}')
FAILED=0

case "${{ matrix.task }}" in
test-core-*)
echo "Grouping test classes by module..."
declare -A module_tests

while IFS=, read -r module class; do
module_tests["$module"]+="$class "
done < "shard-tests_${SHARD_INDEX}.txt"

for module in "${!module_tests[@]}"; do
echo "::group::Running tests in $module"
for class in ${module_tests[$module]}; do
echo " - $class"
done

# Build test args
test_args=$(for class in ${module_tests[$module]}; do echo --tests "$class"; done | xargs)

# Run test task for this module
if ! ./gradlew --no-daemon "$module:test" $test_args -PdbType=mysql -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x spotlessCheck -x spotlessApply -x spotbugsMain -x spotbugsTest -x javadoc -x javadocJar -x modernizer -x buildJavaSdk ; then
echo "::error::Tests failed in module $module"
FAILED=1
fi
echo "::endgroup::"
done
;;
esac
echo "Grouping test classes by module..."
declare -A module_tests

while IFS=, read -r module class; do
module_tests["$module"]+="$class "
done < "shard-tests_${{ matrix.shard_index }}.txt"

for module in "${!module_tests[@]}"; do
echo "::group::Running tests in $module"
for class in ${module_tests[$module]}; do
echo " - $class"
done

# Build test args
test_args=$(for class in ${module_tests[$module]}; do echo --tests "$class"; done | xargs)

# Run test task for this module
if ! ./gradlew --no-daemon "$module:test" $test_args -PdbType=mysql -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x spotlessCheck -x spotlessApply -x spotbugsMain -x spotbugsTest -x javadoc -x javadocJar -x modernizer -x buildJavaSdk ; then
echo "::error::Tests failed in module $module"
FAILED=1
fi
echo "::endgroup::"
done

# Exit with failure status if any test failed
if [ "$FAILED" -eq 1 ]; then
Expand All @@ -133,14 +129,14 @@ jobs:
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-results-mysql-${{ matrix.task }}-attempt-${{ github.run_attempt }}
name: test-results-mysql-shard-${{ matrix.shard_index }}-attempt-${{ github.run_attempt }}
path: '**/build/reports/'
retention-days: 5

- name: Archive server logs
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: server-logs-mysql-${{ matrix.task }}-attempt-${{ github.run_attempt }}
name: server-logs-mysql-shard-${{ matrix.shard_index }}-attempt-${{ github.run_attempt }}
path: '**/build/cargo/'
retention-days: 5
68 changes: 32 additions & 36 deletions .github/workflows/build-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ permissions:

jobs:
test:
name: PostgreSQL Tests (Shard ${{ matrix.shard_index }} of ${{ matrix.total_shards }})
runs-on: ubuntu-24.04
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
task: [test-core-1, test-core-2, test-core-3, test-core-4, test-core-5]
# Define the number of shards (1-based indexing)
shard_index: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
total_shards: [ 15 ]

services:
postgresql:
Expand Down Expand Up @@ -82,47 +85,40 @@ jobs:
sleep 10
docker exec localstack awslocal s3api create-bucket --bucket fineract-reports

- name: Generate test class list (only for test-core-X)
if: startsWith(matrix.task, 'test-core-')
- name: Generate test class list
run: |
chmod +x scripts/split-tests.sh
SHARD_INDEX=$(echo "${{ matrix.task }}" | awk -F'-' '{print $3}')
./scripts/split-tests.sh 5 $SHARD_INDEX
cat "shard-tests_${SHARD_INDEX}.txt"
./scripts/split-tests.sh ${{ matrix.total_shards }} ${{ matrix.shard_index }}
cat "shard-tests_${{ matrix.shard_index }}.txt"

- name: Run Gradle Task
run: |
set -e # Fail the script if any command fails
SHARD_INDEX=$(echo "${{ matrix.task }}" | awk -F'-' '{print $3}')
FAILED=0

case "${{ matrix.task }}" in
test-core-*)
echo "Grouping test classes by module..."
declare -A module_tests

while IFS=, read -r module class; do
module_tests["$module"]+="$class "
done < "shard-tests_${SHARD_INDEX}.txt"

for module in "${!module_tests[@]}"; do
echo "::group::Running tests in $module"
for class in ${module_tests[$module]}; do
echo " - $class"
done

# Build test args
test_args=$(for class in ${module_tests[$module]}; do echo --tests "$class"; done | xargs)

# Run test task for this module
if ! ./gradlew --no-daemon "$module:test" $test_args -PdbType=postgresql -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x spotlessCheck -x spotlessApply -x spotbugsMain -x spotbugsTest -x javadoc -x javadocJar -x modernizer -x buildJavaSdk ; then
echo "::error::Tests failed in module $module"
FAILED=1
fi
echo "::endgroup::"
done
;;
esac
echo "Grouping test classes by module..."
declare -A module_tests

while IFS=, read -r module class; do
module_tests["$module"]+="$class "
done < "shard-tests_${{ matrix.shard_index }}.txt"

for module in "${!module_tests[@]}"; do
echo "::group::Running tests in $module"
for class in ${module_tests[$module]}; do
echo " - $class"
done

# Build test args
test_args=$(for class in ${module_tests[$module]}; do echo --tests "$class"; done | xargs)

# Run test task for this module
if ! ./gradlew --no-daemon "$module:test" $test_args -PdbType=postgresql -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x spotlessCheck -x spotlessApply -x spotbugsMain -x spotbugsTest -x javadoc -x javadocJar -x modernizer -x buildJavaSdk ; then
echo "::error::Tests failed in module $module"
FAILED=1
fi
echo "::endgroup::"
done

# Exit with failure status if any test failed
if [ "$FAILED" -eq 1 ]; then
Expand All @@ -134,14 +130,14 @@ jobs:
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-results-postgresql-${{ matrix.task }}-attempt-${{ github.run_attempt }}
name: test-results-postgresql-shard-${{ matrix.shard_index }}-attempt-${{ github.run_attempt }}
path: '**/build/reports/'
retention-days: 5

- name: Archive server logs
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: server-logs-postgresql-${{ matrix.task }}-attempt-${{ github.run_attempt }}
name: server-logs-postgresql-shard-${{ matrix.shard_index }}-attempt-${{ github.run_attempt }}
path: '**/build/cargo/'
retention-days: 5
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.client.models.AllowAttributeOverrides;
import org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappings;
Expand Down Expand Up @@ -72,7 +72,7 @@ public class LoanProductsRequestFactory {
private final CodeValueResolver codeValueResolver;
private final DelinquencyBucketResolver delinquencyBucketResolver;

private final Set<String> productShortNameMap = new HashSet<>();
private final Set<String> productShortNameMap = ConcurrentHashMap.newKeySet();

@Autowired
private CodeHelper codeHelper;
Expand Down Expand Up @@ -1903,16 +1903,12 @@ public PostLoanProductsRequest defaultLoanProductsRequestLP2EmiUSD() {
}

public String generateShortNameSafely() {
String generatedShortName;
int counter = 0;
do {
counter++;
generatedShortName = Utils.randomStringGenerator("", 4);
if (counter > 999) {
throw new RuntimeException("Unable to generate unique short name");
for (int counter = 0; counter < 999; counter++) {
String generatedShortName = Utils.randomStringGenerator("", 4);
if (productShortNameMap.add(generatedShortName)) {
return generatedShortName;
}
} while (productShortNameMap.contains(generatedShortName));
productShortNameMap.add(generatedShortName);
return generatedShortName;
}
throw new RuntimeException("Unable to generate unique short name");
}
}
Loading