Skip to content

Commit 3920bd6

Browse files
committed
add CI yaml
1 parent 09a1712 commit 3920bd6

File tree

3 files changed

+126
-6
lines changed

3 files changed

+126
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Authorization Integration Test
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the "main" branch
6+
push:
7+
branches: [ "main", "branch-*" ]
8+
pull_request:
9+
branches: [ "main", "branch-*" ]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
changes:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: dorny/paths-filter@v2
21+
id: filter
22+
with:
23+
filters: |
24+
source_changes:
25+
- .github/**
26+
- api/**
27+
- authorizations/**
28+
- bin/**
29+
- catalogs/**
30+
- clients/client-java/**
31+
- clients/client-java-runtime/**
32+
- clients/filesystem-hadoop3/**
33+
- clients/filesystem-hadoop3-runtime/**
34+
- common/**
35+
- conf/**
36+
- core/**
37+
- dev/**
38+
- gradle/**
39+
- integration-test/**
40+
- integration-test-common/**
41+
- iceberg/**
42+
- meta/**
43+
- server/**
44+
- server-common/**
45+
- trino-connector/**
46+
- web/**
47+
- build.gradle.kts
48+
- gradle.properties
49+
- gradlew
50+
- setting.gradle.kts
51+
outputs:
52+
source_changes: ${{ steps.filter.outputs.source_changes }}
53+
54+
test-on-push:
55+
needs: changes
56+
if: (github.event_name == 'push' && needs.changes.outputs.source_changes == 'true')
57+
runs-on: ubuntu-latest
58+
timeout-minutes: 60
59+
strategy:
60+
matrix:
61+
# Integration test for AMD64 architecture
62+
architecture: [linux/amd64]
63+
java-version: [ 8, 11, 17 ]
64+
test-mode: [ embedded, deploy ]
65+
include:
66+
- test-mode: 'embedded'
67+
backend: 'h2'
68+
- test-mode: 'deploy'
69+
backend: 'mysql'
70+
71+
env:
72+
PLATFORM: ${{ matrix.architecture }}
73+
steps:
74+
- uses: actions/checkout@v3
75+
76+
- uses: actions/setup-java@v4
77+
with:
78+
java-version: ${{ matrix.java-version }}
79+
distribution: 'temurin'
80+
cache: 'gradle'
81+
82+
- name: Set up QEMU
83+
uses: docker/setup-qemu-action@v2
84+
85+
- name: Check required command
86+
run: |
87+
dev/ci/check_commands.sh
88+
89+
- name: Package Gravitino
90+
if : ${{ matrix.test-mode == 'deploy' }}
91+
run: |
92+
./gradlew compileDistribution -x test -PjdkVersion=${{ matrix.java-version }}
93+
94+
- name: Free up disk space
95+
run: |
96+
dev/ci/util_free_space.sh
97+
98+
- name: Authorization Integration Test(JDK${{ matrix.java-version }}-${{ matrix.test-mode }}-${{ matrix.backend }})
99+
id: integrationTest
100+
./gradlew -PskipTests -PtestMode=embedded -PjdkVersion=${{ matrix.java-version }} -PskipDockerTests=false :authorizations:authorization-ranger:test --tests "org.apache.gravitino.authorization.ranger.integration.test.**"
101+
./gradlew -PskipTests -PtestMode=deploy -PjdkVersion=${{ matrix.java-version }} -PskipDockerTests=false :authorizations:authorization-ranger:test --tests "org.apache.gravitino.authorization.ranger.integration.test.**"
102+
103+
- name: Upload integrate tests reports
104+
uses: actions/upload-artifact@v3
105+
if: ${{ (failure() && steps.integrationTest.outcome == 'failure') || contains(github.event.pull_request.labels.*.name, 'upload log') }}
106+
with:
107+
name: authorizations-integrate-test-reports-${{ matrix.java-version }}
108+
path: |
109+
build/reports
110+
distribution/package/logs/gravitino-server.out
111+
distribution/package/logs/gravitino-server.log

.github/workflows/backend-integration-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
-x :web:test -x :clients:client-python:test -x :flink-connector:test -x :spark-connector:test -x :spark-connector:spark-common:test
103103
-x :spark-connector:spark-3.3:test -x :spark-connector:spark-3.4:test -x :spark-connector:spark-3.5:test
104104
-x :spark-connector:spark-runtime-3.3:test -x :spark-connector:spark-runtime-3.4:test -x :spark-connector:spark-runtime-3.5:test
105+
-x :authorizations:authorization-ranger:test
105106
106107
- name: Upload integrate tests reports
107108
uses: actions/upload-artifact@v3

authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerITEnv.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,23 @@ public class RangerITEnv {
5454
protected static final String RANGER_HDFS_REPO_NAME = "hdfsDev";
5555
private static final String RANGER_HDFS_TYPE = "hdfs";
5656
protected static RangerClient rangerClient;
57-
57+
private static volatile Boolean initRangerService = Boolean.FALSE;
5858
private static final ContainerSuite containerSuite = ContainerSuite.getInstance();
5959

6060
public static void setup() {
6161
containerSuite.startRangerContainer();
6262
rangerClient = containerSuite.getRangerContainer().rangerClient;
63-
// No IP address set, no impact on testing
64-
createRangerHdfsRepository("", true);
65-
createRangerHiveRepository("", true);
66-
allowAnyoneAccessHDFS();
67-
allowAnyoneAccessInformationSchema();
63+
64+
if (initRangerService.equals(Boolean.FALSE)) {
65+
synchronized (RangerITEnv.class) {
66+
// No IP address set, no impact on testing
67+
createRangerHdfsRepository("", true);
68+
createRangerHiveRepository("", true);
69+
allowAnyoneAccessHDFS();
70+
allowAnyoneAccessInformationSchema();
71+
initRangerService = Boolean.TRUE;
72+
}
73+
}
6874
}
6975

7076
public static void cleanup() {
@@ -91,6 +97,7 @@ static void allowAnyoneAccessHDFS() {
9197
}
9298
} catch (RangerServiceException e) {
9399
// If the policy doesn't exist, we will create it
100+
LOG.warn("Error while fetching policy: {}", e.getMessage());
94101
}
95102

96103
Map<String, RangerPolicy.RangerPolicyResource> policyResourceMap =
@@ -122,6 +129,7 @@ static void allowAnyoneAccessInformationSchema() {
122129
}
123130
} catch (RangerServiceException e) {
124131
// If the policy doesn't exist, we will create it
132+
LOG.warn("Error while fetching policy: {}", e.getMessage());
125133
}
126134

127135
Map<String, RangerPolicy.RangerPolicyResource> policyResourceMap =

0 commit comments

Comments
 (0)