Skip to content
Open
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
76 changes: 71 additions & 5 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ permissions:
contents: read # This is required for actions/checkout

jobs:
run-integration-tests:
name: Run Integration Tests
run-integration-tests-default:
name: Run Integration Tests (Default)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
versions: [ "default", "latest" ]
dbEngine: ["aurora-mysql", "aurora-postgres", "multi-az-mysql", "multi-az-postgres" ]

steps:
Expand Down Expand Up @@ -65,7 +64,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.creds.outputs.aws-session-token }}
AURORA_MYSQL_DB_ENGINE_VERSION: ${{ matrix.dbEngine }}
AURORA_PG_DB_ENGINE_VERSION: ${{ matrix.versions }}
AURORA_PG_DB_ENGINE_VERSION: default

- name: "Get Github Action IP"
if: always()
Expand All @@ -86,6 +85,73 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-report-default-${{ matrix.dbEngine }}-${{ matrix.versions}}
name: integration-report-default-${{ matrix.dbEngine }}
path: ./tests/integration/container/reports
retention-days: 5

run-integration-tests-latest:
name: Run Integration Tests (Latest)
runs-on: ubuntu-latest
needs: run-integration-tests-default
strategy:
fail-fast: false
matrix:
dbEngine: ["aurora-mysql", "aurora-postgres", "multi-az-mysql", "multi-az-postgres" ]

steps:
- name: Clone repository
uses: actions/checkout@v4
- name: "Set up JDK 8"
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 8
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install dependencies
run: npm install --no-save

- name: Configure AWS Credentials
id: creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }}
role-session-name: nodejs_int_latest_tests
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
output-credentials: true

- name: Run Integration Tests
run: |
./gradlew --no-parallel --no-daemon test-${{ matrix.dbEngine }} --info
env:
RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ steps.creds.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.creds.outputs.aws-session-token }}
AURORA_MYSQL_DB_ENGINE_VERSION: ${{ matrix.dbEngine }}
AURORA_PG_DB_ENGINE_VERSION: latest

- name: "Get Github Action IP"
if: always()
id: ip
uses: haythem/public-ip@v1.3

- name: "Remove Github Action IP"
if: always()
run: |
aws ec2 revoke-security-group-ingress \
--group-name default \
--protocol -1 \
--port -1 \
--cidr ${{ steps.ip.outputs.ipv4 }}/32 \
2>&1 > /dev/null;
- name: Archive results
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-report-latest-${{ matrix.dbEngine }}
path: ./tests/integration/container/reports
retention-days: 5
41 changes: 23 additions & 18 deletions common/lib/aws_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,37 @@
limitations under the License.
*/

import { PluginServiceManagerContainer } from "./plugin_service_manager_container";
import { PluginService, PluginServiceImpl } from "./plugin_service";
import { PluginService } from "./plugin_service";
import { DatabaseDialect, DatabaseType } from "./database_dialect/database_dialect";
import { ConnectionUrlParser } from "./utils/connection_url_parser";
import { HostListProvider } from "./host_list_provider/host_list_provider";
import { PluginManager } from "./plugin_manager";

import pkgStream from "stream";
import { ClientWrapper } from "./client_wrapper";
import { ConnectionProviderManager } from "./connection_provider_manager";
import { DefaultTelemetryFactory } from "./utils/telemetry/default_telemetry_factory";
import { TelemetryFactory } from "./utils/telemetry/telemetry_factory";
import { DriverDialect } from "./driver_dialect/driver_dialect";
import { WrapperProperties } from "./wrapper_property";
import { DriverConfigurationProfiles } from "./profile/driver_configuration_profiles";
import { ConfigurationProfile } from "./profile/configuration_profile";
import { AwsWrapperError, TransactionIsolationLevel, ConnectionProvider } from "./";
import { AwsWrapperError, ConnectionProvider, TransactionIsolationLevel } from "./";
import { Messages } from "./utils/messages";
import { HostListProviderService } from "./host_list_provider_service";
import { SessionStateClient } from "./session_state_client";
import { DriverConnectionProvider } from "./driver_connection_provider";
import { ServiceUtils } from "./utils/service_utils";
import { StorageService } from "./utils/storage/storage_service";
import { MonitorService } from "./utils/monitoring/monitor_service";
import { CoreServicesContainer } from "./utils/core_services_container";
import { FullServicesContainer } from "./utils/full_services_container";

