Skip to content

Commit

Permalink
Add datastream to sql IT's
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Kinard <[email protected]>
  • Loading branch information
Polber committed Jul 3, 2024
1 parent 0bcf179 commit 7e440c4
Show file tree
Hide file tree
Showing 11 changed files with 820 additions and 39 deletions.
6 changes: 4 additions & 2 deletions cicd/cmd/run-it-smoke-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ func main() {
flags.SpannerHost(),
flags.FailureMode(),
flags.RetryFailures(),
flags.StaticOracleInstance(),
flags.StaticOracleHost(),
flags.StaticOracleSysPassword(),
flags.CloudProxyHost(),
flags.CloudProxyPort(),
flags.CloudProxyMySqlPort(),
flags.CloudProxyPostgresPort(),
flags.CloudProxyPassword())
if err != nil {
log.Fatalf("%v\n", err)
Expand Down
6 changes: 4 additions & 2 deletions cicd/cmd/run-it-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ func main() {
flags.SpannerHost(),
flags.FailureMode(),
flags.RetryFailures(),
flags.StaticOracleInstance(),
flags.StaticOracleHost(),
flags.StaticOracleSysPassword(),
flags.CloudProxyHost(),
flags.CloudProxyPort(),
flags.CloudProxyMySqlPort(),
flags.CloudProxyPostgresPort(),
flags.CloudProxyPassword())
if err != nil {
log.Fatalf("%v\n", err)
Expand Down
6 changes: 4 additions & 2 deletions cicd/cmd/run-load-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ func main() {
flags.ExportProject(),
flags.ExportDataset(),
flags.ExportTable(),
flags.StaticOracleInstance(),
flags.StaticOracleHost(),
flags.StaticOracleSysPassword(),
flags.CloudProxyHost(),
flags.CloudProxyPort(),
flags.CloudProxyMySqlPort(),
flags.CloudProxyPostgresPort(),
flags.CloudProxyPassword())
if err != nil {
log.Fatalf("%v\n", err)
Expand Down
50 changes: 31 additions & 19 deletions cicd/internal/flags/it-flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ import (

// Avoid making these vars public.
var (
dRegion string
dProject string
dArtifactBucket string
dStageBucket string
dHostIp string
dPrivateConnectivity string
dSpannerHost string
dReleaseMode bool
dRetryFailures string
dCloudProxyHost string
dCloudProxyPort string
dCloudProxyPassword string
dOracleInstance string
dRegion string
dProject string
dArtifactBucket string
dStageBucket string
dHostIp string
dPrivateConnectivity string
dSpannerHost string
dReleaseMode bool
dRetryFailures string
dCloudProxyHost string
dCloudProxyMySqlPort string
dCloudProxyPostgresPort string
dCloudProxyPassword string
dOracleHost string
dCloudOracleSysPassword string
)

// Registers all common flags. Must be called before flag.Parse().
Expand All @@ -51,9 +53,11 @@ func RegisterItFlags() {
flag.BoolVar(&dReleaseMode, "it-release", false, "(optional) Set if tests are being executed for a release")
flag.StringVar(&dRetryFailures, "it-retry-failures", "0", "Number of retries attempts for failing tests")
flag.StringVar(&dCloudProxyHost, "it-cloud-proxy-host", "10.128.0.34", "Hostname or IP address of static Cloud Auth Proxy")
flag.StringVar(&dCloudProxyPort, "it-cloud-proxy-port", "33134", "Port number of static Cloud Auth Proxy")
flag.StringVar(&dCloudProxyMySqlPort, "it-cloud-proxy-mysql-port", "33134", "MySql port number on static Cloud Auth Proxy")
flag.StringVar(&dCloudProxyPostgresPort, "it-cloud-proxy-postgres-port", "33136", "Postgres port number on static Cloud Auth Proxy")
flag.StringVar(&dCloudProxyPassword, "it-cloud-proxy-password", "t>5xl%J(&qTK6?FaZ", "Password of static Cloud Auth Proxy")
flag.StringVar(&dOracleInstance, "it-oracle-host", "10.128.0.90", "Hostname or IP address of static Oracle DB")
flag.StringVar(&dOracleHost, "it-oracle-host", "10.128.0.90", "Hostname or IP address of static Oracle DB")
flag.StringVar(&dCloudOracleSysPassword, "it-oracle-sys-password", "oracle", "sys password of static Oracle DB")
}

func Region() string {
Expand Down Expand Up @@ -119,14 +123,22 @@ func CloudProxyHost() string {
return "-DcloudProxyHost=" + dCloudProxyHost
}

func CloudProxyPort() string {
return "-DcloudProxyPort=" + dCloudProxyPort
func CloudProxyMySqlPort() string {
return "-DcloudProxyMySqlPort=" + dCloudProxyMySqlPort
}

func CloudProxyPostgresPort() string {
return "-DcloudProxyPostgresPort=" + dCloudProxyPostgresPort
}

func CloudProxyPassword() string {
return "-DcloudProxyPassword=" + dCloudProxyPassword
}

func StaticOracleInstance() string {
return "-DcloudOracleHost=" + dOracleInstance
func StaticOracleHost() string {
return "-DcloudOracleHost=" + dOracleHost
}

func StaticOracleSysPassword() string {
return "-DcloudOracleSysPassword=" + dCloudOracleSysPassword
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.beam.it.gcp.cloudsql;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Custom class for the MySQL implementation of {@link CloudSqlResourceManager} abstract class.
Expand All @@ -29,6 +31,8 @@
*/
public class CloudMySQLResourceManager extends CloudSqlResourceManager {

private static final Logger LOG = LoggerFactory.getLogger(CloudMySQLResourceManager.class);

private CloudMySQLResourceManager(Builder builder) {
super(builder);
}
Expand All @@ -49,6 +53,15 @@ public Builder(String testId) {
super(testId);
}

@Override
protected void configurePort() {
if (System.getProperty("cloudProxyMySqlPort") != null) {
this.setPort(Integer.parseInt(System.getProperty("cloudProxyMySqlPort")));

Check warning on line 59 in it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudMySQLResourceManager.java

View check run for this annotation

Codecov / codecov/patch

it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudMySQLResourceManager.java#L59

Added line #L59 was not covered by tests
} else {
LOG.warn("Missing -DcloudProxyMySqlPort.");
}
}

@Override
public @NonNull CloudMySQLResourceManager build() {
return new CloudMySQLResourceManager(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ public class CloudOracleResourceManager extends CloudSqlResourceManager {

private static final Logger LOG = LoggerFactory.getLogger(CloudOracleResourceManager.class);

private static final String DEFAULT_SYSTEM_IDENTIFIER = "xe";

private static final int DEFAULT_ORACLE_PORT = 1521;

private CloudOracleResourceManager(Builder builder) {
private String systemIdentifier;

protected CloudOracleResourceManager(Builder builder) {
super(builder);

this.systemIdentifier = builder.systemIdentifier;
System.setProperty("oracle.jdbc.timezoneAsRegion", "false");
}

Expand All @@ -65,27 +70,65 @@ public static Builder builder(String testId) {
return "SELECT * FROM " + tableName + " WHERE ROWNUM <= 1";
}

/**
* Return the SID of the connected DB.
*
* @return the SID.
*/
public String getSystemIdentifier() {
return this.systemIdentifier;

Check warning on line 79 in it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java

View check run for this annotation

Codecov / codecov/patch

it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java#L79

Added line #L79 was not covered by tests
}

/** Builder for {@link CloudOracleResourceManager}. */
public static final class Builder extends CloudSqlResourceManager.Builder {

private String systemIdentifier;

public Builder(String testId) {
super(testId);

this.setDatabaseName("xe");
this.setPort(DEFAULT_ORACLE_PORT);

// Currently only supports static Oracle instance on GCE
this.maybeUseStaticInstance();
this.setSystemIdentifier(DEFAULT_SYSTEM_IDENTIFIER);
this.setDatabaseName(this.systemIdentifier);
}

public Builder maybeUseStaticInstance() {
@Override
protected void configureHost() {
if (System.getProperty("cloudOracleHost") != null) {
this.setHost(System.getProperty("cloudOracleHost"));
} else {
LOG.warn("Missing -DcloudOracleHost.");
}
this.useStaticContainer();
}

@Override
protected void configurePort() {
if (System.getProperty("cloudOraclePort") != null) {
this.setPort(Integer.parseInt(System.getProperty("cloudOraclePort")));

Check warning on line 106 in it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java

View check run for this annotation

Codecov / codecov/patch

it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java#L106

Added line #L106 was not covered by tests
} else {
this.setPort(DEFAULT_ORACLE_PORT);
}
}

@Override
protected void configureUsername() {
if (System.getProperty("cloudOracleUsername") != null) {
this.setUsername(System.getProperty("cloudOracleUsername"));

Check warning on line 115 in it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java

View check run for this annotation

Codecov / codecov/patch

it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java#L115

Added line #L115 was not covered by tests
} else {
super.configureUsername();
}
}

@Override
protected void configurePassword() {
if (System.getProperty("cloudOraclePassword") != null) {
this.setPassword(System.getProperty("cloudOraclePassword"));

Check warning on line 124 in it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java

View check run for this annotation

Codecov / codecov/patch

it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/cloudsql/CloudOracleResourceManager.java#L124

Added line #L124 was not covered by tests
} else {
super.configurePassword();
}
}

public Builder setSystemIdentifier(String systemIdentifier) {
this.systemIdentifier = systemIdentifier;
return this;
}

Expand Down
Loading

0 comments on commit 7e440c4

Please sign in to comment.