Thursday, December 16, 2010

SBR600 Reflection.

Although I learned lots of stuffs from SBR600, this course was not exactly what I expected before the semester began. I thought that I would learn something practical such as linux commands and script languages in SBR600 as I did from other linux courses. But this course is project-oriented and quite different from other courses I ever took. So that I totally lost the track at the begging of the semester. I think there is a big gap between this SBR600 and other OPS(linux) courses. In my opinion, SBR600 would better deal with practical materials such as linux commands, GIT, Python(because python is commonly used in linux projects) and so on. So if a student completing SBR600 wants to learn more and involve in real Linux projects then takes the SBR700 after the SBR600. Anyway, I really appreciate Chris for the knowledge and passions you showed us throughout this semester.

SBR600 Project 0.3 (AutoQA-Man Pager Checker)

Originally the codes of this test were written by Ivana Varekova (varekova@redhat.com) but not tested and wrapped for autoqa. I modified the codes and put them into one test and created other control and configuration files.
You can get the man_checker test http://matrix.senecac.on.ca/~jwpark2/man_checker.tgz) including "control, control.autoqa, man_checker, man_checker.py" files.
You can also find out addition information on http://zenit.senecac.on.ca/wiki/index.php/AutoQA.
This test has not been fully set but still being examined.

This test is able to check man pages whether the references in "See also" section are valid or whether they point to inexistent tools. The test would be run with post-koji-build hook.

For whom to want to work on this test, the autoqa project provides a basic framework for executing a series of tests and reporting results.

In order to verifiy and run the AutoQA tests, you need to install autoqa and autotest first.


1. Pre-requistes


First, install the autotest and autoqa packages. These packages provide a local test harness and the autoqa hooks, watchers and python libraries needed to verify a test is functioning properly. Be sure to setup the correct package repositories


1. Configure the AutoQA package repository.

# wget -P /etc/yum.repos.d http://repos.fedorapeople.org/repos/fedora-qa/autoqa/fedora-autoqa.repo

2. Finally, with yum repositories configured, use the yum command to install autotest and its dependencies.

# yum install autotest-server

3. Install autoQA

# yum install autoqa

4. configure Cron : On the server you will want to periodically run AutoQA watchers, which will execute corresponding tests. We have prepared a cron file for these purposes, you can install it by:

# cp /usr/share/autoqa/autoqa.cron /etc/cron.d/


2. Examine the watcher


Now we need to simulate running the hook's watcher on AutoQA server to see what commands would be run. My test uses post-koji-build hook, which announces every package built and tagged with dist-fX-updates-candidate tag in Koji. So I would run:


# /usr/share/autoqa/post-koji-build/watch-koji-builds.py --dry-run

No previous run - checking builds in the past 3 hours

autoqa post-koji-build --kojitag dist-f12-updates-candidate --arch x86_64 --arch i686 espeak-1.42.04-1.fc12

autoqa post-koji-build --kojitag dist-f11-updates-candidate --arch x86_64 kdemultimedia-4.3.4-1.fc11

autoqa post-koji-build --kojitag dist-f11-updates-candidate --arch x86_64 kdeplasma-addons-4.3.4-1.fc11

autoqa post-koji-build --kojitag dist-f12-updates-candidate --arch x86_64 --arch i686 cryptopp-5.6.1-0.1.svn479.fc12

autoqa post-koji-build --kojitag dist-f12-updates-candidate --arch x86_64 drupal-6.15-1.fc12

autoqa post-koji-build --kojitag dist-f12-updates-candidate --arch x86_64 --arch i686 seamonkey-2.0.1-1.fc12

... output trimmed ...


3. Run just your test


Now I will run my test for real. But I don't want to run all tests of that post-koji-build hook on it. I will modify the command to look like this:


# autoqa post-koji-build --kojitag dist-f13-updates-candidate --arch x86_64 --arch i686 espeak-1.42.04-1.fc13 --test man_checker

The output will look like

13:53:03 DEBUG| Persistent state variable __group_level now set to 1

13:53:03 INFO | START man_checker man_checker timestamp=129252 5583 localtime=Dec 16 13:53:03

13:53:03 DEBUG| Persistent state variable __group_level now set to 2

13:53:03 DEBUG| Crash handling system enabled

13:53:03 DEBUG| Running 'rpm -qa'

13:53:04 INFO | Test started. Number of iterations: 1

13:53:04 INFO | Executing iteration 1 of 1

13:53:04 INFO | Dropping caches between iterations

13:53:04 DEBUG| Running 'sync'

13:53:05 DEBUG| Running 'echo 3 > /proc/sys/vm/drop_caches'

13:53:05 INFO | ****************************************

13:53:05 INFO | * RESULT: CRASHED

