None of these appear to be used by any tests currently in "master".
Signed-off-by: Nathan Cutler <ncutler@suse.com>
+++ /dev/null
-#! /usr/bin/perl
-=head1 NAME
-
-S3Lib.pm - Perl Module that contains the functions used by S3 test scripts for testing Rados gateway.
-
-=cut
-
-package S3Lib;
-use Cwd;
-use Exporter;
-@ISA = 'Exporter';
-@EXPORT_OK = qw(display_ceph_os_info get_timestamp get_hostname get_user_info $rgw_user delete_user _write_log_entry _exit_result get_status);
-
-#==variables ===
-my $rgw_user = "qa_user";
-my $sec;
-my $min;
-my $hour;
-my $mon;
-my $year;
-my $mday;
-my $wday;
-my $yday;
-my $isdst;
-
-# function to get the current time stamp from the test set up
-sub get_timestamp {
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
- if ($mon < 10) { $mon = "0$mon"; }
- if ($hour < 10) { $hour = "0$hour"; }
- if ($min < 10) { $min = "0$min"; }
- if ($sec < 10) { $sec = "0$sec"; }
- $year=$year+1900;
- return $year . '_' . $mon . '_' . $mday . '__' . $hour . '_' . $min . '_' . $sec;
-}
-
-# Function to get the Ceph and distro info
-sub ceph_os_info
-{
- my $ceph_v = get_command_output ( "ceph -v" );
- my @ceph_arr = split(" ",$ceph_v);
- $ceph_v = "Ceph Version: $ceph_arr[2]";
- my $os_distro = get_command_output ( "lsb_release -d" );
- my @os_arr = split(":",$os_distro);
- $os_distro = "Linux Flavor:$os_arr[1]";
- return ($ceph_v, $os_distro);
-}
-
-# Function to log ceph info to log file
-sub display_ceph_os_info
-{
- my ($vceph, $vos) = ceph_os_info();
- my $msg = "The Tests are running on";
- _write_log_entry ( "$msg\n$vos$vceph" );
-}
-
-# function to execute the command and return output
-sub get_cmd_op
-{
- my $cmd = shift;
- my $excmd = `$cmd`;
- return $excmd;
-}
-
-# Function to check if radosgw is already running
-sub get_status {
- my $service = "radosgw";
- my $cmd = "ps -ef | grep $service | grep -v grep";
- my $status = get_cmd_op($cmd);
- if ($status =~ /client.radosgw.gateway/ ){
- return 0;
- }
- return 1;
-}
-
-#Function that executes the CLI commands and returns the output of the command
-
-sub get_command_output {
- my $cmd_output = shift;
- open( FH, ">>$test_log" );
- print FH "\"$cmd_output\"\n";
- my $exec_cmd = `$cmd_output 2>&1`;
- print FH "$exec_cmd\n";
- close(FH);
- return $exec_cmd;
-}
-
-# Function that enters the given msg to log.txt
-
-sub _write_log_entry {
- my $logmsg = shift;
- open(TC,'>>log.txt');
- print TC "[Log] $logmsg\n";
- close(TC);
-}
-
-# Function that creates the test_completed.txt and reports success/failure to log.txt as required by xstudio run at the end of the test
-
-sub _exit_result {
- my $exit_status = shift;
- my $REPORT_LOG = "SUCCESS";
- open (TCOMP, '>>test_completed.txt');
- close (TCOMP);
- if ($exit_status != 0) {
- $REPORT_LOG = "FAILURE";
- }
- open(TC,'>>log.txt');
- print TC "[$REPORT_LOG]\n";
- close(TC);
- exit($exit_status);
-}
-
-# Function to create the user "qa_user" and extract the user access_key and secret_key of the user
-sub get_user_info
-{
- my $cmd = "sudo radosgw-admin user create --uid=$rgw_user --display-name=$rgw_user";
- my $cmd_op = get_command_output($cmd);
- if ($cmd_op !~ /keys/){
- _write_log_entry( "user $rgw_user NOT created" );
- return (0,0);
- }
- _write_log_entry( "user $rgw_user created" );
- my @get_user = (split/,/,$cmd_op);
- foreach (@get_user) {
- if ($_ =~ /access_key/ ){
- $get_acc_key = $_;
- } elsif ($_ =~ /secret_key/ ){
- $get_sec_key = $_;
- }
- }
- my $access_key = $get_acc_key;
- my $acc_key = (split /:/, $access_key)[1];
- $acc_key =~ s/\\//g;
- $acc_key =~ s/ //g;
- $acc_key =~ s/"//g;
- my $secret_key = $get_sec_key;
- my $sec_key = (split /:/, $secret_key)[1];
- chop($sec_key);
- chop($sec_key);
- $sec_key =~ s/\\//g;
- $sec_key =~ s/ //g;
- $sec_key =~ s/"//g;
- return ($acc_key, $sec_key);
-}
-
-# Function that deletes the user $rgw_user and write to logfile.
-sub delete_user
-{
- my $cmd = "sudo radosgw-admin user rm --uid=$rgw_user";
- my $cmd_op = get_command_output($cmd);
- if ($cmd_op !~ /aborting/){
- _write_log_entry( "user $rgw_user deleted" );
- } else {
- _write_log_entry( "user $rgw_user NOT deleted" );
- }
-}
-
-# Function to get the hostname
-sub get_hostname
-{
- my $cmd = "hostname";
- my $get_host = get_command_output($cmd);
- chomp($get_host);
- return($get_host);
-}
-1;
+++ /dev/null
-#!/usr/bin/perl
-use Amazon::S3;
-use Data::Dumper;
-use strict;
-use IO::File;
-use Getopt::Long;
-use Digest::MD5;
-use S3Lib qw(get_hostname get_user_info $rgw_user delete_user _write_log_entry _exit_result);
-
-my $exit_status=0;
-my $tc;
-my $mytestfilename;
-my $logmsg;
-my $kruft;
-my $counter;
-my $fillfile;
-my $maxcount=1000;
-my $sec;
-my $min;
-my $hour;
-my $mon;
-my $year;
-my $mday;
-my $wday;
-my $yday;
-my $isdst;
-my $s3;
-my $domain = "front.sepia.ceph.com";
-my $host = get_hostname();
-chomp($host);
-my $hostname = "$host.$domain";
-
-
-sub _exit_result {
- open (TCOMP, '>>test_completed.txt');
- close (TCOMP);
- exit($exit_status);
-}
-
-sub _write_log_entry {
- open(TC,'>>log.txt');
- print TC "[Log] $logmsg\n";
- close(TC);
-}
-
-
-sub get_timestamp {
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
- if ($mon < 10) { $mon = "0$mon"; }
- if ($hour < 10) { $hour = "0$hour"; }
- if ($min < 10) { $min = "0$min"; }
- if ($sec < 10) { $sec = "0$sec"; }
- $year=$year+1900;
-
- return $year . '_' . $mon . '_' . $mday . '__' . $hour . '_' . $min . '_' . $sec
-}
-
-#
-# one time write to log with ceph version
-#
-open (TC,'>>log.txt');
-print TC "[Log] ";
-system ("ceph -v >> log.txt");
-
-#**************************************************************************
-# Modify access keys to suit the target account
-
-my ($access_key, $secret_key) = get_user_info();
-if ( ($access_key) && ($secret_key) ) {
-
-# Make S3 connection
-# modify the host name if this test is run outside of QA.
-
- $s3 = Amazon::S3->new(
- { aws_access_key_id => $access_key,
- aws_secret_access_key => $secret_key,
- host => $hostname,
- secure => 0,
- retry => 1,
- }
- );
-
-}
-#**************************************************************************
- # List the existing buckets
- my $response = $s3->buckets;
- foreach my $bucket ( @{ $response->{buckets} } ) {
- print "You have a bucket: " . $bucket->bucket . "\n";
- }
-
- # create a new bucket (the test bucket)
- my $bucketname = 'kftestbucket' . get_timestamp();
- print "Attempting to create bucket = $bucketname\n";
-
- my $bucket = $s3->add_bucket( { bucket => $bucketname } )
- or die $s3->err . $s3->errstr;
- print "Bucket Created: $bucketname\n";
- $logmsg = "Bucket Created: $bucketname (add_bucket)";
- _write_log_entry();
-
-
- # create files in the bucket
-
-print "Generating files....\n";
-for($counter = 1; $counter <= $maxcount; $counter++){
- $fillfile = 'bogus'.$counter;
- $bucket->add_key( $fillfile, 'this is file #$counter' )
- or die $s3->err . ": " . $s3->errstr;
- if ($counter%10 == 0){print "Created $counter files...\n"}
-}
-
- $logmsg = "$maxcount files created in bucket $bucketname (add_key)";
- _write_log_entry();
-
-
- # list files in the bucket and count them - must be = max count
- print "Verifying correct number of files created....\n";
- $counter=0;
- $response = $bucket->list_all
- or die $s3->err . ": " . $s3->errstr;
- foreach my $key ( @{ $response->{keys} } ) {
- my $key_name = $key->{key};
- my $key_size = $key->{size};
-# print "Bucket contains key '$key_name' of size $key_size\n";
- $counter = $counter + 1;
- }
- $logmsg = "list_all method successful";
- _write_log_entry();
- if ($counter==$maxcount) {
- $logmsg = "File count verified = $maxcount - Pass";
- _write_log_entry();
- }
- else {
- $logmsg = "[Log] File count fail $counter vs $maxcount";
- _write_log_entry();
- $exit_status=3;
- }
-
-
- # delete files in the bucket
- print "Deleting $maxcount files...\n";
- $response = $bucket->list_all
- or die $s3->err . ": " . $s3->errstr;
- foreach my $key ( @{ $response->{keys} } ) {
-
- my $key_name = $key->{key};
- $bucket->delete_key($key_name) or die $s3->err . ": " . $s3->errstr;
- }
- $logmsg = "$maxcount files deleted (delete_key)";
- _write_log_entry();
-
-
- # and finally delete the bucket
- $bucket->delete_bucket or die $s3->err . ": " . $s3->errstr;
- $logmsg = "Test bucket deleted (delete_bucket)";
- _write_log_entry();
-
-delete_user();
-
-if ($exit_status == 0){
- open(TC,'>>log.txt');
- print TC "[Success]\n";
- close(TC);
- _exit_result();
-} else {
- open(TC,'>>log.txt');
- print TC "[Failure]\n";
- close(TC);
- _exit_result();
-}
-
+++ /dev/null
-#! /usr/bin/perl
-
-=head1 NAME
-
-rgw_install_config.pl - Script to install and configure the rados gateway on client machine.
-
-=head1 SYNOPSIS
-
-Use:
- perl rgw_install_config.pl [--help]
-
-Examples:
- perl rgw_install_config.pl
- or
- perl rgw_install_config.pl --help
-
-=head1 ARGUMENTS
-
-rgw_install_config.pl takes the following arguments:
- --help
- (optional) Displays the usage message.
-
-=cut
-
-use strict;
-use warnings;
-use Pod::Usage();
-use Getopt::Long();
-
-my $help;
-
-Getopt::Long::GetOptions(
- 'help' => \$help
-);
-
-Pod::Usage::pod2usage( -verbose => 1 ) if ($help);
-
-# Function that enters the given msg to log.txt
-
-sub _write_log_entry {
- my $logmsg = shift;
- open(TC,'>>log.txt');
- print TC "[Log] $logmsg\n";
- close(TC);
-}
-
-# Function to get the hostname
-sub get_hostname
-{
- my $cmd = "hostname";
- my $get_host = `$cmd`;
- chomp($get_host);
- return($get_host);
-}
-
-# Function to execute the command and return the exit status
-sub exec_cmd
-{
- my $cmd = shift;
- my $excmd = system($cmd);
- if ( $excmd == 0 ) {
- _write_log_entry("$cmd successful");
- return 0;
- } else{
- _write_log_entry("$cmd NOT successful");
- return 1;
- }
-}
-
-# function to execute the command and return output
-sub get_cmd_op
-{
- my $cmd = shift;
- my $excmd = `$cmd`;
- _write_log_entry("$cmd \n $excmd");
- return $excmd;
-}
-
-# Function to enable module for apache and fastcgi
-sub enmod
-{
- if (!system("sudo a2enmod rewrite")){
- if (!system("sudo a2enmod fastcgi")){
- _write_log_entry("a2enmod rewrite && a2enmod fastcgi successful");
- return 0;
- }
- write_log_entry("a2enmod fastcgi NOT successful");
- return 1;
- }
- write_log_entry("a2enmod rewrite NOT successful");
- return 1;
-}
-
-# Function to create httpd.conf file
-sub set_httpconf
-{
- my $hostname = shift;
- my $http_conf = "/etc/apache2/httpd.conf";
- my $file = "test_file";
- open (FH, ">$file");
- print FH "ServerName $hostname";
- close FH;
- my $get_op = "sudo sh -c \"cat $file >> $http_conf\"";
- my $exit_status = exec_cmd($get_op);
- exec_cmd("rm -f $file");
- return $exit_status;
-}
-
-# To append ceph.conf file with radosgw info
-sub append_ceph_conf
-{
- my $hostname = shift;
- my $file = "/etc/ceph/ceph.conf";
- my $file1 = "test_file1";
- open (FH, ">$file1");
- print FH "[client.radosgw.gateway]
- host = $hostname
- keyring = /etc/ceph/keyring.radosgw.gateway
- rgw socket path = /tmp/radosgw.sock
- log file = /var/log/ceph/radosgw.log \n";
- close FH;
- my $get_op = "sudo sh -c \"cat $file1 >> $file\"";
- my $exit_status = exec_cmd($get_op);
- exec_cmd("rm -f $file1");
- return $exit_status;
-}
-
-# create s3gw.fcgi file and set execute permission for the file
-sub create_fcgi
-{
- my $file = "/var/www/s3gw.fcgi";
- my $chmod_file = "sudo chmod +x /var/www/s3gw.fcgi";
- my $exe_cmd = "exec /usr/bin/radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway";
- my $file1 = "test_file3";
- open (FH, ">$file1");
- print FH "#!/bin/sh \n $exe_cmd \n";
- close FH;
- my $get_op = "sudo sh -c \"cat $file1 >> $file\"" ;
- my $exit_status = exec_cmd($get_op);
- exec_cmd("rm -f $file1");
- my $exit_status1 = exec_cmd($chmod_file) if (!$exit_status);
- return $exit_status1;
-}
-
-# To create rgw.conf
-sub create_rgw_conf {
- my $content = "FastCgiExternalServer /var/www/s3gw.fcgi -socket /tmp/radosgw.sock
-<VirtualHost *:80>
- ServerName rados.domain.com
- ServerAdmin qa\@inktank.com
- DocumentRoot /var/www
-
- RewriteEngine On
- RewriteRule ^/([a-zA-Z0-9-_.]*)([/]?.*) /s3gw.fcgi?page=\$1¶ms=\$2&%{QUERY_STRING} [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
-
- <IfModule mod_fastcgi.c>
- <Directory /var/www>
- Options +ExecCGI
- AllowOverride All
- SetHandler fastcgi-script
- Order allow,deny
- Allow from all
- AuthBasicAuthoritative Off
- </Directory>
- </IfModule>
- AllowEncodedSlashes On
- ErrorLog /var/log/apache2/error.log
- CustomLog /var/log/apache2/access.log combined
- ServerSignature Off
-</VirtualHost>";
-
- my $file = "/etc/apache2/sites-available/rgw.conf";
- my $file1 = "test_file2";
- open (FH, ">$file1");
- print FH "$content";
- close FH;
- my $get_op = "sudo sh -c \"cat $file1 >> $file\"";
- my $exit_status = exec_cmd($get_op);
- exec_cmd("rm -f $file1");
- return $exit_status;
-}
-
-# To generate keyring for rados gateway and add it to ceph keyring with required access
-sub generate_keyring_and_key
-{
- my $cmd = "sudo ceph-authtool --create-keyring /etc/ceph/keyring.radosgw.gateway";
- my $chmod_cmd = "sudo chmod +r /etc/ceph/keyring.radosgw.gateway";
- my $cmd_key = "sudo ceph-authtool /etc/ceph/keyring.radosgw.gateway -n client.radosgw.gateway --gen-key";
- my $chmod_cmd_key = "sudo ceph-authtool -n client.radosgw.gateway --cap osd \'allow rwx\' --cap mon \'allow r\' /etc/ceph/keyring.radosgw.gateway";
- my $exit_status = exec_cmd($cmd);
- my $exit_status1 = exec_cmd($chmod_cmd) if(!$exit_status);
- my $exit_status2 = exec_cmd($cmd_key) if(!$exit_status1);
- my $exit_status3 = exec_cmd($chmod_cmd_key) if(!$exit_status2);
- return($exit_status3);
-}
-
-# To create a rgw user
-sub create_user
-{
- my $usr = shift;
- my $cmd = "sudo radosgw-admin user create --uid=$usr --display-name=$usr";
- my $status = exec_cmd($cmd);
- return($status);
-}
-
-#To start radosgw
-sub start_rgw
-{
- my $cmd = "sudo /etc/init.d/radosgw start";
- my $check_ps = "ps -ef | grep radosgw | grep -v grep";
- my $status = get_cmd_op($cmd);
- if (!$status) {
- my $ps = get_cmd_op($check_ps);
- if ($ps =~ /radosgw/) {
- return 0;
- }
- }
- return 1;
-}
-
-# To start the given service
-sub start_service
-{
- my $input = shift;
- my $status = exec_cmd ("sudo service $input restart");
- if (!$status){
- my $output = get_cmd_op("sudo service $input status");
- if ($output =~ /running/ ){
- if($input eq "apache2" ) {
- return 0;
- }elsif($input eq "ceph"){
- my $count = get_cmd_op("sudo service ceph status | wc -l");
- if ($count == 8 ){
- return 0;
- }
- }
- }
- }
- return 1;
-}
-
-# To enable/disable site
-sub ensite_dissite
-{
- my $a2ensite = "sudo a2ensite rgw.conf";
- my $a2dissite = "sudo a2dissite default";
- my $check_en = get_cmd_op($a2ensite);
- my $check_dis = get_cmd_op($a2dissite);
- if (($check_en =~ /nabl/) && ($check_dis =~ /isabl/)){
- return 0;
- }
- return 1;
-}
-
-#====Main starts here ======
-
-my $domain = "front.sepia.ceph.com";
-my $host = get_hostname();
-my $hostname = "$host.$domain";
-my $run_update = "sudo apt-get update";
-my $install_radosgw = "sudo apt-get install radosgw";
-my $mkdir_rgw = "sudo mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway";
-my $add_entry_ceph_keyring = "sudo ceph -k /etc/ceph/ceph.keyring auth add client.radosgw.gateway -i /etc/ceph/keyring.radosgw.gateway";
-my $start_rgw = "sudo /etc/init.d/radosgw start";
-my $user = "qa";
-my $install_ap_fcgi = "yes | sudo apt-get install apache2 libapache2-mod-fastcgi" if(!exec_cmd($run_update));
-my $check_en = enmod() if(!$install_ap_fcgi);
-my $check_http = set_httpconf($hostname) if (!$check_en);
-my $check_apache = start_service("apache2") if (!$check_http) ;
-my $check_install = exec_cmd($install_radosgw) if(!$check_apache);
-my $get_exit = append_ceph_conf($host) if(!$check_install);
-my $get_exec = exec_cmd($mkdir_rgw) if(!$get_exit);
-my $get_status = create_rgw_conf() if (!$get_exec);
-my $get_enstatus = ensite_dissite() if (!$get_status);
-my $get_status1 = create_fcgi() if(!$get_enstatus);
-my $status = generate_keyring_and_key() if (!$get_status1);
-my $status_add = exec_cmd($add_entry_ceph_keyring) if(!$status);
-my $status_ceph = start_service("ceph") if (!$status_add);
-my $status_apache = start_service("apache2") if (!$status_ceph);
-my $status_rgw = start_rgw() if (!$status_apache);
-my $status_user = create_user($user) if (!$status_rgw);
-_write_log_entry("RGW installation and configuration successful!") if (!$status_user);
-
-
-
-
-
+++ /dev/null
-#! /usr/bin/perl
-
-=head1 NAME
-
-s3-file-test.pl - Script to test the S3 functionality
-
-=head1 SYNOPSIS
-
-Use:
- perl s3-file-test.pl <test_id> [--help]
-
-Examples:
- perl s3-file-test.pl <1|2|3|4|5>
- or
- perl s3-file-test.pl --help
-
-=head1 DESCRIPTION
-
-This script intends to test the S3 functionality
-and reports the test results
-
-=head1 ARGUMENTS
-
-s3-file-test.pl takes the following arguments:
- <test_id>
- (mandatory) Specify the test case ID. It should be one of these values: 1|2|3|4|5
- --help
- (optional) Displays the usage message.
-
-=cut
-
-use Amazon::S3;
-use Data::Dumper;
-use strict;
-use IO::File;
-use Getopt::Long;
-use Digest::MD5;
-use S3Lib qw(display_ceph_os_info get_timestamp get_hostname get_user_info $rgw_user delete_user _write_log_entry _exit_result get_status);
-use Pod::Usage();
-
-my ( $help, $tc );
-
-Getopt::Long::GetOptions(
- 'help' => \$help
-);
-my $tc = $ARGV[0];
-Pod::Usage::pod2usage(-verbose => 1) && exit if (( @ARGV == 0 ) || ($help) );
-
-#== local variables ===
-my $exit_status = 0;
-my $mytestfilename;
-my $logmsg;
-my $kruft;
-my $s3;
-my $domain = "front.sepia.ceph.com";
-my $host = get_hostname();
-my $hostname = "$host.$domain";
-my $testfileloc;
-
-# Execute the test case based on the input to the script
-sub create_file {
- if ( $tc == 1 ) {
- system("dd if=/dev/zero of=/tmp/10MBfile bs=10485760 count=1");
- $mytestfilename = '10MBfile';
- }
- elsif ( $tc == 2 ) {
- system("dd if=/dev/zero of=/tmp/100MBfile bs=10485760 count=10");
- $mytestfilename = '100MBfile';
- }
- elsif ( $tc == 3 ) {
- system("dd if=/dev/zero of=/tmp/500MBfile bs=10485760 count=50");
- $mytestfilename = '500MBfile';
- }
- elsif ( $tc == 4 ) {
- system("dd if=/dev/zero of=/tmp/1GBfile bs=10485760 count=100");
- $mytestfilename = '1GBfile';
- }
- elsif ( $tc == 5 ) {
- system("dd if=/dev/zero of=/tmp/2GBfile bs=10485760 count=200");
- $mytestfilename = '2GBfile';
- } else {
- $exit_status = 1;
- _exit_result($exit_status);
- }
- return 0;
-}
-
-# Run tests for the S3 functionality
-sub run_tests {
- # Modify access keys to suit the target account
- my ( $access_key, $secret_key ) = get_user_info();
- if ( ($access_key) && ($secret_key) ) {
- $s3 = Amazon::S3->new(
- {
- aws_access_key_id => $access_key,
- aws_secret_access_key => $secret_key,
- host => $hostname,
- secure => 0,
- retry => 1,
- }
- );
- }
-
- # List the existing buckets
- my $response = $s3->buckets;
- foreach my $bucket ( @{ $response->{buckets} } ) {
- print "You have a bucket: " . $bucket->bucket . "\n";
- }
-
- # create a new bucket (the test bucket)
- my $bucketname = 'kftestbucket' . get_timestamp();
- print "Attempting to create bucket = $bucketname\n";
- my $bucket = $s3->add_bucket( { bucket => $bucketname } )
- or die $s3->err . $s3->errstr;
- print "Bucket Created: $bucketname\n";
- $logmsg = "Bucket Created: $bucketname";
- _write_log_entry($logmsg);
-
- # upload a file to the bucket
- print "adding file to bucket: $mytestfilename\n";
- $bucket->add_key_filename( $mytestfilename, $testfileloc,
- { content_type => 'text/plain', },
- ) or die $s3->err . ": " . $s3->errstr;
- $logmsg = "$mytestfilename uploaded";
- _write_log_entry($logmsg);
-
- # store a value in the bucket
- $bucket->add_key( 'reminder.txt', 'this is text via add_key' )
- or die $s3->err . ": " . $s3->errstr;
- $logmsg = "Text value stored in file";
- _write_log_entry($logmsg);
-
- # list files in the bucket
- $response = $bucket->list_all
- or die $s3->err . ": " . $s3->errstr;
- foreach my $key ( @{ $response->{keys} } ) {
- my $key_name = $key->{key};
- my $key_size = $key->{size};
- print "Bucket contains key '$key_name' of size $key_size\n";
- }
-
- # fetch file from the bucket
- print
- "Downloading $mytestfilename to temp file: /tmp/downloadfilepurgeme...";
- $response =
- $bucket->get_key_filename( $mytestfilename, 'GET',
- '/tmp/downloadfilepurgeme' )
- or die $s3->err . ": " . $s3->errstr;
- $logmsg = "file downloaded";
- _write_log_entry($logmsg);
-
- # fetch value from the bucket
- $response = $bucket->get_key('reminder.txt')
- or die $s3->err . ": " . $s3->errstr;
- print "reminder.txt:\n";
- print " content length: " . $response->{content_length} . "\n";
- print " content type: " . $response->{content_type} . "\n";
- print " etag: " . $response->{content_type} . "\n";
- print " content: " . $response->{value} . "\n";
-
- # check the original file against the downloaded file to see if the file has been
- # corrupted.
- my $md5 = Digest::MD5->new;
- my $check = 1;
- my $File = $testfileloc;
- my $dlfile = "/tmp/downloadfilepurgeme";
- open( FILE, $File )
- or die "Error: Could not open $File for MD5 checksum...";
- open( DLFILE, $dlfile )
- or die "Error: Could not open $dlfile for MD5 checksum.";
- binmode(FILE);
- binmode(DLFILE);
- my $md5sum = $md5->addfile(*FILE)->hexdigest;
- my $md5sumdl = $md5->addfile(*DLFILE)->hexdigest;
- close FILE;
- close DLFILE;
-
- print "\n";
- print "Finished MD5 Checksum for $File:\n";
- print "$md5sum\n";
- print "Finished MD5 Checksum for $dlfile:\n";
- print "$md5sumdl\n";
- print "\n";
-
- # compare the checksums
- if ( $md5sum eq $md5sumdl ) {
- print "Checksums are equal\n";
- $logmsg = "Checksums are equal";
- _write_log_entry($logmsg);
- }
- else {
- print "Checksums are not equal\n";
- $exit_status = 2;
- $logmsg = "[Failure] Checksums are not equal";
- _write_log_entry($logmsg);
-
- }
-
- # Negative test: try deleting the bucket which still contains objects
- # the method should return false
- if ( !$bucket->delete_bucket ) {
- $logmsg = "Negative test - delete full bucket - Pass";
- }
- else {
- $logmsg = " Negative test - delete full bucket - Fail";
- $exit_status = 3;
- }
- _write_log_entry($logmsg);
-
- # delete keys
- $bucket->delete_key('reminder.txt') or die $s3->err . ": " . $s3->errstr;
- $bucket->delete_key($mytestfilename) or die $s3->err . ": " . $s3->errstr;
- $bucket->delete_key('bogusfile') or die $s3->err . ": " . $s3->errstr;
-
- # and finally delete the bucket
- $bucket->delete_bucket or die $s3->err . ": " . $s3->errstr;
-}
-
-#== Main starts here===
-display_ceph_os_info();
-
-# check if service is already running
-sub check
-{
- my $state = get_status();
- if ($state) {
- _write_log_entry("radosgw is NOT running. quitting");
- $exit_status = 1;
- _exit_result($exit_status);
- }
-}
-check();
-my $flag = create_file();
-if (!$flag) {
- $testfileloc = "/tmp/" . $mytestfilename;
- print "Test file = $testfileloc\n";
- run_tests();
- delete_user();
-}
-_exit_result($exit_status);
-
+++ /dev/null
-#! /usr/bin/perl
-
-use strict;
-use warnings;
-
-#===Variable Declarations====
-
-my $home = "~teuthworker";
-my $teuthology = "~teuthology/teuthology/virtualenv/bin/teuthology";
-my $archivedir = "$home/qa/archive";
-my $config_yaml = "fixed-3.yaml";
-#my $test_name = qq/rbd_api_tests.pl/;
-my $test_name = qq/[% script %]/;
-my $get_script_name = &get_value($test_name,0,'\.');
-my $targetyaml = "$home/qa/targets.yaml";
-
-=head1
-************Function Definition*************************************************************************
-Name of Function: get_value
-Description: get_value() function splits the given command output with the delimiter passed to it
- and returns the desired index of the array
-Arguments: $cmd_output, $index, $delimiter
-Argument Description:
-$cmd_output = String that holds the command output from which required value has to be extracted.
-$index = Index of the array
-$delimiter = Delimiter used in split()
-********************************************************************************************************
-=cut
-
-sub get_value
-{
- my ($cmd_output, $index,$delimiter) = @_;
- my $var = qq/$delimiter/;
- my @split_cmd_output = split($var,$cmd_output);
- my $return_val = $split_cmd_output[$index];
- return $return_val;
-}
-
-=head1
-************Function Definition*************************************************************************
-Name of Function: locate_file
-Description: locate_file() function locates the input file passed to it and passes the command
- output to get_value() file.
-Arguments: $get_yaml
-Argument Description:
-$get_yaml = Name of yaml file to be located
-********************************************************************************************************
-=cut
-
-sub locate_file
-{
- my ($get_yaml) = @_;
- my $loc_yaml = `locate $get_yaml`;
- my $taskyaml = &get_value($loc_yaml,0,"\\n");
- return $taskyaml;
-}
-
-
-=head1
-************Function Definition*************************************************************************
-Name of Function: generate_logfile
-Description: Generates a path for log file in the name of test with embedded time stamp under
- archivedir.
-Arguments: None
-Argument Description: NA
-********************************************************************************************************
-=cut
-
-sub generate_log_path
-{
- my @time = split(/ /, localtime());
- my $stamp = $time[1] . "-" . $time[2] . "-" . $time[4] . "-" . $time[3];
- my $log_file = "$archivedir/$get_script_name-$stamp";
- return $log_file;
-}
-
-# Main starts here
-
-my $task_yaml = "$get_script_name"."."."yaml";
-my $configyaml = &locate_file($config_yaml);
-my $taskyaml = &locate_file($task_yaml);
-my $logfile_loc = &generate_log_path();
-my $tcommand = "$teuthology $configyaml $taskyaml $targetyaml --archive $logfile_loc";
-
-print "$tcommand\n";
-
-system ($tcommand);
-
-if ($? != 0) {
- printf ("Failure $?\n");
- open (TCOMP, '>>test_completed.txt');
- close (TCOMP);
- open (TCOMP, '>>log.txt');
-
- print TCOMP "[Failure]\n";
- close (TCOMP);
- exit 1;
-} else {
- printf ("Success $?\n");
-
- open (TCOMP, '>>test_completed.txt');
- close (TCOMP);
- open (TCOMP, '>>log.txt');
- print TCOMP "[Success]\n";
- close (TCOMP);
- exit 0;
-}
-
+++ /dev/null
-#!/usr/bin/perl
-
-=head1 NAME
-
-script_gen.pl - create a perl wrapper for the teuthology scripts
-
-=head1 SYNOPSIS
-
-Use:
- perl script_gen.pl --script_name <script_name> [--help]
-
-Examples:
- perl script_gen.pl --script_name abc.pl or
- perl script_gen.pl --help
-
-=head1 DESCRIPTION
-
-This script creates a perl wrapper in the name of script_name passed to it.
-The task yaml file name and log file name
-within the wrapper are modified accordingly.
-
-=head1 ARGUMENTS
-
-script_gen.pl takes the following arguments:
-
- --help
- (optional.) Displays the usage message.
-
- --script_name script_name
- (Required.) script name same as the name of the teuthology task for
- which perl wrapper is needed.
-
-=cut
-
-use strict;
-use warnings;
-use Template;
-
-use Pod::Usage();
-use Getopt::Long();
-
-my ($help, $script_name);
-
-Getopt::Long::GetOptions(
- 'help' => \$help,
- 'script_name=s' => \$script_name);
-
- Pod::Usage::pod2usage( -verbose=>1 ) if ($help);
-
-unless (defined($script_name)){
- Pod::Usage::pod2usage( -exitstatus =>2 );
-}
-my $sample_script = "sample.pl";
-my $template = Template->new;
-my $variables = {
- script => $script_name,
-};
-$template->process($sample_script,$variables,$script_name);
-