[lxc-devel] [lxd/master] Various test bugfixes and typo fixes

stgraber on Github lxc-bot at linuxcontainers.org
Thu Nov 29 21:08:04 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181129/f2338ec4/attachment.bin>
-------------- next part --------------
From 21657bf1df0ebfa77b762304d39a0e9afcb7d53e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 28 Nov 2018 21:45:56 -0500
Subject: [PATCH 1/4] tests: Always pass -w to iptables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 test/includes/clustering.sh | 23 ++---------------------
 test/suites/proxy.sh        | 24 ++++++++++++------------
 2 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/test/includes/clustering.sh b/test/includes/clustering.sh
index 8da0034503..7ce460058c 100644
--- a/test/includes/clustering.sh
+++ b/test/includes/clustering.sh
@@ -9,16 +9,7 @@ setup_clustering_bridge() {
   ip addr add 10.1.1.1/16 dev "${name}"
 
   # shellcheck disable=SC2039
-  for i in {1..5}; do
-      # Retry a few times since the xtables lock might be hold.
-      if iptables -t nat -A POSTROUTING -s 10.1.0.0/16 -d 0.0.0.0/0 -j MASQUERADE; then
-        break
-      fi
-      if [ "$i" -eq 5 ]; then
-        return 1
-      fi
-      sleep 0.1
-  done
+  iptables -w -t nat -A POSTROUTING -s 10.1.0.0/16 -d 0.0.0.0/0 -j MASQUERADE
   echo 1 > /proc/sys/net/ipv4/ip_forward
 }
 
@@ -28,17 +19,7 @@ teardown_clustering_bridge() {
   if [ -e "/sys/class/net/${name}" ]; then
       echo "==> Teardown clustering bridge ${name}"
       echo 0 > /proc/sys/net/ipv4/ip_forward
-      # shellcheck disable=SC2039
-      for i in {1..5}; do
-          # Retry a few times since the xtables lock might be hold.
-          if iptables -t nat -A POSTROUTING -s 10.1.0.0/16 -d 0.0.0.0/0 -j MASQUERADE; then
-              break
-          fi
-          if [ "$i" -eq 5 ]; then
-              return 1
-          fi
-          sleep 0.1
-      done
+      iptables -w -t nat -A POSTROUTING -s 10.1.0.0/16 -d 0.0.0.0/0 -j MASQUERADE
       ip link del dev "${name}"
   fi
 }
diff --git a/test/suites/proxy.sh b/test/suites/proxy.sh
index 5cd353b1bf..a4b37cd5b1 100644
--- a/test/suites/proxy.sh
+++ b/test/suites/proxy.sh
@@ -104,45 +104,45 @@ test_proxy_device_tcp() {
   lxc config device set nattest eth0 ipv6.address "${v6_addr}"
 
   lxc start nattest
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   lxc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234" connect="tcp:${v4_addr}:1234" bind=host
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   # enable NAT
   lxc config device set nattest validNAT nat true
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 2 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 2 ]
 
   lxc config device remove nattest validNAT
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   lxc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234-1235" connect="tcp:${v4_addr}:1234" bind=host nat=true
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 4 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 4 ]
 
   lxc config device remove nattest validNAT
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   lxc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234-1235" connect="tcp:${v4_addr}:1234-1235" bind=host nat=true
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 4 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 4 ]
 
   lxc config device remove nattest validNAT
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   # IPv6 test
   lxc config device add nattest validNAT proxy listen="tcp:[::1]:1234" connect="tcp:[::]:1234" bind=host nat=true
-  [ "$(ip6tables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 2 ]
+  [ "$(ip6tables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 2 ]
 
   lxc config device unset nattest validNAT nat
-  [ "$(ip6tables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(ip6tables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   lxc config device remove nattest validNAT
 
   # This won't enable NAT
   lxc config device add nattest invalidNAT proxy listen="tcp:127.0.0.1:1234" connect="udp:${v4_addr}:1234" bind=host
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (invalidNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (invalidNAT)")" -eq 0 ]
 
   lxc delete -f nattest
-  [ "$(iptables -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
+  [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ]
 
   lxc network delete lxdt$$
 }

From 7555f492a4cb570e1d812ef5a7a70022af5aa2fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 28 Nov 2018 21:55:00 -0500
Subject: [PATCH 2/4] lxd/migration: Remove leftover debugging
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/migrate_container.go | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index a3dae97243..5ae8bb5282 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -1161,7 +1161,6 @@ func migrationCompareSnapshots(sourceSnapshots []*migration.Snapshot, targetSnap
 	toSync := []*migration.Snapshot{}
 
 	for _, snap := range sourceSnapshots {
-		logger.Errorf("source snap: %v", snap.GetName())
 		snapName := snap.GetName()
 
 		sourceSnapshotsTime[snapName] = snap.GetCreationDate()

From 28f8b5ed45f16238f2bcbf67c8351ec7798234c9 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Mon, 26 Nov 2018 11:29:18 +0100
Subject: [PATCH 3/4] lxd/db: Fix unit test not actually checking error

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/db/node/update_test.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/db/node/update_test.go b/lxd/db/node/update_test.go
index 36d3d2136e..a99fd96dfc 100644
--- a/lxd/db/node/update_test.go
+++ b/lxd/db/node/update_test.go
@@ -28,7 +28,7 @@ func TestUpdateFromV36_DropTables(t *testing.T) {
 	require.NoError(t, err)
 
 	var current []string
-	query.Transaction(db, func(tx *sql.Tx) error {
+	err = query.Transaction(db, func(tx *sql.Tx) error {
 		var err error
 		stmt := "SELECT name FROM sqlite_master WHERE type='table'"
 		current, err = query.SelectStrings(tx, stmt)

From 0c6568d109e68c441ce6c43f6497878e835a709c Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Wed, 28 Nov 2018 14:16:51 +0100
Subject: [PATCH 4/4] lxd/db: Fix typo in existing docstring

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/db/raft.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/db/raft.go b/lxd/db/raft.go
index beb8e29250..4fb4116ca5 100644
--- a/lxd/db/raft.go
+++ b/lxd/db/raft.go
@@ -61,7 +61,7 @@ func (n *NodeTx) RaftNodeAddress(id int64) (string, error) {
 	}
 }
 
-// RaftNodeFirst adds a the first node if the cluster. It ensures that the
+// RaftNodeFirst adds a the first node of the cluster. It ensures that the
 // database ID is 1, to match the server ID of first raft log entry.
 //
 // This method is supposed to be called when there are no rows in raft_nodes,


More information about the lxc-devel mailing list