1BEAKERLIB.SH(1)       User Contributed Perl Documentation      BEAKERLIB.SH(1)
2
3
4

NAME

6       BeakerLib - a shell-level integration testing library
7

DESCRIPTION

9       BeakerLib is a shell-level integration testing library, providing
10       convenience functions which simplify writing, running and analysis of
11       integration and blackbox tests.
12
13       The essential features include:
14
15       ·   Journal - uniform logging mechanism (logs & results saved in
16           flexible XML format, easy to compare results & generate reports)
17
18       ·   Phases - logical grouping of test actions, clear separation of
19           setup / test / cleanup (preventing false fails)
20
21       ·   Asserts - common checks affecting the overall results of the
22           individual phases (checking for exit codes, file existence &
23           content...)
24
25       ·   Helpers - convenience functions for common operations such as
26           managing services, backup & restore
27
28       The main script sets the "BEAKERLIB" variable and sources other scripts
29       where the actual functions are defined. You should source it at the
30       beginning of your test with:
31
32           . /usr/lib/beakerlib/beakerlib.sh
33
34       See the EXAMPLES section for quick start inspiration.
35

EXAMPLES

37   Simple
38       A minimal BeakerLib test can look like this:
39
40           . /usr/lib/beakerlib/beakerlib.sh
41
42           rlJournalStart
43               rlPhaseStartTest
44                   rlAssertRpm "setup"
45                   rlAssertExists "/etc/passwd"
46                   rlAssertGrep "root" "/etc/passwd"
47               rlPhaseEnd
48           rlJournalEnd
49
50   Phases
51       Here comes a bit more interesting example of a test which sets all the
52       recommended variables and makes use of the phases:
53
54           # Include the BeakerLib environment
55           . /usr/lib/beakerlib/beakerlib.sh
56
57           # Set the full test name
58           TEST="/examples/beakerlib/Sanity/phases"
59
60           # Package being tested
61           PACKAGE="coreutils"
62
63           rlJournalStart
64               # Setup phase: Prepare test directory
65               rlPhaseStartSetup
66                   rlAssertRpm $PACKAGE
67                   rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
68                   rlRun "pushd $TmpDir"
69               rlPhaseEnd
70
71               # Test phase: Testing touch, ls and rm commands
72               rlPhaseStartTest
73                   rlRun "touch foo" 0 "Creating the foo test file"
74                   rlAssertExists "foo"
75                   rlRun "ls -l foo" 0 "Listing the foo test file"
76                   rlRun "rm foo" 0 "Removing the foo test file"
77                   rlAssertNotExists "foo"
78                   rlRun "ls -l foo" 2 "Listing foo should now report an error"
79               rlPhaseEnd
80
81               # Cleanup phase: Remove test directory
82               rlPhaseStartCleanup
83                   rlRun "popd"
84                   rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
85               rlPhaseEnd
86           rlJournalEnd
87
88           # Print the test report
89           rlJournalPrintText
90
91       The ouput of the rlJournalPrintText command would produce an output
92       similar to the following:
93
94           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
95           :: [   LOG    ] :: TEST PROTOCOL
96           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
97
98           :: [   LOG    ] :: Test run ID   : debugging
99           :: [   LOG    ] :: Package       : coreutils
100           :: [   LOG    ] :: Installed:    : coreutils-7.6-9.fc12.i686
101           :: [   LOG    ] :: Test started  : 2010-02-08 14:55:44
102           :: [   LOG    ] :: Test finished : 2010-02-08 14:55:50
103           :: [   LOG    ] :: Test name     : /examples/beakerlib/Sanity/phases
104           :: [   LOG    ] :: Distro:       : Fedora release 12 (Constantine)
105           :: [   LOG    ] :: Hostname      : localhost
106           :: [   LOG    ] :: Architecture  : i686
107
108           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
109           :: [   LOG    ] :: Test description
110           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
111
112           PURPOSE of /examples/beakerlib/Sanity/phases
113           Description: Testing BeakerLib phases
114           Author: Petr Splichal <psplicha@redhat.com>
115
116           This example shows how the phases work in the BeakerLib on a
117           trivial smoke test for the "touch", "ls" and "rm" commands from
118           the coreutils package.
119
120
121           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
122           :: [   LOG    ] :: Setup
123           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
124
125           :: [   PASS   ] :: Checking for the presence of coreutils rpm
126           :: [   PASS   ] :: Creating tmp directory
127           :: [   PASS   ] :: Running 'pushd /tmp/tmp.IcluQu5GVS'
128           :: [   LOG    ] :: Duration: 0s
129           :: [   LOG    ] :: Assertions: 3 good, 0 bad
130           :: [   PASS   ] :: RESULT: Setup
131
132           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
133           :: [   LOG    ] :: Test
134           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
135
136           :: [   PASS   ] :: Creating the foo test file
137           :: [   PASS   ] :: File foo should exist
138           :: [   PASS   ] :: Listing the foo test file
139           :: [   PASS   ] :: Removing the foo test file
140           :: [   PASS   ] :: File foo should not exist
141           :: [   PASS   ] :: Listing foo should now report an error
142           :: [   LOG    ] :: Duration: 1s
143           :: [   LOG    ] :: Assertions: 6 good, 0 bad
144           :: [   PASS   ] :: RESULT: Test
145
146           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
147           :: [   LOG    ] :: Cleanup
148           ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
149
150           :: [   PASS   ] :: Running 'popd'
151           :: [   PASS   ] :: Removing tmp directory
152           :: [   LOG    ] :: Duration: 1s
153           :: [   LOG    ] :: Assertions: 2 good, 0 bad
154           :: [   PASS   ] :: RESULT: Cleanup
155
156       Note that the detailed test description is read from a separate file
157       PURPOSE placed in the same directory as the test itself.
158
160       Project Page
161           https://fedorahosted.org/beakerlib/
162
163       Manual
164           https://fedorahosted.org/beakerlib/wiki/Manual
165
166       Reporting bugs
167           TODO
168

AUTHORS

170       ·   Petr Muller <pmuller@redhat.com>
171
172       ·   Ondrej Hudlicky <ohudlick@redhat.com>
173
174       ·   Jan Hutar <jhutar@redhat.com>
175
176       ·   Petr Splichal <psplicha@redhat.com>
177
178       ·   Ales Zelinka <azelinka@redhat.com>
179
180
181
182perl v5.10.1                      2010-05-12                   BEAKERLIB.SH(1)
Impressum