Skip to content

Commit

Permalink
Merge pull request #73 from G-Lenz/main
Browse files Browse the repository at this point in the history
Release v2.7.2
  • Loading branch information
abewub authored Sep 11, 2024
2 parents 46dd9e9 + f686b95 commit b40d8c9
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 97 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.7.2] - 2024-09
### Fixed
- Some user sesssions not appearing in session table due to batchWrite API limit being reached

## [2.7.1] - 2024-08
### Added
- Security.md file
Expand Down
5 changes: 5 additions & 0 deletions source/lib/components/ecs-cluster-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface EcsClusterResourcesProps extends cdk.StackProps {
readonly newPrivateSubnet2Id: string;
readonly numberOfmonthsForTerminationCheck: string;
readonly stableTagCondition: string;
readonly stableTagInUse: string;
}

export class EcsClusterResources extends Construct {
Expand Down Expand Up @@ -407,6 +408,10 @@ export class EcsClusterResources extends Construct {
name: "ImageVersion",
value: image,
},
{
name: "StableTag",
value: props.stableTagInUse,
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ export class CostOptimizerHubStack extends cdk.Stack {
newPrivateSubnet2Id: costOptimizerVpc.privateSubnet2.attrSubnetId,
numberOfmonthsForTerminationCheck: numberOfMonthsForTerminationCheck.valueAsString,
stableTagCondition: stableTagCondition.logicalId,
stableTagInUse: stableTagging.valueAsString,
};

new EcsClusterResources(this, "EcsClusterResources", ecsClusterProps);
Expand Down
94 changes: 44 additions & 50 deletions source/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions source/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cost-optimizer-for-amazon-workspaces",
"version": "2.7.0",
"version": "2.7.2",
"description": "Cost Optimizer for Amazon Workspaces (SO0018)",
"license": "Apache-2.0",
"repository": {
Expand All @@ -18,16 +18,16 @@
"test": "jest --coverage",
"license-report": "license-report --output=csv --delimiter=' under ' --fields=name --fields=licenseType",
"cdk": "cdk",
"bootstrap": "SOLUTION_VERSION=v2.7.1 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk bootstrap",
"deploy": "SOLUTION_VERSION=v2.7.1 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk deploy cost-optimizer-for-amazon-workspaces",
"deploySpoke": "SOLUTION_VERSION=v2.7.1 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk deploy cost-optimizer-for-amazon-workspaces-spoke",
"synth": "SOLUTION_VERSION=v2.7.1 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces DIST_OUTPUT_BUCKET=solutions-reference cdk synth"
"bootstrap": "SOLUTION_VERSION=v2.7.2 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk bootstrap",
"deploy": "SOLUTION_VERSION=v2.7.2 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk deploy cost-optimizer-for-amazon-workspaces",
"deploySpoke": "SOLUTION_VERSION=v2.7.2 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk deploy cost-optimizer-for-amazon-workspaces-spoke",
"synth": "SOLUTION_VERSION=v2.7.2 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces DIST_OUTPUT_BUCKET=solutions-reference cdk synth"
},
"devDependencies": {
"@aws-cdk/assert": "2.68.0",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.9",
"@types/sinon": "^10.0.16",
"@types/sinon": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"aws-cdk": "^2.94.0",
"cdk-nag": "^2.27.124",
Expand All @@ -41,7 +41,7 @@
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.6.4",
"prettier": "^3.2.5",
"sinon": "^17.0.0",
"sinon": "^18.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.4.3"
Expand Down
6 changes: 6 additions & 0 deletions source/test/__snapshots__/hub-snapshot.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,12 @@ exports[`hub stack synth matches the existing snapshot 1`] = `
],
},
},
{
"Name": "StableTag",
"Value": {
"Ref": "UseStableTagging",
},
},
],
"Essential": true,
"Image": {
Expand Down
2 changes: 1 addition & 1 deletion source/testing_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jmespath==1.0.1
packaging==23.0
pluggy==1.0.0
pyparsing==3.0.9
python-dateutil==2.8.2
python-dateutil==2.9.0
s3transfer==0.10.2
six==1.16.0
tomli==2.0.1
Expand Down
2 changes: 1 addition & 1 deletion source/workspaces_app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ charset-normalizer==2.1.1
idna==3.7
idna==3.7
jmespath==1.0.1
python-dateutil==2.8.2
python-dateutil==2.9.0
requests==2.32.0
s3transfer==0.10.2
six==1.16.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def ws_record(ws_billing_data, ws_metrics):
billing_data=ws_billing_data,
performance_metrics=ws_metrics,
report_date="test-report-date",
last_reported_metric_period="test-last-period",
last_known_user_connection="test-last-connection",
last_reported_metric_period="2024-09-03T00:00:00Z",
last_known_user_connection="2024-09-02T00:00:00Z",
tags="[{'key1': 'tag1'}, {'key2': 'tag2'}]",
)

Expand Down Expand Up @@ -235,7 +235,9 @@ def test_get_end_of_month(session):
@unittest.mock.patch("boto3.session.Session")
@unittest.mock.patch(DirectoryReader.__module__ + ".upload_report")
@unittest.mock.patch(DirectoryReader.__module__ + ".WorkspacesHelper")
@unittest.mock.patch(DirectoryReader.__module__ + ".UsageTableDAO")
def test_process_directory_with_multiple_graphics_workspaces(
mock_usage_table_dao,
MockWorkspacesHelper,
mock_session,
stack_parameters,
Expand All @@ -248,6 +250,7 @@ def test_process_directory_with_multiple_graphics_workspaces(
"WorkspaceId": "ws-graphics1",
"DirectoryId": "foobarbazqux",
"UserName": "graphics_user",
"ComputerName": "cpu1",
"State": "AVAILABLE",
"WorkspaceProperties": {
"RunningMode": "AUTO_STOP",
Expand All @@ -258,6 +261,7 @@ def test_process_directory_with_multiple_graphics_workspaces(
"WorkspaceId": "ws-graphicsPro1",
"DirectoryId": "foobarbazqux",
"UserName": "graphicsPro_user",
"ComputerName": "cpu2",
"State": "AVAILABLE",
"WorkspaceProperties": {
"RunningMode": "AUTO_STOP",
Expand All @@ -268,26 +272,45 @@ def test_process_directory_with_multiple_graphics_workspaces(
MockWorkspacesHelper.return_value.get_workspaces_for_directory.return_value = (
graphics_workspaces
)
MockWorkspacesHelper.return_value.get_hourly_threshold_for_bundle_type.return_value = Decimal(
"100"
)
ws_records = [copy.deepcopy(ws_record), copy.deepcopy(ws_record)]
for idx, record in enumerate(ws_records):
record.description = ws_description(
**{
"username": graphics_workspaces[idx]["UserName"],
"directory_id": graphics_workspaces[idx]["DirectoryId"],
"bundle_type": graphics_workspaces[idx]["WorkspaceProperties"][
"ComputeTypeName"
],
"initial_mode": graphics_workspaces[idx]["WorkspaceProperties"][
"RunningMode"
],
"workspace_id": graphics_workspaces[idx]["WorkspaceId"],
"computer_name": graphics_workspaces[idx]["ComputerName"],
}
)

mock_session.client.return_value.get_item.return_value = {}
mock_session.client.return_value.get_caller_identity.return_value = {
"Account": ws_record.description.account
}
mock_process_workspace = MockWorkspacesHelper.return_value.process_workspace
mock_process_workspace.side_effect = ws_records
region = "us-east-1"
mock_usage_table_dao.return_value.get_workspace_ddb_item.side_effect = [
ws_records[0].description,
ws_records[1].description,
]
directory_reader = DirectoryReader(mock_session, region)
result = directory_reader.process_directory(
stack_parameters, directory_parameters, dashboard_metrics
)
mock_process_workspace.has_calls([(ws_records[0], None), (ws_records[1], None)])
mock_process_workspace.assert_has_calls(
[
unittest.mock.call(ws_records[0].description, None, dashboard_metrics),
unittest.mock.call(ws_records[1].description, None, dashboard_metrics),
]
)
assert len(mock_process_workspace.call_args_list) == 2
assert result[0] == 2
assert result[1][0]["bundleType"] == "GRAPHICS_G4DN"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,9 @@ def test_get_billable_hours_and_performance_none(mocker, session, ws_record):

spy_get_time_range.assert_called_once()
spy_get_cloudwatch_metric_data_points.assert_called_once()
spy_get_list_data_points.not_called()
spy_get_user_connected_hours.not_called()
spy_get_user_sessions.not_called()
spy_get_list_data_points.assert_not_called()
spy_get_user_connected_hours.assert_not_called()
spy_get_user_sessions.assert_not_called()

assert result == None

Expand Down
Loading

0 comments on commit b40d8c9

Please sign in to comment.