Skip to content

Commit

Permalink
tests: Add check_uuid in tests.
Browse files Browse the repository at this point in the history
check_uuid checks that ovn-sbctl and ovn-nbctl commands return an uuid
(and not an error for instance).

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
simonartxavier authored and ovsrobot committed Jan 8, 2025
1 parent dbdd8ea commit a8ac0e8
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 279 deletions.
34 changes: 17 additions & 17 deletions tests/ovn-controller.at
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ check_patches
# Create a localnet port, but we should still have no patch ports, as they
# won't be created until there's a localnet port on a logical switch with
# another logical port bound to this chassis.
ovn-sbctl \
check_uuid ovn-sbctl \
-- --id=@dp101 create Datapath_Binding tunnel_key=101 external_ids:name=dp101 \
-- create Port_Binding datapath=@dp101 logical_port=localnet1 tunnel_key=1 \
type=localnet options:network_name=physnet1
check_patches

# Create a localnet port on a logical switch with a port bound to this chassis.
# Now we should get some patch ports created.
ovn-sbctl \
check_uuid ovn-sbctl \
-- --id=@dp102 create Datapath_Binding tunnel_key=102 external_ids:name=dp102 \
-- create Port_Binding datapath=@dp102 logical_port=localnet2 tunnel_key=1 \
type=localnet options:network_name=physnet1 \
Expand Down Expand Up @@ -953,7 +953,7 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as1
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1' drop

# Add IPs to as1 for 10 times, 1 IP each time.
Expand Down Expand Up @@ -1130,7 +1130,7 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as1
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1 && tcp && tcp.dst == {111, 222, 333}' drop

# Add IPs to as1 for 10 times, 1 IP each time.
Expand Down Expand Up @@ -1328,8 +1328,8 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
ovn-nbctl create address_set name=as2
check_uuid ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as2
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1 && ip4.dst == $as2' drop

# Add IPs to as1 and as2, with some of the IPs overlapping
Expand Down Expand Up @@ -1487,8 +1487,8 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
ovn-nbctl create address_set name=as2
check_uuid ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as2

# OR on different fields
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && (ip4.src == $as1 || ip4.dst == $as2)' drop
Expand Down Expand Up @@ -1587,8 +1587,8 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
ovn-nbctl create address_set name=as2
check_uuid ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as2

# OR on the same field
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == {$as1, $as2}' drop
Expand Down Expand Up @@ -1696,7 +1696,7 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as1
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1 && ip4.dst == $as1' drop

