[go: up one dir, main page]

File: xml.t

package info (click to toggle)
rex 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,800 kB
  • sloc: perl: 30,667; xml: 264; makefile: 8
file content (64 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use Test::More tests => 6;
use FindBin qw($Bin);
use Rex::Require;

SKIP: {

  eval { XML::LibXML->require };
  skip 'Missing XML::LibXML for XML file support.', 6 if $@;

  require Rex::Group::Lookup::XML;
  Rex::Group::Lookup::XML->import;

  use Rex::Group;
  use Rex::Commands;

  no warnings 'once';

  $::QUIET = 1;

  groups_xml("$Bin/test.xml");
  my %groups = Rex::Group->get_groups;

  # stringification needed for is_deeply string comparison
  my @application_server = map { "$_" } @{ $groups{application} };

  is( scalar( @{ $groups{application} } ), 2, "2 application servers" );
  is_deeply(
    [ sort @application_server ],
    [qw/machine01 machine02/],
    "got machine02,machine01"
  );
  is( scalar( @{ $groups{profiler} } ), 2, "2 profiler servers 2" );

  my ($server1) = grep { m/\bmachine07\b/ } @{ $groups{profiler} };
  my ($server2) = grep { m/\bmachine01\b/ } @{ $groups{application} };

  Rex::TaskList->create()->set_in_transaction(1);
  no_ssh(
    task(
      "xml_task1",
      $server1,
      sub {
        is( connection()->server->option("services"),
          "nginx,docker", "got services inside task" );
      }
    )
  );
  Rex::Commands::do_task("xml_task1");

  no_ssh(
    task(
      "xml_task2",
      $server2,
      sub {
        is( connection()->server->get_user(),
          'root', "$server2 user is 'root'" );
        is( connection()->server->get_password(),
          'foob4r', "$server2 password is 'foob4r'" );
      }
    )
  );
  Rex::Commands::do_task("xml_task2");
  Rex::TaskList->create()->set_in_transaction(0);
}