13:53:05 INFO | * SUMMARY: man_checker: CRASHED; TypeError: run_once() takes exa ctly 2 non-keyword arguments (1 given)

13:53:05 INFO | * HIGHLIGHTS: 0 lines

13:53:05 INFO | * OUTPUTS: 6 lines

Friday, November 26, 2010

SBR600 project 0.2 (man page checker)e

The test I'm trying to implement extracts the man pages from the package uploaded in the koji-build system and see the SEE ALSO section of the man pages to check if any invalid links are contained.
The following script is to get a list of man-pages from RPMs uploaded in the koji-build system

#!/bin/bash
# parameter - directory with rpm
# ouptput - list of its man-pages
rpm_path=$1

for rpm in `ls $rpm_path`; do
if [[ $rpm == *.rpm ]]
then
rpm -qlp $rpm_path/$rpm 2>/dev/null| grep "^/usr/share/man/man.*"
fi
done


After getting a list of man pages, the following script test the man pages extracted

#!/bin/bash
# first parametr - srpm
# second parametr - man-pages list
# output - false SEE ALSO links

rpm=$1
list=$2
#set -x

mkdir ./tmp
cd ./tmp
rpm2cpio ../$1 >tmp.cpio
cpio -i -d --force-local /dev/null

if [ -d ./usr/share/man/ ]; then

for i in `ls ./usr/share/man/man[0-9]*/*`; do
# find the start of SEE ALSO section
if [ `zcat $i | grep -n "SEE ALSO" | grep ".SH" | wc -l` -ne 0 ]; then
# begin of this section
min=`zcat $i | grep -n "SEE ALSO" | grep ".SH" | sed "s|:.*||" | head -n1`
max=`zcat $i | wc -l`

let "suf=$max-$min"
if [ $suf -ne 0 ]; then
# end of SEE ALSO section
end=`zcat $i >/dev/null| tail -n$suf | grep -n ".SH" | head -n1 | sed "s|:.*||"`
if [ "x" = "x$d" ]; then
# there is next section after SEE ALSO
# SEE ALSO is the last section
end=`zcat $i |wc -l`
else
# SEE ALSO is the last section
let end="$end-1"
fi

fil1=`zcat $i | tail -n$suf | head -n$end | grep "^.BR" | sed "s|.BR \([^ ]*\) (\([1-9][^ ]*\)).*|/usr/share/man/man\2/\1.\2.|g" | grep -v BR`
for jj in `echo $fil1`; do
j=`echo $jj | sed 's|\\\-|-|g'`
grep "$j" ../$2 >/dev/null;
if [ $? -ne 0 ]; then
j2=`echo $j | sed "s|/usr/share/man/man\(.*\)/\([^.]*\).*|/usr/share/man/man.*/\2.[0-9]|"`
pom=`grep "$j2" ../$2`
if [ `echo $pom | wc -l` -ne 0 ]; then
printf " BUG - package: %20s, man-page: %30s, link %20s\n" $1 $i $j
fi
else
printf " OK - package: %20s, man-page: %30s, link %20s\n" $1 $i $j
fi
done
fi
fi
done
fi



1. Install and configure AutoQA # Some useful imports
import autoqa.util
from autoqa.test import AutoQATest
from autoqa.decorators import ExceptionCatcher
from autotest_lib.client.bin import utils

# Your class name must match file name (without .py) and also run_test line in
# its control file.
class (AutoQATest): # <-- UPDATE Classname version = 1 # increment this if setup() changes # During the execution fill these variables: # self.result: test result keyword # self.summary: one line test result summary # self.outputs: full test output (string or list of strings) # self.highlights: important lines to notice (string or list of strings) @ExceptionCatcher("self.run_once_failed") def run_once(self, some_params, **kwargs): #**kwargs needs to stay cmd = 'test_binary --param %s' % some_params self.outputs = utils.system_output(cmd, retain_output=True) self.result = "PASSED" #FAILED, INFO, ABORTED, ... self.summary = "This test was awesome!" self.highlights = "Note these important lines, if you miss them,\n" self.highlights += "you'll regret it forever.
  • Get the source code using GIT : git clone git://git.fedorahosted.org/autoqa.git autoqa : #This command downloads the source code us
  • For Fedora, execute the command: wget -P /etc/yum.repos.d http://repos.fedorapeople.org/repos/fedora-qa/autoqa/fedora-autoqa.repo
  • Yum repository for AutoQA server has been set up. Use yum to download it : yum install autoqa
  • Now on the server, event watchers, which triggers corresponding autoqa tests when events occur, are needed to run periodically. :
    cp /usr/share/autoqa/autoqa.cron /etc/cron.d/
