Skip to content

Commit

Permalink
Add expected outcomes for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcronenberg committed Oct 12, 2023
1 parent 7b9a3f7 commit 01c3419
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[connection]
id=bond0
uuid=a6902e59-964b-4651-b8d8-ffe67658ae9a
type=bond
interface-name=bond0

[bond]
miimon=100
mode=active-backup
primary=en0

[match]

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[connection]
id=en0
uuid=38d979e6-aa0e-4bae-8cff-a6dda281d0c7
type=ethernet
interface-name=en0
master=bond0
slave-type=bond

[ethernet]

[match]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[connection]
id=en1
uuid=9269bbb4-a771-406f-ba66-3f65ed15634c
type=ethernet
interface-name=en1
master=bond0
slave-type=bond

[ethernet]

[match]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[connection]
id=eth0
uuid=a123047b-232e-4b86-9f69-851e7690deaa
type=ethernet
interface-name=eth0

[ethernet]

[match]

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[connection]
id=eth1
uuid=4935f592-3e86-491b-847b-2ce4f180001c
type=ethernet
interface-name=eth1

[ethernet]

[match]

[ipv4]
address1=192.168.100.5/24
address2=192.168.101.5/24
method=manual

[ipv6]
addr-gen-mode=default
method=auto

[proxy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[connection]
id=eth2
uuid=85378eec-2abb-4cbb-a3d3-69c10921b2e0
type=ethernet
interface-name=eth2

[ethernet]

[match]

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[connection]
id=eth3
uuid=ee291fe1-7dd3-4376-9c63-4228fab9df27
type=ethernet
interface-name=eth3

[ethernet]

[match]

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[connection]
id=eth4
uuid=79dac508-d8ae-4bae-82bc-8590c9e501cd
type=ethernet
interface-name=eth4

[ethernet]

[match]

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
address1=2001:db8:0:1::5/64
address2=2001:db8:0:2::5/64
method=manual

[proxy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[connection]
id=eth0
uuid=676a03ec-54a6-4e45-b7ab-2eb0e1c18a75
type=ethernet
interface-name=eth0

[ethernet]

[match]

[ipv4]
address1=192.168.101.5/24,192.168.102.1
address2=192.168.102.5/24
method=manual

[ipv6]
addr-gen-mode=default
address1=2001:db8:1::5/64,2001:db8:1::1
method=manual

[proxy]
52 changes: 52 additions & 0 deletions rust/agama-migrate-wicked/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
TEST_DIRS=$(ls -d */)
RESULT=0
MIGRATE_WICKED_BIN=../../target/debug/migrate-wicked

error_msg() {
echo -e "${RED}Test $1: $2${NC}"
}

if [[ $(ls -A /etc/NetworkManager/system-connections/) ]]; then
echo -e "${RED}There are already NM connections. You may be running this script on a live system, which is highly discouraged!${NC}"
exit 1
fi

if [ ! -f $MIGRATE_WICKED_BIN ]; then
echo -e "${RED}No migrate-wicked binary found${NC}"
exit 1
fi

for TEST_DIR in ${TEST_DIRS}; do
$MIGRATE_WICKED_BIN show $TEST_DIR/wicked_xml
if [ $? -ne 0 ]; then
error_msg ${TEST_DIR/\//} "Show command failed"
RESULT=1
fi
$MIGRATE_WICKED_BIN migrate $TEST_DIR/wicked_xml
if [ $? -ne 0 ]; then
error_msg ${TEST_DIR/\//} "Migration failed"
RESULT=1
continue
fi
for cmp_file in $(ls $TEST_DIR/system-connections/); do
diff --unified=0 -I uuid $TEST_DIR/system-connections/$cmp_file /etc/NetworkManager/system-connections/${cmp_file/\./\*.}
if [ $? -ne 0 ]; then
error_msg ${TEST_DIR/\//} "NM Connection $cmp_file didn't match\n"
RESULT=1
else
echo -e "${GREEN}Migration for connection ${cmp_file/\.*/} successful${NC}\n"
fi
done
rm -f /etc/NetworkManager/system-connections/*
done

if [ $RESULT -eq 0 ]; then
echo -e "${GREEN}All tests successful${NC}"
else
echo -e "${RED}Some tests were unsuccessful${NC}"
fi
exit $RESULT

0 comments on commit 01c3419

Please sign in to comment.