r2 - 17 Aug 2006 - 16:39:58 - BerookAlemayehuYou are here: OSAF >  Journal Web  >  BerookAlemayehuNotes > CosmoOutputParsing

Cosmo Output Parsing

Introduction

Tests are run on Cosmo to emulate a client trying to do certain things like make a new calendar, create an event, and other such things a user would need to do. As these tests are run, Cosmo executes many commands. However, in the end the only things these test scripts check for is a specific response code from Cosmo, which most of the time indicates that the server did it's job. It doesn't guarantee that the server didn't miss something or did something extra. What my project will do is read in all the output and commands that Cosmo exectues during test runs and parse this data into a datastructure where the data can be easily queried to make sure Cosmo is doing everything it needs to be doing.

Reading The Output

The output coming from Cosmo is read by opening a server socket to Cosmo using the telnet object. We connect to the Cosmo server with hostname 'localhost' and port number '9005'.

tn = telnetlib.Telnet(host, port)

After a connection has been made, the code reads the output from Cosmo until a newline character is reached.

tn.read_until('\n', 100)

Example of one line of output:

2006-07-31 14:03:20,212 #%# {ISO8601} #%# DEBUG #%# [ItemManager] #%# created item 2fc864cb-1700-417c-a2f5-3ea3095a0919\n

Parsing The Output

The output is split along the '#%#' character. A simple string.split() method is being used to do this.

temp = self.data.split(' #%# ')

Each part of the output is then put into their own seperate lists, which will be stored into a dictionary.

self.timestamp.append(temp2)
self.ISO.append(temp[1])
self.level.append(temp[2])
self.method.append(temp[3])
self.body.append(temp[4])

Creating Datetime Objects

The output that is read from the Cosmo server is in a string format. We wanted to take the timestamps that were in the output and store them as datetime objects. In order to do that we took the line of code, used the string.split() method to split the timestamp into it's year, month, day, hour, minute, second, and microsecond. Since all of these were still in string format, they were converted into ints and then used as parameters to create a datetime object.

temp2 = datetime(year, month, day, hour, minute, second, msecond)

Storing The Output

We decided to store all the lists in a dictionary because it would allow us to store many different objects into one datastructure. This makes it very easy for us to organize each list.

Searching The Dictionary

We want to have several different methods that are able to search the dictionary and give us certain information based on what a user searches for. So far, we have started developing a method that searches if a certain event took place within a certain time range. The user is able to choose how far back in time they want to search for a certain string from the output.

What Needs To Be Done:

The next step is get the time range method to work and then develop a few other methods, for example a method to search for what occured at a specific time. The code in this project will also need to be integrated with Broadsword and the Open Automation Framework.

-- BerookAlemayehu - 17 Aug 2006

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.