Skip to content

Commit b40d8c9

Browse files
authored
Merge pull request #73 from G-Lenz/main
Release v2.7.2
2 parents 46dd9e9 + f686b95 commit b40d8c9

13 files changed

+153
-97
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.7.2] - 2024-09
8+
### Fixed
9+
- Some user sesssions not appearing in session table due to batchWrite API limit being reached
10+
711
## [2.7.1] - 2024-08
812
### Added
913
- Security.md file

source/lib/components/ecs-cluster-resources.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface EcsClusterResourcesProps extends cdk.StackProps {
5757
readonly newPrivateSubnet2Id: string;
5858
readonly numberOfmonthsForTerminationCheck: string;
5959
readonly stableTagCondition: string;
60+
readonly stableTagInUse: string;
6061
}
6162

6263
export class EcsClusterResources extends Construct {
@@ -407,6 +408,10 @@ export class EcsClusterResources extends Construct {
407408
name: "ImageVersion",
408409
value: image,
409410
},
411+
{
412+
name: "StableTag",
413+
value: props.stableTagInUse,
414+
},
410415
],
411416
},
412417
],

source/lib/cost-optimizer-for-amazon-workspaces-hub-stack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ export class CostOptimizerHubStack extends cdk.Stack {
540540
newPrivateSubnet2Id: costOptimizerVpc.privateSubnet2.attrSubnetId,
541541
numberOfmonthsForTerminationCheck: numberOfMonthsForTerminationCheck.valueAsString,
542542
stableTagCondition: stableTagCondition.logicalId,
543+
stableTagInUse: stableTagging.valueAsString,
543544
};
544545

545546
new EcsClusterResources(this, "EcsClusterResources", ecsClusterProps);

source/package-lock.json