# Add IPs to as1 for 10 times, 1 IP each time.
Expand Down Expand Up @@ -1887,8 +1887,8 @@ read_counter() {
# 2 ASes, each has 3 IPs, no overlapping.
# 2 ACLs, each should generate a conjunction, and 1 overlapping tcp.dst
# generating a flow with combined conjunctions.
ovn-nbctl create address_set name=as1 addresses=10.0.0.11,10.0.0.12,10.0.0.13
ovn-nbctl create address_set name=as2 addresses=10.0.0.21,10.0.0.22,10.0.0.23
check_uuid ovn-nbctl create address_set name=as1 addresses=10.0.0.11,10.0.0.12,10.0.0.13
check_uuid ovn-nbctl create address_set name=as2 addresses=10.0.0.21,10.0.0.22,10.0.0.23
check ovn-nbctl acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1 && tcp && tcp.dst == {101, 102}' drop
check ovn-nbctl acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as2 && tcp && tcp.dst == {201, 202}' drop

Expand Down Expand Up @@ -2008,7 +2008,7 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as1
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && eth.src == $as1' drop

# Add MACs to as1 for 5 times.
Expand Down Expand Up @@ -2093,7 +2093,7 @@ read_counter() {
ovn-appctl -t ovn-controller coverage/read-counter $1
}

ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as1
check ovn-nbctl --wait=hv acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip6.src == $as1' drop

# Add IPs to as1 for 5 times, 1 IP each time.
Expand Down Expand Up @@ -2169,7 +2169,7 @@ ovn-appctl -t ovn-controller vlog/set file:dbg
acl_eval=$(ovn-debug lflow-stage-to-oftable ls_out_acl_eval)
acl_sample=$(ovn-debug lflow-stage-to-oftable ls_out_acl_sample)

ovn-nbctl create address_set name=as1 addresses=8.8.8.8
check_uuid ovn-nbctl create address_set name=as1 addresses=8.8.8.8
check ovn-nbctl acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1' drop
check ovn-nbctl --wait=hv sync
AT_CHECK([ovs-ofctl dump-flows br-int table=$acl_eval | grep -c "priority=1100"], [0], [1
Expand Down Expand Up @@ -2944,7 +2944,7 @@ acl_sample=$(ovn-debug lflow-stage-to-oftable ls_out_acl_sample)
dp_key=$(printf "%x" $(fetch_column datapath tunnel_key external_ids:name=ls1))
port_key=$(printf "%x" $(fetch_column port_binding tunnel_key logical_port=ls1-lp1))

ovn-nbctl create address_set name=as1
check_uuid ovn-nbctl create address_set name=as1
check ovn-nbctl acl-add ls1 to-lport 100 'outport == "ls1-lp1" && ip4.src == $as1' drop
check ovn-nbctl add address_set as1 addresses 10.0.0.0/24
check ovn-nbctl --wait=hv sync
Expand Down
2 changes: 1 addition & 1 deletion tests/ovn-ic.at
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ done

ovn_as az1

ovn-nbctl \
check_uuid ovn-nbctl \
--id=@id create logical-router-static-route ip_prefix=1.1.1.1/32 nexthop=10.0.1.10 -- \
add logical-router lr1 static_routes @id

Expand Down
9 changes: 9 additions & 0 deletions tests/ovn-macros.at
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,15 @@ check() {
AT_CHECK(["$@"])
}

# Runs COMMAND and checks that it does not print anything else than uuid as output.
# It also fails if the output is empty.
check_uuid() {
echo "$@"
output=$("${@}")
AT_CHECK([echo "$output" | grep .], [0], [ignore], [], [echo "Unexpected empty output: check_uuid is expecting a UUID"])
AT_CHECK([echo "$output" | grep -vE '^[[0-9a-fA-F]]{8}-[[0-9a-fA-F]]{4}-[[0-9a-fA-F]]{4}-[[0-9a-fA-F]]{4}-[[0-9a-fA-F]]{12}$'], [1])
}

parse_db() {
case $1 in
(*:*) echo ${1%%:*} ;;
Expand Down
10 changes: 5 additions & 5 deletions tests/ovn-nbctl.at
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,8 @@ AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])

AT_CHECK([ovn-nbctl lr-nat-del lr0])

ovn-nbctl create Address_Set name=allowed_range addresses=\"1.1.1.1\"
ovn-nbctl create Address_Set name=disallowed_range addresses=\"2.2.2.2\"
check_uuid ovn-nbctl create Address_Set name=allowed_range addresses=\"1.1.1.1\"
check_uuid ovn-nbctl create Address_Set name=disallowed_range addresses=\"2.2.2.2\"
AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 40.0.0.3 192.168.1.6])
AT_CHECK([ovn-nbctl lr-nat-update-ext-ip lr0 snat 192.168.1.6 allowed_range])
AT_CHECK([ovn-nbctl --is-exempted lr-nat-update-ext-ip lr0 snat 192.168.1.6 disallowed_range])
Expand Down Expand Up @@ -2836,19 +2836,19 @@ dnl ---------------------------------------------------------------------

OVN_NBCTL_TEST([acl_sampling], [ACL sampling operations], [
check ovn-nbctl ls-add ls
ovn-nbctl \
check_uuid ovn-nbctl \
--id=@sample1 create Sample metadata=4301 -- \
--sample-new=@sample1 acl-add ls from-lport 1 1 allow-related
sample1=$(fetch_column nb:Sample _uuid metadata=4301)
check_column "$sample1" nb:ACL sample_new priority=1

ovn-nbctl \
check_uuid ovn-nbctl \
--id=@sample2 create Sample metadata=4302 -- \
--sample-est=@sample2 acl-add ls from-lport 2 1 allow-related
sample2=$(fetch_column nb:Sample _uuid metadata=4302)
check_column "$sample2" nb:ACL sample_est priority=2

ovn-nbctl \
check_uuid ovn-nbctl \
--id=@sample3 create Sample metadata=4303 -- \
--id=@sample4 create Sample metadata=4304 -- \
--sample-new=@sample3 --sample-est=@sample4 acl-add ls from-lport 3 1 allow-related
Expand Down
Loading

0 comments on commit a8ac0e8

Please sign in to comment.