Skip to content

Commit

Permalink
added sleep time 10 seconds within rspec test to ensure process are r… (
Browse files Browse the repository at this point in the history
#351)

* added sleep time 10 seconds within rspec test to ensure process are ready to capture pcap

* Delete scripts/wait_for_dhcp_server.sh

---------

Co-authored-by: Jahir <[email protected]>
  • Loading branch information
juddin927 and juddin927 authored Jun 11, 2024
1 parent 5ac79eb commit 2aeeb73
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions dhcp-service/spec/lease_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,43 @@
db_client[:lease4].truncate
db_client.disconnect
Process.fork { `tshark -iany -f 'ip src 172.1.0.10 and udp port 67' -w ./dhcp_offer_packet.pcap -q -a packets:1` }
sleep 5 # Adding a delay to ensure the process is ready
end

after { db_client.disconnect }

# context "when ordinary dhcp clients send DHCP requests" do
# it "provides 10 leases to 10 clients, leases persist in the DB and provides DHCP options from global options" do
# `perfdhcp -r 2 \
# -n 10 \
# -R 10 \
# -d 2 \
# -4 \
# -W 20000000 \
# 172.1.0.10`
#
# expect(db_client[:lease4].count).to eq(10)
# expect(dhcp_offer_packet_content).to include(File.read("./spec/fixtures/expected_lease_options_ordinary.txt"))
# expect(dhcp_offer_packet_content).not_to include("Option: (234) Private")
# end
# end
#
# context "when Windows 10 devices with client class value of 'W10TEST' send DHCP requests" do
# it "provides a lease with DHCP options from global options but overrides dns-name option from client class options" do
# `perfdhcp -r 2 \
# -n 3 \
# -R 1 \
# -b mac=00:0c:01:02:03:04 \
# -d 2 \
# -4 \
# -o 77,57313054455354 \
# -W 20000000 \
# 172.1.0.10`
#
# expect(dhcp_offer_packet_content).to include(File.read("./spec/fixtures/expected_lease_options_client_class.txt"))
# end
# end
context "when ordinary dhcp clients send DHCP requests" do
it "provides 10 leases to 10 clients, leases persist in the DB and provides DHCP options from global options" do
`perfdhcp -r 2 \
-n 10 \
-R 10 \
-d 2 \
-4 \
-W 20000000 \
172.1.0.10`
sleep 10
# tshark -r dhcp_offer_packet.pcap -V
expect(db_client[:lease4].count).to eq(10)
expect(dhcp_offer_packet_content).to include(File.read("./spec/fixtures/expected_lease_options_ordinary.txt"))
expect(dhcp_offer_packet_content).not_to include("Option: (234) Private")
end
end

context "when Windows 10 devices with client class value of 'W10TEST' send DHCP requests" do
it "provides a lease with DHCP options from global options but overrides dns-name option from client class options" do
`perfdhcp -r 2 \
-n 3 \
-R 1 \
-b mac=00:0c:01:02:03:04 \
-d 2 \
-4 \
-o 77,57313054455354 \
-W 20000000 \
172.1.0.10`
sleep 5
expect(dhcp_offer_packet_content).to include(File.read("./spec/fixtures/expected_lease_options_client_class.txt"))
end
end

context "when Windows 10 devices with delivery optimisation enabled send DHCP requests" do
it "provides a lease with DHCP options from global options as well as an additional option: private option 234" do
Expand All @@ -57,7 +59,7 @@
-o 55,00EA \
-W 20000000 \
172.1.0.10`

sleep 5
expect(dhcp_offer_packet_content).to include(File.read("./spec/fixtures/expected_lease_options_delivery_optimised.txt"))
end
end
Expand Down

0 comments on commit 2aeeb73

Please sign in to comment.