Re: [PATCH][TCK] add tests for network interface transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/24/2012 06:32 PM, Kyla Zhang wrote:
From: Xiaoqiang Hu <xhu@xxxxxxxxxx>

add tests for network interface transaction: interface_change_begin,
interface_change_commit and interface_change_rollback
---
  .../networks/110-interface-change-transaction.t    |   81 ++++++++++++++++++++
  1 files changed, 81 insertions(+), 0 deletions(-)
  create mode 100644 scripts/networks/110-interface-change-transaction.t

diff --git a/scripts/networks/110-interface-change-transaction.t b/scripts/networks/110-interface-change-transaction.t
new file mode 100644
index 0000000..f518d9f
--- /dev/null
+++ b/scripts/networks/110-interface-change-transaction.t
@@ -0,0 +1,81 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Xiaoqiang Hu <xhu@xxxxxxxxxx>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+networks/110-interface-lifecycle.t: test transaction for changing the
+configuration of one or more network interfaces
+
+=head1 DESCRIPTION
+
+The test case validates the transaction for changing the configuration
+of one or more network interfaces
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $network_script_dir = "/etc/sysconfig/network-scripts";
+my $test_interface_name = "ifcfg-interface-tck-test";
+my $test_interface_cfg = $network_script_dir."/".$test_interface_name;
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+    $tck->cleanup if $tck;
+    unlink $test_interface_cfg if -f $test_interface_cfg;
+}
+
+my $ret;
+
+unlink $test_interface_cfg if -f $test_interface_cfg;
+
+eval { $conn->interface_change_begin(); };
+SKIP: {
+    skip "interface_change_begin/commit/rollback not implemented", 2 if $@ && err_not_implemented($@);
+
+    $ret = system("cat <<EOF > $test_interface_cfg
+DEVICE=\"interface-tck-test\"
+BOOTPROTO=\"none\"
+ONBOOT=\"no\"
+EOF
+");
+
+    $conn->interface_change_rollback();
+    ok(! -e $test_interface_cfg, "interface rollback");
+
+    unlink $test_interface_cfg if -f $test_interface_cfg;
+
+    $conn->interface_change_begin();
+
+    $ret = system("cat <<EOF > $test_interface_cfg
+DEVICE=\"interface-tck-test\"
+BOOTPROTO=\"none\"
+ONBOOT=\"no\"
+EOF
+");
+
+    $conn->interface_change_commit();
+    ok(-e $test_interface_cfg, "interface commit");
+}
+
+# end

    ACK.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]