Lines changed: 44 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cost-optimizer-for-amazon-workspaces",
3-
"version": "2.7.0",
3+
"version": "2.7.2",
44
"description": "Cost Optimizer for Amazon Workspaces (SO0018)",
55
"license": "Apache-2.0",
66
"repository": {
@@ -18,16 +18,16 @@
1818
"test": "jest --coverage",
1919
"license-report": "license-report --output=csv --delimiter=' under ' --fields=name --fields=licenseType",
2020
"cdk": "cdk",
21-
"bootstrap": "SOLUTION_VERSION=v2.7.1 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk bootstrap",
22-
"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",
23-
"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",
24-
"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"
21+
"bootstrap": "SOLUTION_VERSION=v2.7.2 SOLUTION_NAME=cost-optimizer-for-amazon-workspaces SOLUTION_TRADEMARKEDNAME=cost-optimizer-for-amazon-workspaces cdk bootstrap",
22+
"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",
23+
"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",
24+
"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"
2525
},
2626
"devDependencies": {
2727
"@aws-cdk/assert": "2.68.0",
2828
"@types/jest": "^29.5.4",
2929
"@types/node": "^20.5.9",
30-
"@types/sinon": "^10.0.16",
30+
"@types/sinon": "^17.0.3",
3131
"@typescript-eslint/eslint-plugin": "^6.21.0",
3232
"aws-cdk": "^2.94.0",
3333
"cdk-nag": "^2.27.124",
@@ -41,7 +41,7 @@
4141
"eslint-plugin-promise": "^6.1.1",
4242
"jest": "^29.6.4",
4343
"prettier": "^3.2.5",
44-
"sinon": "^17.0.0",
44+
"sinon": "^18.0.0",
4545
"ts-jest": "^29.1.1",
4646
"ts-node": "^10.9.1",
4747
"typescript": "^5.4.3"

source/test/__snapshots__/hub-snapshot.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,12 @@ exports[`hub stack synth matches the existing snapshot 1`] = `
14101410
],
14111411
},
14121412
},
1413+
{
1414+
"Name": "StableTag",
1415+
"Value": {
1416+
"Ref": "UseStableTagging",
1417+
},
1418+
},
14131419
],
14141420
"Essential": true,
14151421
"Image": {

source/testing_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jmespath==1.0.1
1313
packaging==23.0
1414
pluggy==1.0.0
1515
pyparsing==3.0.9
16-
python-dateutil==2.8.2
16+
python-dateutil==2.9.0
1717
s3transfer==0.10.2
1818
six==1.16.0
1919
tomli==2.0.1

source/workspaces_app/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ charset-normalizer==2.1.1
55
idna==3.7
66
idna==3.7
77
jmespath==1.0.1
8-
python-dateutil==2.8.2
8+
python-dateutil==2.9.0
99
requests==2.32.0
1010
s3transfer==0.10.2
1111
six==1.16.0

source/workspaces_app/workspaces_app/__tests__/test_directory_reader.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def ws_record(ws_billing_data, ws_metrics):
115115
billing_data=ws_billing_data,
116116
performance_metrics=ws_metrics,
117117
report_date="test-report-date",
118-
last_reported_metric_period="test-last-period",
119-
last_known_user_connection="test-last-connection",
118+
last_reported_metric_period="2024-09-03T00:00:00Z",
119+
last_known_user_connection="2024-09-02T00:00:00Z",
120120
tags="[{'key1': 'tag1'}, {'key2': 'tag2'}]",
121121
)
122122

@@ -235,7 +235,9 @@ def test_get_end_of_month(session):
235235
@unittest.mock.patch("boto3.session.Session")
236236
@unittest.mock.patch(DirectoryReader.__module__ + ".upload_report")
237237
@unittest.mock.patch(DirectoryReader.__module__ + ".WorkspacesHelper")
238+
@unittest.mock.patch(DirectoryReader.__module__ + ".UsageTableDAO")
238239
def test_process_directory_with_multiple_graphics_workspaces(
240+
mock_usage_table_dao,
239241
MockWorkspacesHelper,
240242
mock_session,
241243
stack_parameters,
@@ -248,6 +250,7 @@ def test_process_directory_with_multiple_graphics_workspaces(
248250
"WorkspaceId": "ws-graphics1",
249251
"DirectoryId": "foobarbazqux",
250252
"UserName": "graphics_user",
253+
"ComputerName": "cpu1",
251254
"State": "AVAILABLE",
252255
"WorkspaceProperties": {
253256
"RunningMode": "AUTO_STOP",
@@ -258,6 +261,7 @@ def test_process_directory_with_multiple_graphics_workspaces(
258261
"WorkspaceId": "ws-graphicsPro1",
259262
"DirectoryId": "foobarbazqux",
260263
"UserName": "graphicsPro_user",
264+
"ComputerName": "cpu2",
261265
"State": "AVAILABLE",
262266
"WorkspaceProperties": {
263267
"RunningMode": "AUTO_STOP",
@@ -268,26 +272,45 @@ def test_process_directory_with_multiple_graphics_workspaces(
268272
MockWorkspacesHelper.return_value.get_workspaces_for_directory.return_value = (
269273
graphics_workspaces
270274
)
275+
MockWorkspacesHelper.return_value.get_hourly_threshold_for_bundle_type.return_value = Decimal(
276+
"100"
277+
)
271278
ws_records = [copy.deepcopy(ws_record), copy.deepcopy(ws_record)]
272279
for idx, record in enumerate(ws_records):
273280
record.description = ws_description(
274281
**{
282+
"username": graphics_workspaces[idx]["UserName"],
283+
"directory_id": graphics_workspaces[idx]["DirectoryId"],
275284
"bundle_type": graphics_workspaces[idx]["WorkspaceProperties"][
276285
"ComputeTypeName"
277286
],
287+
"initial_mode": graphics_workspaces[idx]["WorkspaceProperties"][
288+
"RunningMode"
289+
],
278290
"workspace_id": graphics_workspaces[idx]["WorkspaceId"],
291+
"computer_name": graphics_workspaces[idx]["ComputerName"],
279292
}
280293
)
281-
282-
mock_session.client.return_value.get_item.return_value = {}
294+
mock_session.client.return_value.get_caller_identity.return_value = {
295+
"Account": ws_record.description.account
296+
}
283297
mock_process_workspace = MockWorkspacesHelper.return_value.process_workspace
284298
mock_process_workspace.side_effect = ws_records
285299
region = "us-east-1"
300+
mock_usage_table_dao.return_value.get_workspace_ddb_item.side_effect = [
301+
ws_records[0].description,
302+
ws_records[1].description,
303+
]
286304
directory_reader = DirectoryReader(mock_session, region)
287305
result = directory_reader.process_directory(
288306
stack_parameters, directory_parameters, dashboard_metrics
289307
)
290-
mock_process_workspace.has_calls([(ws_records[0], None), (ws_records[1], None)])
308+
mock_process_workspace.assert_has_calls(
309+
[
310+
unittest.mock.call(ws_records[0].description, None, dashboard_metrics),
311+
unittest.mock.call(ws_records[1].description, None, dashboard_metrics),
312+
]
313+
)
291314
assert len(mock_process_workspace.call_args_list) == 2
292315
assert result[0] == 2
293316
assert result[1][0]["bundleType"] == "GRAPHICS_G4DN"

source/workspaces_app/workspaces_app/__tests__/test_metrics_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,9 @@ def test_get_billable_hours_and_performance_none(mocker, session, ws_record):
809809

810810
spy_get_time_range.assert_called_once()
811811
spy_get_cloudwatch_metric_data_points.assert_called_once()
812-
spy_get_list_data_points.not_called()
813-
spy_get_user_connected_hours.not_called()
814-
spy_get_user_sessions.not_called()
812+
spy_get_list_data_points.assert_not_called()
813+
spy_get_user_connected_hours.assert_not_called()
814+
spy_get_user_sessions.assert_not_called()
815815

816816
assert result == None
817817

0 commit comments

Comments
 (0)