Skip to content

Commit

Permalink
Improve E2E tests (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Jul 13, 2024
1 parent b5b387d commit 785a4f4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
34 changes: 29 additions & 5 deletions components/testing/infrastructure/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ resource "aws_security_group" "this" {
vpc_id = data.terraform_remote_state.core_infrastructure.outputs.vpc.vpc_id
}

resource "aws_security_group_rule" "ingress" {
type = "ingress"
to_port = 0
protocol = "-1"
from_port = 0
security_group_id = aws_security_group.this.id
cidr_blocks = [
"${data.terraform_remote_state.core_infrastructure.outputs.nat_instance_ip}/32",
"${data.terraform_remote_state.core_infrastructure.outputs.vpc.nat_public_ips[0]}/32",
]
}

resource "aws_security_group_rule" "egress" {
type = "egress"
to_port = 0
Expand All @@ -22,15 +34,27 @@ resource "aws_security_group_rule" "egress" {
cidr_blocks = ["0.0.0.0/0"]
}

data "aws_network_interface" "nat_instance" {
filter {
name = "tag:Name"
values = ["NAT Instance"]
}
}

resource "aws_route" "nat_instance" {
route_table_id = data.terraform_remote_state.core_infrastructure.outputs.vpc.private_route_table_ids[0]
destination_cidr_block = "${aws_instance.this.public_ip}/32"
network_interface_id = data.aws_network_interface.nat_instance.id
}

resource "aws_instance" "this" {
ami = data.aws_ssm_parameter.arm64_ami.value
instance_type = "t4g.small"
security_groups = [
aws_security_group.this.id,
]
ami = data.aws_ssm_parameter.arm64_ami.value
instance_type = "t4g.small"
vpc_security_group_ids = [aws_security_group.this.id]
subnet_id = element(data.terraform_remote_state.core_infrastructure.outputs.vpc.public_subnets, 0)
associate_public_ip_address = true
iam_instance_profile = aws_iam_instance_profile.this.id
user_data_replace_on_change = true

root_block_device {
volume_size = 100
Expand Down
2 changes: 1 addition & 1 deletion components/testing/infrastructure/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ service docker start

unzip /opt/testing/test_files.zip -d /opt/testing/tests
docker build -t "testing:latest" /opt/testing
docker run --rm -d testing:latest tail -f /dev/null
docker run --rm --net=host -d testing:latest tail -f /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ HOSTNAME=$(cat /etc/hostname)

read -p "1. Add (or modify) a SIP trunk on Somleng with the following Source IP for Inbound Dialing: $AWS_PUBLIC_IP. Press any key when done."
read -p "2. Configure the number: $DESTINATION_NUMBER on Somleng: Press any key when done."
read -p "3. Start TCP dump. In another terminal run the following: sudo docker run -it --rm --net container:$HOSTNAME nicolaka/netshoot followed by tcpdump -Xvv -i eth0 -s0 -w capture.pcap. Press any key when done."
read -p "3. Start TCP dump. In another terminal run the following: sudo docker run -it --rm --net container:$HOSTNAME nicolaka/netshoot followed by tcpdump -Xvv -i ens5 -s0 -w capture.pcap. Press any key when done."

log_file="uac_*_messages.log"
rm -f $log_file

sipp -sf scenarios/uac.xml 15.197.218.231:5080 -key username "+855715100850" -s 1234 -m 1 -trace_msg > /dev/null
sipp -sf scenarios/uac.xml 15.197.218.231:5080 -d 20000 -mi "$AWS_PUBLIC_IP" --key username "+855715100850" --key advertised_ip "$AWS_PUBLIC_IP" -s 1234 -m 1 -min_rtp_port 10000 -max_rtp_port 50000 -trace_msg > /dev/null
20 changes: 10 additions & 10 deletions components/testing/infrastructure/tests/scenarios/uac.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
<![CDATA[
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:[username]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
Via: SIP/2.0/[transport] [advertised_ip]:[local_port];branch=[branch]
From: sipp <sip:[username]@[advertised_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:[username]@[local_ip]:[local_port]
Contact: sip:[username]@[advertised_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
o=user1 53655765 2353687637 IN IP[media_ip_type] [media_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
Expand Down Expand Up @@ -70,12 +70,12 @@
<![CDATA[
ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:[username]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
Via: SIP/2.0/[transport] [advertised_ip]:[local_port];branch=[branch]
From: sipp <sip:[username]@[advertised_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: sip:[username]@[local_ip]:[local_port]
Contact: sip:[username]@[advertised_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
Expand All @@ -93,12 +93,12 @@
<![CDATA[
BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sipp <sip:[username]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
Via: SIP/2.0/[transport] [advertised_ip]:[local_port];branch=[branch]
From: sipp <sip:[username]@[advertised_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 2 BYE
Contact: sip:[username]@[local_ip]:[local_port]
Contact: sip:[username]@[advertised_ip]:[local_port]
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
Expand Down

0 comments on commit 785a4f4

Please sign in to comment.