Skip to content

Commit b27e2a2

Browse files
committed
Git. Fixed SUI tests.
1 parent db0ab5a commit b27e2a2

File tree

8 files changed

+206
-18
lines changed

8 files changed

+206
-18
lines changed

lib/sui/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import "dotenv/config"
33
import "source-map-support/register";
44
import * as cdk from "aws-cdk-lib";
55
import * as nag from "cdk-nag";
6-
import * as config from "./lib/config/suiConfig";
6+
import * as config from "./lib/config/node-config";
77
import {SuiCommonStack} from "./lib/common-stack";
88
import {SuiSingleNodeStack} from "./lib/single-node-stack";
99

lib/sui/lib/config/suiConfig.ts renamed to lib/sui/lib/config/node-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as ec2 from "aws-cdk-lib/aws-ec2";
2-
import * as configTypes from "./suiConfig.interface";
2+
import * as configTypes from "./node-config.interface";
33
import * as constants from "../../../constructs/constants";
44

55

lib/sui/lib/constructs/sui-node-security-group.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class SuiNodeSecurityGroupConstruct extends cdkConstructs.Construct {
2727
sg.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.udp(8084), "Sui P2P");
2828
sg.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(9184), "Sui Metrics");
2929
sg.addIngressRule(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(9000), "JSON-RPC");
30-
sg.addIngressRule(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(22), "SSH");
3130

3231
this.securityGroup = sg
3332

lib/sui/lib/single-node-stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as nodeCwDashboard from "./constructs/node-cw-dashboard"
99
import * as cw from 'aws-cdk-lib/aws-cloudwatch';
1010
import * as nag from "cdk-nag";
1111
import { SingleNodeConstruct } from "../../constructs/single-node"
12-
import * as configTypes from "./config/suiConfig.interface";
12+
import * as configTypes from "./config/node-config.interface";
1313
import * as constants from "../../constructs/constants";
1414
import { SuiNodeSecurityGroupConstruct } from "./constructs/sui-node-security-group";
1515

@@ -113,7 +113,7 @@ export class SuiSingleNodeStack extends cdk.Stack {
113113
})
114114

115115
new cw.CfnDashboard(this, 'sui-cw-dashboard', {
116-
dashboardName: STACK_NAME,
116+
dashboardName: `${STACK_NAME}-${node.instanceId}`,
117117
dashboardBody: dashboardString,
118118
});
119119

lib/sui/test/.env-test

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#############################################################
2-
# Example configuration for Starknet nodes runner app on AWS #
2+
# Example configuration for Sui Node Runner app on AWS #
33
#############################################################
4-
54
## Set the AWS account is and region for your environment ##
6-
AWS_ACCOUNT_ID="xxxxxxxxxxx"
7-
AWS_REGION="us-east-1" # Regions supported by Amazon Managed Blockchain Access Ethereum: https://docs.aws.amazon.com/general/latest/gr/managedblockchain.html#managedblockchain-access
5+
AWS_ACCOUNT_ID="xxxxxxxx"
6+
AWS_REGION="us-east-1" # your region of choice
87

9-
## Common configuration parameters ##
10-
STARKNET_L1_ENDPOINT="wss://ethereum-rpc.publicnode.com"
11-
STARKNET_NETWORK_ID="mainnet" # All options: "mainnet", "sepolia", "sepolia-integration"
12-
STARKNET_NODE_VERSION="v0.11.7" # Current required version of Starknet
8+
## Common configuration parameters #
9+
SUI_NETWORK_ID="testnet" # All options: "mainnet", "testnet" , "devnet"
10+
SUI_INSTANCE_TYPE="m6i.4xlarge"
1311