2. Setting for the new test.

There's four parts to a test: the test code, the test object, the Autotest control file, and the AutoQA control file. all live in a single directory, located in the tests directory of the autoqa source directory. From the autoqa/doc directory, copy template files, autoqa.template, autoqa.control.template, and test_class.py to the directory /tests/man_page_checker/ and rename them autoqa, autoqa.control, and man_page_checker.py respectively. After that, put the man_page_checker source code in it.

* control file for man_page_checker
AUTHOR = "Jaewoo Park "
TIME="SHORT"
NAME = 'man_page_checker' #name of the test
DOC = """
This test checks validity in man pages
"""
TEST_TYPE = 'CLIENT'
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
job.run_test('man_page_checker', config=autoqa_conf, **autoqa_args)
# should use the name of test for the first value


* control.autoqa file

# this test can be run just once and on any architecture
archs = ['noarch']

# we want to run this test just for post-koji-build hook
if hook not in ['post-koji-build']:
execute = False


* man_page_checker.py file

# Some useful imports
import autoqa.util
from autoqa.test import AutoQATest
from autoqa.decorators import ExceptionCatcher
from autotest_lib.client.bin import utils

# Your class name must match file name (without .py) and also run_test line in
# its control file.
class (AutoQATest): # <-- UPDATE Classname
version = 1 # increment this if setup() changes

# During the execution fill these variables:
# self.result: test result keyword
# self.summary: one line test result summary
# self.outputs: full test output (string or list of strings)
# self.highlights: important lines to notice (string or list of strings)
@ExceptionCatcher("self.run_once_failed")
def run_once(self, some_params, **kwargs): #**kwargs needs to stay
cmd = 'test_binary --param %s' % some_params
self.outputs = utils.system_output(cmd, retain_output=True)
self.result = "PASSED" #FAILED, INFO, ABORTED, ...
self.summary = "This test was awesome!"
self.highlights = "Note these important lines, if you miss them,\n"
self.highlights += "you'll regret it forever.
"


Thursday, November 11, 2010

SBR600 - AutoQA Project plan 0.1

Project plan 0.1 : Autotest server setting.

AutoQA is an automated test system for Fedora. Its design is simple: when certain events occur, AutoQA launches automated tests.
Autotest is currently b used as the test harness for AutoQA. It handles the dirty work of getting code onto test machines, running it, and holding all the results. Autotest is currently packaged for Fedora 13, but due to unpackaged dependencies, is not yet available for Fedora. Hence in order to install autotest, AutoQA package repository is needed to be configured first.
#wget -P /etc/yum.repos.d http://repos.fedorapeople.org/repos/fedora-qa/autoqa/fedora-autoqa.repo : This command adds the autoQA repository to the fedora repository directory.

Finally, with yum repositories configured, use the yum command to install autotest and it's dependencies.
# yum install autotest-server : This step installs autotest-server and its dependencies

The autotest server requires the Apache HTTP Server. No additional configuration is required,
autotest provides a /etc/httpd/conf.d/autotest.conf configuration file. All the conf files in
the conf.d directory will be included when httpd starts.

1. Start httpd:
# service httpd restart

2. Configure httpd to start on system boot:
# chkconfig httpd on

Autotest requires access to a mysql server. Also need set up a password for the mysql root . If it's not done, errors occur
#mysqladmin -u root password sbr600
After this, create the autotest_web and autotest_tko databases and user permissions needed by autotest.

create database autotest_web; grant all privileges on autotest_web.* TO 'autotest'@'localhost' identified by 'NEWPASSWORD'; grant SELECT on autotest_web.* TO 'nobody'@'%'; grant SELECT on autotest_web.* TO 'nobody'@'localhost'; flush privileges;

create database autotest_tko; grant all privileges on autotest_tko.* TO 'autotest'@'localhost' identified by 'NEWPASSWORD'; grant SELECT on autotest_tko.* TO 'nobody'@'%'; grant SELECT on autotest_tko.* TO 'nobody'@'localhost'; flush privileges;

With the mysql database configured, it's time to tell autotest how to connect, and to pre-populate the database with initial data.

1. The /usr/share/autotest/global_config.ini file is needed to be modified to do this.

In sections [TKO] and [AUTOTEST_WEB], enter the correct values for password
In section [TKO], change the value of database to autotest_tko
In section [SERVER], set the value of hostname

2. Setup the database schemas and populate initial data

# python /usr/share/autotest/database/migrate.py --database=AUTOTEST_WEB sync
# python /usr/share/autotest/database/migrate.py --database=TKO sync

3. Run the Django syncdb operation

# python /usr/share/autotest/frontend/manage.py syncdb --noinput

4. Restart httpd

# service httpd restart