const { EventEmitter } = pkgStream;

export abstract class AwsClient extends EventEmitter implements SessionStateClient {
private _defaultPort: number = -1;
private readonly fullServiceContainer: FullServicesContainer;
private readonly storageService: StorageService;
private readonly monitorService: MonitorService;
protected telemetryFactory: TelemetryFactory;
protected pluginManager: PluginManager;
protected pluginService: PluginService;
Expand Down Expand Up @@ -103,22 +105,25 @@ export abstract class AwsClient extends EventEmitter implements SessionStateClie
}
}

const coreServicesContainer: CoreServicesContainer = CoreServicesContainer.getInstance();
this.storageService = coreServicesContainer.getStorageService();
this.monitorService = coreServicesContainer.getMonitorService();
this.telemetryFactory = new DefaultTelemetryFactory(this.properties);
const container = new PluginServiceManagerContainer();
this.pluginService = new PluginServiceImpl(
container,

this.fullServiceContainer = ServiceUtils.instance.createStandardServiceContainer(
this.storageService,
this.monitorService,
this,
this.properties,
dbType,
knownDialectsByCode,
this.properties,
this._configurationProfile?.getDriverDialect() ?? driverDialect
);
this.pluginManager = new PluginManager(
container,
this.properties,
new ConnectionProviderManager(connectionProvider ?? new DriverConnectionProvider(), WrapperProperties.CONNECTION_PROVIDER.get(this.properties)),
this.telemetryFactory
this._configurationProfile?.getDriverDialect() ?? driverDialect,
this.telemetryFactory,
connectionProvider
);

this.pluginService = this.fullServiceContainer.getPluginService();
this.pluginManager = this.fullServiceContainer.getPluginManager();
}

