Skip to content

Commit

Permalink
PR feedback updates
Browse files Browse the repository at this point in the history
Signed-off-by: Tanner Lewis <[email protected]>
  • Loading branch information
lewijacn committed Sep 20, 2024
1 parent 3cc59c0 commit c5c69dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Metadata Migration](#metadata-migration)
- [Replay](#replay)
- [Kafka](#kafka)
- [Client Options](#client-options)
- [Usage](#usage)
- [Library](#library)
- [CLI](#cli)
Expand Down Expand Up @@ -82,6 +83,8 @@ metadata_migration:
kafka:
broker_endpoints: "kafka:9092"
standard:
client_options:
user_agent_extra: "test-user-agent-v1.0"
```
## Services.yaml spec
Expand Down Expand Up @@ -225,13 +228,19 @@ Exactly one of the following blocks must be present:

A Kafka cluster is used in the capture and replay stage of the migration to store recorded requests and responses before they're replayed. While it's not necessary for a user to directly interact with the Kafka cluster in most cases, there are a handful of commands that can be helpful for checking on the status or resetting state that are exposed by the Console CLI.

- `broker_endpoints`: required, comma-separated list of kafaka broker endpoints
- `broker_endpoints`: required, comma-separated list of kafka broker endpoints

Exactly one of the following keys must be present, but both are nullable (they don't have or need any additional parameters).

- `msk`: the Kafka instance is deployed as AWS Managed Service Kafka
- `standard`: the Kafka instance is deployed as a standard Kafka cluster (e.g. on Docker)

### Client Options

Client options are global settings that are applied to different clients used throughout this library

- `user_agent_extra`: optional, a user agent string that will be appended to the `User-Agent` header of all requests from this library

## Usage

### Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def create_pipeline_from_env(osi_client,
# Target endpoints for OSI are not currently allowed a port
target_endpoint_clean = sanitize_endpoint(target_cluster.endpoint, True)
source_auth_secret = None
if source_cluster.auth_details and source_cluster.auth_details["password_from_secret_arn"]:
if source_cluster.auth_details and "password_from_secret_arn" in source_cluster.auth_details:
source_auth_secret = source_cluster.auth_details["password_from_secret_arn"]
pipeline_config_string = construct_pipeline_config(pipeline_config_file_path=pipeline_template_path,
source_endpoint=source_endpoint_clean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from console_link.models.utils import append_user_agent_header_for_requests, create_boto3_client
from console_link.models.utils import append_user_agent_header_for_requests
import requests.utils

USER_AGENT_EXTRA = "test-user-agent-v1.0"
Expand All @@ -9,13 +9,15 @@ def test_append_user_agent_header_for_requests_no_headers():
result_headers = append_user_agent_header_for_requests(headers=None, user_agent_extra=USER_AGENT_EXTRA)
assert result_headers == expected_headers


def test_append_user_agent_header_for_requests_existing_headers():
existing_headers = {"Accept": "/*", "Host": "macosx"}
expected_headers = dict(existing_headers)
expected_headers["User-Agent"] = f"{requests.utils.default_user_agent()} {USER_AGENT_EXTRA}"
result_headers = append_user_agent_header_for_requests(headers=existing_headers, user_agent_extra=USER_AGENT_EXTRA)
assert result_headers == expected_headers


def test_append_user_agent_header_for_requests_existing_headers_with_user_agent():
existing_headers = {"Accept": "/*", "Host": "macosx", "User-Agent": "pyclient"}
expected_headers = dict(existing_headers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('createApp', () => {
process.env.CDK_DEFAULT_ACCOUNT = 'test-account';
process.env.CDK_DEFAULT_REGION = 'test-region';
process.env.MIGRATIONS_APP_REGISTRY_ARN = 'test-arn';
process.env.CUSTOM_REPLAYER_USER_AGENT = 'test-user-agent';
process.env.MIGRATIONS_USER_AGENT = 'test-user-agent';

const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
const mockAddTag = jest.fn();
Expand All @@ -58,7 +58,7 @@ describe('createApp', () => {
expect.any(Object),
{
migrationsAppRegistryARN: 'test-arn',
customReplayerUserAgent: 'test-user-agent',
migrationsUserAgent: 'test-user-agent',
migrationsSolutionVersion: '1.0.0',
env: { account: 'test-account', region: 'test-region' },
}
Expand All @@ -74,4 +74,4 @@ describe('createApp', () => {

consoleSpy.mockRestore();
});
});
});

0 comments on commit c5c69dd

Please sign in to comment.