четверг, 22 июня 2017 г.

AQA: jmeter: create assertions for JDBC (Database)

How to extract JDBC Request response?
My JDBC request response is as below,

request_token   create_date
Vve5vyD42ZPr5ssTIduzy1l6cvb/hDPaCMXnF8cFcpaCfdRMvNChB43I+JSgmgvy2owklXPRGvIVolDhb12lU2dIXko6ajlqyKoh3RjhPYo=    2015-02-25 18:56:00.0
How to extract only 'request token' from the response?

Answer:
In your JDBC Sampler add the following values into "Variables" input:

token,date
See below image for details:
https://i.stack.imgur.com/Hkz91.png
You'll be able to refer "request_token" value as ${token_1} and "create_date" value as ${date_1}

See the following material for more information:

How to get current date and time?
Use __time function:
  • ${__time(dd/MM/yyyy,)}
  • ${__time(hh:mm a,)}
${__time(dd-mmm-yyyy HHmmss)} 20-032-2015 233224
${__time(d-MMM-yyyy hhmmss)}  20-May-2015 113224
${__time(dd-m-yyyy hhmmss)}   20-32-2015 113224
${__time(D-M-yyyy hhmmss)}    140-5-2015 113224
${__time(DD-MM-yyyy)}         140-05-2015


Additional info:


 

понедельник, 19 июня 2017 г.

SQL: collection of used queries - tips and tricks

1) Extract Random row which has only 1 record, for example ccid=756;

SELECT PACKAGENAME FROM WEB_PACKAGE_INFO HAVING COUNT(PACKAGENAME)=1 GROUP BY PACKAGENAME ORDER BY  dbms_random.value;

For another DB servers:
Select a random row with MySQL:
SELECT column FROM table
ORDER BY RAND()
LIMIT 1

Select a random row with PostgreSQL:
SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1

Select a random row with Microsoft SQL Server:
SELECT TOP 1 column FROM table
ORDER BY NEWID()

Select a random row with IBM DB2
SELECT column, RAND() as IDX
FROM table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY

Select a random record with Oracle:
SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1

2) Format date to view ISO8601 yyyy-mm-ddThh:mi:ss.mmmZ

select to_char(STARTDATE,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as STARTDATE from WEB_PACKAGE_INFO;

3) It gives new random row every time when executed:
select * from
(select
PACKAGEREGION,PACKAGENAME, PACKAGE_ID, CAMCPCKGID, 
    to_char(STARTDATE,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as STARTDATE,
    to_char(EXPIRATIONDATE,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as EXPIRATIONDATE,
STATUS, PACKAGEID, CHANNELID, BOC, MAJOR, CALLSIGN, CCID, SOURCEID,
    to_char(CHSTART,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as CHSTART,
    to_char(CHEND,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as CHEND,
CSS, CHANNELSTATE, COUNTRY, SAT, SID, TEXT, CHANNEL_ID
from web_package_info where status='A' ORDER BY dbms_random.random)
where rownum = 1;

But such constraction won't give such result:
select
PACKAGEREGION,PACKAGENAME, PACKAGE_ID, CAMCPCKGID, 
    to_char(STARTDATE,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as STARTDATE,
    to_char(EXPIRATIONDATE,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as EXPIRATIONDATE,
STATUS, PACKAGEID, CHANNELID, BOC, MAJOR, CALLSIGN, CCID, SOURCEID,
    to_char(CHSTART,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as CHSTART,
    to_char(CHEND,'YYYY-MM-DD"T"HH24:MI:SS"Z"') as CHEND,
CSS, CHANNELSTATE, COUNTRY, SAT, SID, TEXT, CHANNEL_ID
from web_package_info where status='A' ORDER BY dbms_random.random;

вторник, 13 июня 2017 г.

UNIX: find and grep best practice

How to run  last executed find command in Unix – Example 1 

javin@testenv1 ~/java : !find
find . -name "*.java"     --last find command executed
./OnlineStockTrading.java
./StockTrading.java


How to find files which have been modified less than one day, minute or hour  in Unix:

javin@testenv1 ~/java : find . -mtime (find all the files modified exact 1 day)

javin@testenv1 ~/java : find . -mtime -1 (find all the files modified less than 1 day)
.
./StockTrading.java

javin@testenv1 ~/java : find . -mtime +1 (find all the files modified more than 1 day)
./.vimrc
./OnlineStockTrading.java
./StockTrading.java~

воскресенье, 11 июня 2017 г.

AQA. XPath - tools, examples

Tool for quick testing: link

Example 1:
Task: XML tree has:
proceedings
   -name
   -contents
      -article
         -description
         -title
         -pages
How can I identify any title that has only one description? And the number of articles that have more than three descriptions using xpath?

Decision:
Title with one description:
/proceedings/contents/article[count(description)=1]/title
Number of articles with more than three descriptions:
count(/proceedings/contents/article[count(description)>3])
 
Example 2:
Find element by span and text 
//span[text()='Мероприятия'] 
next element after f
 
Example 3: 
xpath select first element with attribute
(//*[@id="titleInput"])[1]
This will first get the book elements with the location attribute equal to 'US'. Then it will select the first node from that set. Note the use of parentheses, which are required by some implementations.
(note this is not the same as /bookstore/book[1][@location='US'] unless the first element also happens to have that location attribute )

Example 4:
Take element based on text inside (not by number of record)
<select name="garden">
    <option>Flowers</option>
    <option selected="selected">Shrubs</option>
    <option>Trees</option>
    <option selected="selected">Bushes</option>
    <option>Grass</option>
    <option>Dirt</option>
</select>
Xpath:
//*[@id="qualListContainer"]/option[.="HDTV"]
Xpath if number record used:
//*[@id="qualListContainer"]/option[3]

Example 5:
Button that contain link with text "Create"
//button[text()='Create']
the same variant:
//button[.='Create']
or by link text
//a[text()='text_i_want_to_find']/@href


SEO: Эксперимент: как Яндекс и Google учитывают ключевые слова в URL

Эксперимент: как Яндекс и Google учитывают ключевые слова в URL Эксперимент: как Яндекс и Google учитывают ключевые слова в URL Дата пу...