private async setup() {
Expand Down Expand Up @@ -159,11 +164,11 @@ export abstract class AwsClient extends EventEmitter implements SessionStateClie

abstract setReadOnly(readOnly: boolean): Promise<any | void>;

abstract isReadOnly(): boolean;
abstract isReadOnly(): boolean | undefined;

abstract setAutoCommit(autoCommit: boolean): Promise<any | void>;

abstract getAutoCommit(): boolean;
abstract getAutoCommit(): boolean | undefined;

abstract setTransactionIsolation(level: TransactionIsolationLevel): Promise<any | void>;

Expand Down
2 changes: 0 additions & 2 deletions common/lib/host_list_provider/rds_host_list_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ import { Messages } from "../utils/messages";
import { WrapperProperties } from "../wrapper_property";
import { logger } from "../../logutils";
import { HostAvailability } from "../host_availability/host_availability";
import { CacheMap } from "../utils/cache_map";
import { isDialectTopologyAware, logTopology } from "../utils/utils";
import { DatabaseDialect } from "../database_dialect/database_dialect";
import { ClientWrapper } from "../client_wrapper";
import { CoreServicesContainer } from "../utils/core_services_container";
import { StorageService } from "../utils/storage/storage_service";
import { Topology } from "./topology";
import { ExpirationCache } from "../utils/storage/expiration_cache";

export class RdsHostListProvider implements DynamicHostListProvider {
private readonly originalUrl: string;
Expand Down
35 changes: 16 additions & 19 deletions common/lib/plugin_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { HostInfo } from "./host_info";
import { ConnectionPluginChainBuilder } from "./connection_plugin_chain_builder";
import { AwsWrapperError } from "./utils/errors";
import { Messages } from "./utils/messages";
import { PluginServiceManagerContainer } from "./plugin_service_manager_container";
import { HostListProviderService } from "./host_list_provider_service";
import { HostChangeOptions } from "./host_change_options";
import { OldConnectionSuggestionAction } from "./old_connection_suggestion_action";
Expand All @@ -32,6 +31,7 @@ import { TelemetryTraceLevel } from "./utils/telemetry/telemetry_trace_level";
import { ConnectionProvider } from "./connection_provider";
import { ConnectionPluginFactory } from "./plugin_factory";
import { ConfigurationProfile } from "./profile/configuration_profile";
import { FullServicesContainer } from "./utils/full_services_container";

type PluginFunc<T> = (plugin: ConnectionPlugin, targetFunc: () => Promise<T>) => Promise<T>;

Expand Down Expand Up @@ -79,17 +79,16 @@ export class PluginManager {
private readonly props: Map<string, any>;
private _plugins: ConnectionPlugin[] = [];
private readonly connectionProviderManager: ConnectionProviderManager;
private pluginServiceManagerContainer: PluginServiceManagerContainer;
private fullServiceContainer: FullServicesContainer;
protected telemetryFactory: TelemetryFactory;

constructor(
pluginServiceManagerContainer: PluginServiceManagerContainer,
fullServicesContainer: FullServicesContainer,
props: Map<string, any>,
connectionProviderManager: ConnectionProviderManager,
telemetryFactory: TelemetryFactory
) {
this.pluginServiceManagerContainer = pluginServiceManagerContainer;
this.pluginServiceManagerContainer.pluginManager = this;
this.fullServiceContainer = fullServicesContainer;
this.connectionProviderManager = connectionProviderManager;
this.props = props;
this.telemetryFactory = telemetryFactory;
Expand All @@ -98,17 +97,15 @@ export class PluginManager {
async init(configurationProfile?: ConfigurationProfile | null): Promise<void>;
async init(configurationProfile: ConfigurationProfile | null, plugins: ConnectionPlugin[]): Promise<void>;
async init(configurationProfile: ConfigurationProfile | null, plugins?: ConnectionPlugin[]) {
if (this.pluginServiceManagerContainer.pluginService != null) {
if (plugins) {
this._plugins = plugins;
} else {
this._plugins = await ConnectionPluginChainBuilder.getPlugins(
this.pluginServiceManagerContainer.pluginService,
this.props,
this.connectionProviderManager,
configurationProfile
);
}
if (plugins) {
this._plugins = plugins;
} else {
this._plugins = await ConnectionPluginChainBuilder.getPlugins(
this.fullServiceContainer.getPluginService(),
this.props,
this.connectionProviderManager,
configurationProfile
);
}
for (const plugin of this._plugins) {
PluginManager.PLUGINS.add(plugin);
Expand All @@ -128,8 +125,8 @@ export class PluginManager {
}

const telemetryContext = this.telemetryFactory.openTelemetryContext(methodName, TelemetryTraceLevel.NESTED);
const currentClient: ClientWrapper = this.pluginServiceManagerContainer.pluginService.getCurrentClient().targetClient;
this.pluginServiceManagerContainer.pluginService.attachNoOpErrorListener(currentClient);
const currentClient: ClientWrapper = this.fullServiceContainer.getPluginService().getCurrentClient().targetClient;
this.fullServiceContainer.getPluginService().attachNoOpErrorListener(currentClient);
try {
return await telemetryContext.start(() => {
return this.executeWithSubscribedPlugins(
Expand All @@ -142,7 +139,7 @@ export class PluginManager {
);
});
} finally {
this.pluginServiceManagerContainer.pluginService.attachErrorListener(currentClient);
this.fullServiceContainer.getPluginService().attachErrorListener(currentClient);
}
}

Expand Down
Loading