8 eval { require WWW
::Mechanize
};
10 warn "\nCannot load WWW::Mechanize. "
11 . "\nPlease install it before using smolder_smoke_signal.\n";
24 ./bin/smolder_smoke_signal --server smolder.foo.com \
25 --username myself --password s3cr3t --file test_report.xml \
30 Script used to upload a Smoke test report to a running smolder server.
31 This is extremely useful for scripted/automatic test runs but also
32 helpful when using a CLI makes things faster.
42 This is the hostname (and port if not 80) of the running Smolder server.
46 The name of the Smolder project to use for the upload.
50 The name of the Smolder user to use for the upload.
54 The password for the Smolder user given by C<username>.
58 The name of the file to upload. Please see F<docs/upload_file_format.pod>
59 for more details about the format that Smolder expects this file to
70 If your Smolder server is running on a port other than 80, then you
75 The architecture for the given smoke test run. If none is given
76 it will use the default architecture for the project.
80 The platform for the given smoke test run. If none is given
81 it will use the default platform for the project.
85 The revision control number for this test run. Only applies to
86 projects that use revision control (shouldn't they all) and only
87 applies to tests run against a checkout from revision control.
89 This is just a free form text option so it will work with any
90 revision number that your preferred revision control system uses.
94 A comma separated list of tags that are given for this smoke report run.
96 ./bin/smolder_smoke_signal --server smolder.foo.com \
97 --username myself --password s3cr3t --file test_report.xml \
98 --project MyProject --tags "Foo, My Bar"
102 Any comments that you want to associate with the smoke test run.
106 Print verbose output of our actions to STDOUT.
111 my ($server, $project, $user, $pw, $file, $arch, $platform, $tags, $comments, $verbose, $rev,
116 'server=s' => \
$server,
118 'project=s' => \
$project,
119 'username=s' => \
$user,
120 'password=s' => \
$pw,
122 'architecture=s' => \
$arch,
123 'platform=s' => \
$platform,
125 'comments=s' => \
$comments,
126 'revision=s' => \
$rev,
127 'verbose!' => \
$verbose,
144 # make sure all the required fields are there
145 _missing_required
('server') unless $server;
146 _missing_required
('project') unless $project;
147 _missing_required
('username') unless $user;
148 _missing_required
('password') unless $pw;
149 _missing_required
('file') unless $file;
151 # make sure our file is there and is of the right type
153 unless ($file =~ /\.tar(\.gz)?$/) {
154 warn "File '$file' is not of the correct type!\n";
158 warn "File '$file' does not exist, or is not readable!\n";
162 # try and reach the smolder server
163 print "Trying to reach Smolder server at $server.\n" if ($verbose);
165 my $mech = WWW
::Mechanize
->new();
166 my $base_url = "http://$server:$port/app";
167 eval { $mech->get($base_url) };
168 unless ($mech->status eq '200') {
169 warn "Could not reach $server:$port successfully. Received status " . $mech->status . "\n";
174 print "Trying to login with username '$user'.\n" if ($verbose);
175 $mech->get($base_url . '/public_auth/login');
176 my $form = $mech->form_name('login');
177 if ($mech->status ne '200' || !$form) {
178 warn "Could not reach Smolder login form. Are you sure $server:$port is a Smolder server?\n";
186 my $content = $mech->content;
187 if ($mech->status ne '200' || $content !~ /Welcome \Q$user\E/) {
188 warn "Could not login with username '$user' and password '$pw'!\n";
192 # now go to this project's page
193 print "Retrieving project listing for user '$user'.\n" if ($verbose);
194 $mech->get($base_url . '/developer_projects');
195 $content = $mech->content;
196 $content =~ />\Q$project\E<!--ID:(\d+)-->/;
198 if ($mech->status ne '200' || !$project_id) {
199 warn "Could not get your project listing, or you are not a member of the '$project' project!\n";
203 # now go to the add-smoke-report page for this project
204 print "Adding smoke report to project '$project'.\n" if ($verbose);
205 $mech->get($base_url . "/developer_projects/add_report/$project_id");
206 $content = $mech->content;
207 if ($mech->status ne '200' || $content !~ /New Smoke Report/) {
208 warn "Could not reach the Add Smoke Report form!\n";
211 $mech->form_name('add_report');
212 my %fields = (report_file
=> $file);
213 $fields{platform
} = $platform if $platform;
214 $fields{architecture
} = $arch if $arch;
215 $fields{tags
} = $tags if $tags;
216 $fields{comments
} = $comments if $comments;
217 $fields{revision
} = $rev if $rev;
218 $mech->set_fields(%fields);
221 $content = $mech->content;
222 if ($mech->status ne '200' || $content !~ /Recent Smoke Reports/) {
223 warn "Could not upload smoke report with the given information!\n";
226 $content =~ /#(\d+) Added/;
229 print "\nReport successfully uploaded as #$report_id.\n";
231 ##########################################################
233 ##########################################################
234 sub _missing_required
{
236 warn "Missing required field '$field'!\n";