14-
STARKNET_INSTANCE_TYPE="m6a.2xlarge"
1512
# Data volume configuration
16-
STARKNET_DATA_VOL_TYPE="gp3" # Other options: "io1" | "io2" | "gp3" | "instance-store" . IMPORTANT: Use "instance-store" option only with instance types that support that feature, like popular for node im4gn, d3, i3en, and i4i instance families
17-
STARKNET_DATA_VOL_SIZE="250" # Current required data size to keep both smapshot archive and unarchived version of it
18-
STARKNET_DATA_VOL_IOPS="3000" # Max IOPS for EBS volumes (not applicable for "instance-store")
19-
STARKNET_DATA_VOL_THROUGHPUT="700" # Max throughput for EBS gp3 volumes (not applicable for "io1" | "io2" | "instance-store")
13+
SUI_DATA_VOL_TYPE="gp3" # Other options: "io1" | "io2" | "gp3"
14+
SUI_DATA_VOL_SIZE="4000" # Current required data size to keep both snapshot archive and unarchived version of it
15+
SUI_DATA_VOL_IOPS="3000" # Max IOPS for EBS volumes
16+
SUI_DATA_VOL_THROUGHPUT="700" # Max throughput for EBS gp3 volumes (not applicable for "io1" | "io2")

lib/sui/test/common-stack.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { Match, Template } from "aws-cdk-lib/assertions";
2+
import * as cdk from "aws-cdk-lib";
3+
import * as dotenv from 'dotenv';
4+
dotenv.config({ path: './test/.env-test' });
5+
import * as config from "../lib/config/node-config";
6+
import { SuiCommonStack } from "../lib/common-stack";
7+
8+
describe("SuiCommonStack", () => {
9+
test("synthesizes the way we expect", () => {
10+
const app = new cdk.App();
11+
12+
// Create the SuiCommonStack.
13+
const suiCommonStack = new SuiCommonStack(app, "sui-common", {
14+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
15+
stackName: `sui-nodes-common`,
16+
});
17+
18+
// Prepare the stack for assertions.
19+
const template = Template.fromStack(suiCommonStack);
20+
21+
// Has EC2 instance role.
22+
template.hasResourceProperties("AWS::IAM::Role", {
23+
AssumeRolePolicyDocument: {
24+
Statement: [
25+
{
26+
Action: "sts:AssumeRole",
27+
Effect: "Allow",
28+
Principal: {
29+
Service: "ec2.amazonaws.com"
30+
}
31+
}
32+
]
33+
},
34+
ManagedPolicyArns: [
35+
{
36+
"Fn::Join": [
37+
"",
38+
[
39+
"arn:",
40+
{
41+
Ref: "AWS::Partition"
42+
},
43+
":iam::aws:policy/AmazonSSMManagedInstanceCore"
44+
]
45+
]
46+
},
47+
{
48+
"Fn::Join": [
49+
"",
50+
[
51+
"arn:",
52+
{
53+
"Ref": "AWS::Partition"
54+
},
55+
":iam::aws:policy/CloudWatchAgentServerPolicy"
56+
]
57+
]
58+
}
59+
]
60+
})
61+
62+
});
63+
});
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { Match, Template } from "aws-cdk-lib/assertions";
2+
import * as cdk from "aws-cdk-lib";
3+
import * as dotenv from 'dotenv';
4+
dotenv.config({ path: './test/.env-test' });
5+
import * as config from "../lib/config/node-config";
6+
import { SuiSingleNodeStack } from "../lib/single-node-stack";
7+
8+
describe("SuiSingleNodeStack", () => {
9+
test("synthesizes the way we expect", () => {
10+
const app = new cdk.App();
11+
12+
// Create the SuiSingleNodeStack.
13+
const suiSingleNodeStack = new SuiSingleNodeStack(app, "sui-single-node", {
14+
stackName: `sui-single-node-${config.baseNodeConfig.suiNetworkId}`,
15+
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },
16+
instanceType: config.baseNodeConfig.instanceType,
17+
instanceCpuType: config.baseNodeConfig.instanceCpuType,
18+
dataVolume: config.baseNodeConfig.dataVolume,
19+
suiNetworkId: config.baseNodeConfig.suiNetworkId,
20+
});
21+
22+
// Prepare the stack for assertions.
23+
const template = Template.fromStack(suiSingleNodeStack);
24+
25+
// Has EC2 instance security group.
26+
template.hasResourceProperties("AWS::EC2::SecurityGroup", {
27+
GroupDescription: Match.anyValue(),
28+
VpcId: Match.anyValue(),
29+
SecurityGroupEgress: [
30+
{
31+
"CidrIp": "0.0.0.0/0",
32+
"Description": "Allow all outbound traffic by default",
33+
"IpProtocol": "-1"
34+
}
35+
],
36+
SecurityGroupIngress: [
37+
{
38+
"CidrIp": "0.0.0.0/0",
39+
"Description": "Sui P2P",
40+
"FromPort": 8084,
41+
"IpProtocol": "udp",
42+
"ToPort": 8084
43+
},
44+
{
45+
"CidrIp": "0.0.0.0/0",
46+
"Description": "Sui Metrics",
47+
"FromPort": 9184,
48+
"IpProtocol": "tcp",
49+
"ToPort": 9184
50+
},
51+
{
52+
"CidrIp": "1.2.3.4/5",
53+
"Description": "JSON-RPC",
54+
"FromPort": 9000,
55+
"IpProtocol": "tcp",
56+
"ToPort": 9000
57+
}
58+
]
59+
})
60+
61+
// Has EC2 instance with node configuration
62+
template.hasResourceProperties("AWS::EC2::Instance", {
63+
AvailabilityZone: Match.anyValue(),
64+
UserData: Match.anyValue(),
65+
BlockDeviceMappings: [
66+
{
67+
DeviceName: "/dev/sda1",
68+
Ebs: {
69+
DeleteOnTermination: true,
70+
Encrypted: true,
71+
Iops: 3000,
72+
VolumeSize: 46,
73+
VolumeType: "gp3"
74+
}
75+
}
76+
],
77+
IamInstanceProfile: Match.anyValue(),
78+
ImageId: Match.anyValue(),
79+
InstanceType: "m6i.4xlarge",
80+
Monitoring: true,
81+
PropagateTagsToVolumeOnCreation: true,
82+
SecurityGroupIds: Match.anyValue(),
83+
SubnetId: Match.anyValue(),
84+
})
85+
86+
// Has EBS data volume.
87+
template.hasResourceProperties("AWS::EC2::Volume", {
88+
AvailabilityZone: Match.anyValue(),
89+
Encrypted: true,
90+
Iops: 3000,
91+
MultiAttachEnabled: false,
92+
Size: 4000,
93+
Throughput: 700,
94+
VolumeType: "gp3"
95+
})
96+
97+
// Has EBS data volume attachment.
98+
template.hasResourceProperties("AWS::EC2::VolumeAttachment", {
99+
Device: "/dev/sdf",
100+
InstanceId: Match.anyValue(),
101+
VolumeId: Match.anyValue(),
102+
})
103+
104+
// Has EBS accounts volume.
105+
template.hasResourceProperties("AWS::EC2::Volume", {
106+
AvailabilityZone: Match.anyValue(),
107+
Encrypted: true,
108+
Iops: 3000,
109+
MultiAttachEnabled: false,
110+
Size: 4000,
111+
Throughput: 700,
112+
VolumeType: "gp3"
113+
})
114+
115+
// Has EBS accounts volume attachment.
116+
template.hasResourceProperties("AWS::EC2::VolumeAttachment", {
117+
Device: "/dev/sdf",
118+
InstanceId: Match.anyValue(),
119+
VolumeId: Match.anyValue(),
120+
})
121+
122+
// Has CloudWatch dashboard.
123+
template.hasResourceProperties("AWS::CloudWatch::Dashboard", {
124+
DashboardBody: Match.anyValue(),
125+
DashboardName: {"Fn::Join": ["", ["sui-single-node-testnet-",{ "Ref": Match.anyValue() }]]}
126+
})
127+
128+
});
129+
});

0 commit comments

Comments
 (0)