Skip to content
103 changes: 5 additions & 98 deletions .github/workflows/spanner-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,6 @@ env:
permissions: write-all

jobs:
spotless_check:
name: Spotless
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Spotless
run: |
./cicd/run-spotless \
--modules-to-build="SPANNER"
checkstyle_check:
name: Checkstyle
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Checkstyle
run: |
./cicd/run-checkstyle \
--modules-to-build="SPANNER"
java_build:
name: Build
timeout-minutes: 60
Expand All @@ -98,74 +70,9 @@ jobs:
--modules-to-build="SPANNER"
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
java_unit_tests:
name: Unit Tests
needs: [java_build]
timeout-minutes: 60
runs-on: [self-hosted, it]
steps:
- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Unit Tests
run: |
./cicd/run-unit-tests \
--modules-to-build="SPANNER"
- name: Upload Unit Tests Report
uses: actions/upload-artifact@v4
if: always() # always run even if the previous step fails
with:
name: surefire-unit-test-results
path: |
**/surefire-reports/TEST-*.xml
**/surefire-reports/*.html
**/surefire-reports/html/**
retention-days: 1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5.5.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: GoogleCloudPlatform/DataflowTemplates
files: 'target/site/jacoco-aggregate/jacoco.xml'
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
java_integration_smoke_tests_templates:
name: Dataflow Templates Integration Smoke Tests
needs: [spotless_check, checkstyle_check, java_build, java_unit_tests]
timeout-minutes: 60
# Run on any runner that matches all the specified runs-on values.
runs-on: [self-hosted, it]
steps:
- name: Checkout Code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Integration Smoke Tests
run: |
./cicd/run-it-smoke-tests \
--modules-to-build="SPANNER" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-private-connectivity="datastream-connect-2"
- name: Upload Smoke Tests Report
uses: actions/upload-artifact@v4
if: always() # always run even if the previous step fails
with:
name: surefire-smoke-test-results
path: |
**/surefire-reports/TEST-*.xml
**/surefire-reports/*.html
**/surefire-reports/html/**
retention-days: 1
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
java_integration_tests_templates:
name: Dataflow Templates Integration Tests
needs: [java_integration_smoke_tests_templates]
needs: [java_build]
timeout-minutes: 180
# Run on any runner that matches all the specified runs-on values.
runs-on: [self-hosted, it]
Expand All @@ -178,7 +85,7 @@ jobs:
- name: Run Integration Tests
run: |
./cicd/run-it-tests \
--modules-to-build="SPANNER" \
--it-module="spanner-to-sourcedb" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
Expand All @@ -190,7 +97,7 @@ jobs:
name: surefire-integration-test-results
path: |
**/surefire-reports/TEST-*.xml
**/surefire-reports/*.html
**/surere-reports/*.html
**/surefire-reports/html/**
retention-days: 10
- name: Integration Test report on GitHub
Expand All @@ -210,7 +117,7 @@ jobs:
java_load_tests_templates:
if: contains(github.event.pull_request.labels.*.name, 'run-load-tests')
name: Dataflow Templates Load Tests
needs: [spotless_check, checkstyle_check, java_build, java_unit_tests, java_integration_tests_templates]
needs: [java_build, java_integration_tests_templates]
timeout-minutes: 600
# Run on any runner that matches all the specified runs-on values.
runs-on: [self-hosted, perf]
Expand All @@ -229,4 +136,4 @@ jobs:
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-private-connectivity="datastream-connect-2"
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
uses: ./.github/actions/cleanup-java-env
8 changes: 8 additions & 0 deletions cicd/cmd/run-it-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ import (
func main() {
flags.RegisterCommonFlags()
flags.RegisterItFlags()

var itModule string
flag.StringVar(&itModule, "it-module", "", "(optional) The single module to run integration tests for")

flag.Parse()

if itModule != "" {
flags.SetModulesToBuild(itModule)
}

// Run mvn install before running integration tests
mvnFlags := workflows.NewMavenFlags()
err := workflows.MvnCleanInstall().Run(
Expand Down
Binary file added cicd/cmd/run-it-tests/run-it-tests
Binary file not shown.
17 changes: 17 additions & 0 deletions cicd/internal/flags/common-flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,33 @@ var (
"v2/datastream-to-sql/",
},
}

// New map for short name to full path mapping
shortNameToFullPathMap = map[string]string{
"spanner-to-sourcedb": "v2/spanner-to-sourcedb/",
// Add other mappings as needed
}
)

// Registers all common flags. Must be called before flag.Parse().
func RegisterCommonFlags() {
flag.StringVar(&modulesToBuild, "modules-to-build", ALL, "List of modules to build/run commands against")
}

// SetModulesToBuild allows setting the modules to build programmatically.
func SetModulesToBuild(module string) {
modulesToBuild = module
}

// Returns all modules to build.
func ModulesToBuild() []string {
m := modulesToBuild

// Check if the module is a short name
if fullPath, ok := shortNameToFullPathMap[m]; ok {
return []string{fullPath}
}

if m == "DEFAULT" {
// "DEFAULT" is "ALL" minus other modules defined in moduleMap
var s []string
Expand Down
Binary file added cicd/run-it-tests
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.apache.beam.sdk.io.gcp.spanner.SpannerConfig;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -158,7 +157,7 @@ public static void cleanUp() throws IOException {
}

@Test
@Ignore("Skipping spannerToSourceDbBasic test")
// @Ignore("Skipping spannerToSourceDbBasic test")
public void spannerToSourceDbBasic() throws InterruptedException, IOException {
assertThatPipeline(jobInfo).isRunning();
// Write row in Spanner
Expand Down Expand Up @@ -217,12 +216,20 @@ private void assertRowInMySQL() throws InterruptedException {
pipelineOperator()
.waitForCondition(
createConfig(jobInfo, TEST_TIMEOUT),
() -> jdbcResourceManager.getRowCount(TABLE) == 1); // only one row is inserted
() -> {
long rowCount = jdbcResourceManager.getRowCount(TABLE);
LOG.info("Current row count for table {}: {}", TABLE, rowCount);
return rowCount == 1;
}); // only one row is inserted
assertThatResult(result).meetsConditions();
List<Map<String, Object>> rows = jdbcResourceManager.readTable(TABLE);
LOG.info("Retrieved rows from MySQL for table {}: {}", TABLE, rows);
assertThat(rows).hasSize(1);
LOG.info("id is : {}", rows.get(0).get("id"));
assertThat(rows.get(0).get("id")).isEqualTo(1);
LOG.info("name is : {}", rows.get(0).get("name"));
assertThat(rows.get(0).get("name")).isEqualTo("FF");
LOG.info("from is : {}", rows.get(0).get("from"));
assertThat(rows.get(0).get("from")).isEqualTo("AA");
}

Expand Down
Loading