5. Start the autotest scheduler

# service autotestd start

If all the steps are properly done, you can access web-based autotest server page.





Tuesday, October 12, 2010

SBR600 - Building a package from a new spec file

The software I chose to build is "dosbox" which is a DOS emulator supporting graphic and sound for old DOS applications.
To create a package from source code, rpmdevtools, which contains a bunch of rpm-related commands, is required.

root# yum install rpmdevtools

First of all, I needed the source rpm file of the "dosbox" application.

user# yumdownloader --source dosbox

And then installed the source rpm file.

user# rpm -i dosbox-0.74-1.fc13.src.rpm

After installing it, there were a spec file in the SPEC directory and 3 files, dosbox- 0.74.tar.gz, dosbox.desktop, dosbox.png in the SOURCES directory.

Renamed the existing spec file and created a new spec file using the command:

user# rpmdev-newspec dosbox


Before working on the spec file, I installed the dependencies for the dosbox such as:
libpng-devel, SDL-devel, SDL_net-devel, SDL_sound-devel, desktop-file-utils, alsa-lib-devel, and libGLU-devel.

Then modified the dosbox.spec file and ran the command "rpmbuild -ba dosbox.spec" to create a new rpm package from souces but the following errors were generated at the end.

Checking for unpackaged file(s):
/usr/lib/rpm/check-files /home/jaewoo/rpmbuild/BUILDROOT/dosbox-0.74-1.fc13.x86_64


error: Installed (but unpackaged) file(s) found:
/usr/bin/dosbox
/usr/share/man/man1/dosbox.1.gz


RPM build errors:

Installed (but unpackaged) file(s) found:

/usr/bin/dosbox

/usr/share/man/man1/dosbox.1.gz


Now I'm working on how to fix the problem

Tuesday, September 21, 2010

SBR600- week2 - modifying -j values in .rpmmacros

To do this lab, I used a school computer in the open lab which has

intel Q9550 quad core cpu running at 2.83GHz and 4GB ram on it.

The result of rebuilding a package from its source RPM based on -j

value in ~./rpmmacros are the following:

%_smp_mflags -j0
error

%_smp_mflags -j1
real 0m31.406s
user 0m20.616s
sys 0m6.055s

%_smp_mflags -j2
real 0m24.657s
user 0m20.507s
sys 0m6.110s

%_smp_mflags -j3
real 0m22.559s
user 0m20.901s
sys 0m6.269s

%_smp_mflags -j4
real 0m21.480s
user 0m21.154s
sys 0m6.365s

%_smp_mflags -j5
real 0m21.636s
user 0m21.257s
sys 0m6.481s

%_smp_mflags -j6
real 0m21.430s
user 0m21.129s
sys 0m6.294s

commenting out of %_smp_mflags
real 0m21.650s
user 0m21.216s
sys 0m6.409s

The %_smp_mflag in .rpmmacros file is used as the make command

builds a package to set the number of jobs which will run at once.
As it is observed above, if the number of jobs sets to 0, it stops with
error. If there is no argument, it is considered as infinite jobs. I
didn't see any significant increment of performance after the value
of 4. 4 or higher value for the -j switch is best suited for the system
I tested.

Monday, September 13, 2010

SBR600-Building software packages from source code

1. NLED

First of all, I downloaded the NLED source code from

"http://cdot.senecac.on.ca/software/nled/" and extracted

the file using the command "tar -xzf nled_2_52_src.tgz"

Then I tried "make" command in the directory which

contains the source code of NLED but I got the following

error messages.

[jaewoo@localhost nled-2.52]$ make
cc -O -c -o nled.o nled.c
make: cc: Command not found
make: *** [nled.o] Error 127


After this, I realized there is no C compiler installed on my system.

So I did "yum install gcc" and then "yum install "*/ncurses.h"

respectively to install a C compiler and ncurses library.

After these steps were done, the "make" command successfully

created the "nled" editor

2. Installing aMSN

I got the aMSN souce code from "http://sourceforge.net"

"http://softlayer.dl.sourceforge.net/project/amsn/amsn/0.98.3/amsn-0.98.3-src.tar.bz2"

To extract the archive file, use either

"tar -xjvf amsn-0.98.3-src.tar.bz2"

or

"bunzip2 amsn-0.98.3-src.tar.bz2 && tar -xvf amsn-0.98.3-src.tar" command.

When I issued the command "./configure" there were so many

prerequisite packages missing so I had to install all missing

packages first at the below using "yum" respectively :

"gcc-c++ , tcl-devel, tk-devel, libpng-devel, libjpeg-devel,

gstreamer-devel, farsight2-devel".

At last, I was able to successfully run the aMSN messager on

my linux system.