Tuesday, January 27, 2009

Some Animal Test


Some of the ANImal Test

here, are they
  • Duck Test
  • Elephant Test
  • Monkey Test
  • Guerrilla Test
Duck Test

Wiki says "The duck test is a humorous term for a form of inductive reasoning. It can be explained this way:

If it looks like a duck, swims like a duck and quacks like a duck, then it probably is a duck.

The test implies that a person can figure out the true nature of an unknown subject by observing this subject's readily identifiable traits. It is sometimes used to counter abstruse arguments that something is not what it appears to be.

  Whether this is Duck?

Figure out the Image through Duck Test.

Elephant Test

 Something very hard to describe, but it can be instantly recognizable when spotted.

Moneky Test(ing)

It is a random testing  for unit test without any intention, performed by automation tools.

Example "A monkey test can enter random input to the inputs box to ensure handling of all the valid inputs by the users"

It comes from the famous quotes  ‘a thousand monkeys at a thousand typewriters will eventually type out the entire works of Shakespeare’

Guerrilla Test(ing)

Testing one particular model or functionality heavily without knowing the steps to do it.

Saturday, January 24, 2009

How to Set Isolation level and View


To set Isolation level, Say Read Uncommitted.

mysql>SET GLOBAL TRANSACTION ISOLATION ;
LEVEL READ UNCOMMITTED;
The default Isolation level is Repeatable Read.
To view current Isolation Level
mysql>select @@tx_isolation;

Friday, January 23, 2009

Sanity VS Smoke


Smoke Test:

When a build is received, a smoke test is run to ascertain if the build is stable and it can be considered for further testing.

Smoke testing can be done for testing the stability of any interim build.

Smoke testing can be executed for platform qualification tests.

Sanity testing:

Once a new build is obtained with minor revisions, instead of doing a through regression, a sanity is performed so as to ascertain the build has indeed rectified the issues and no further issue has been introduced by the fixes. Its generally a subset of regression testing and a group of test cases are executed that are related with the changes made to the app.

Generally, when multiple cycles of testing are executed, sanity testing may be done during the later cycles after through regression cycles.

Some Difference between them.

1) Smoke testing originated in the hardware testing practice of turning on a new piece of hardware for the first time and considering it a success if it does not catch fire and smoke. In software industry, smoke testing is a shallow and wide approach whereby all areas of the application without getting into too deep, is tested
Sanity test is a narrow regression test that focuses on one or a few areas of functionality. Sanity testing is usually narrow and deep.

2)Smoke test is scripted--either using a written set of tests or an automated test
Sanity test is usually unscripted.

3)Smoke test is designed to touch every part of the application in a cursory way. It's is shallow and wide.
Sanity test is used to determine a small section of the application is still working after minor change.

4)Smoke testing will be conducted to ensure whether the most crucial functions of a program work, but not bothering with finer details. (Such as build verification).
Sanity testing is a cursory testing; it is performed whenever a cursory testing is sufficient  to prove the application is functioning according to specifications. This level of testing is a  subset of regression testing.

5)Smoke testing is normal health check up to a build of an application before taking it to testing in depth.
Sanity testing is to verify whether requirements are met or not, checking all
features breadth- first

Thursday, January 22, 2009

Difference between Repeatable Read and Read Committed


Main Difference between them

Repeatable Read: Changes are visible only, when all the
Transaction commit. i.e
example if Connection 1 starts a transaction, lets

Begin;
insert query to insert value;
select query to visible the records;

Remember, the above transaction is not committed using commit stmt.
But the newly inserted value can be viewed even without using
commit within the transaction.

Lets Connection 2 do the same thing

Begin;
insert query to insert value;
select query to visible the records;

No commit stmt used

Now Go to connection 1

Use commit stmt and view the records using select query.

This is the most important part, Connection 1 used committed stmt
and can view the newly inserted records which is used in Connection 1,
but still it cannot view newly inserted records done through connection 2.

Even connection 2 cannot view the newly inserted records done
through connection 1 until commit stmt is used. So to visible the
changes both Connection 1 and Connection 2 has to be committed.
Simply, Connection 1 cannot view the changes of Connection 2 until
Connection 2 commits and Connection 2 cannot view the changes made by
Connection 1 until Connection 1 commits

Read Committed: Changes are visible when anyone of the Transaction
commit them

If both Connection 1 and Connection 2 starts a transaction, changes
are visible when anyone of the Connection commit them.

For more information refer

Transaction Isolation Level

Reference: http://www.databasejournal.com/features/

mysql/article.php/3393161/


MySQL-Transactions-Part-II---

Transaction-Isolation-Levels.htm

Transaction Isolation Levels

A transaction isolation level sets the default transactional behaviour. Our examples last month all took the default setting. This month, we see how changing the transaction isolation level leads to different results. As the name suggests, the setting determines how isolated each transation is, or what kind of locks are associated with queries inside a transaction. The four levels, in ascending order of strictness, are:

  • READ UNCOMMITTED: Barely transactional, this setting allows for so-called 'dirty reads', where queries inside one transaction are affected by uncommitted changes in another transaction.
  • READ COMMITTED: Committed updates are visible within another transaction. This means identical queries within a transaction can return differing results. This is the default in some DBMS's.
  • REPEATABLE READ: The default isolation level for InnoDB tables. Within a transaction, all reads are consistent.
  • SERIALIZABLE: Updates are not permitted in other transactions if a transaction has run an ordinary SELECT query, i.e. queries are treated as if they had a LOCK IN SHARE MODE, which we saw in action last month.

InnoDB tables support all four SQL standard transaction isolation levels. Be careful when converting code from other DBMS's, as they do not all support all four levels, nor do they all default to the same level.

  • SQL SERVER - READ COMMITTED
  • Oracle - READ COMMITTED (supports only READ COMMITTED, SERIALIZABLE and the non-standard READ ONLY)
  • DB2 - REPEATABLE READ (supports REPEATABLE READ, UNCOMMITTED READ and 2 non-standard levels)
  • PostgreSQL - REPEATABLE READ (only supports REPEATABLE READ and SERIALIZABLE)

For those who have skipped Part 1, we are using the following table to test with:

mysql> DESC t;

+-------+---------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+---------+------+-----+---------+-------+

| f | int(11) | YES | | NULL | |

+-------+---------+------+-----+---------+-------+

1 row in set (0.05 sec)

You can create and populate it as follows:

mysql> CREATE TABLE t (f INT) TYPE = InnoDB;

Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t values (1),(2),(3),(4),(55);

Query OK, 5 rows affected (0.00 sec)

If you have not made a specific change to the transaction isolation level, it will be a repeatable read. You can check this as follows:

mysql> SELECT @@tx_isolation;

+-----------------+

| @@tx_isolation |

+-----------------+

| REPEATABLE-READ |

+-----------------+

1 row in set (0.00 sec)

Repeatable Reads

In this exercise, we begin a transaction, and see if a committed insert from another transaction is visible in the midst of the transaction.

Connection 1

mysql> BEGIN;

Query OK, 0 rows affected (0.05 sec)

mysql> SELECT * FROM t;

+------+

| f |

+------+

| 1 |

| 2 |

| 3 |

| 4 |

| 55 |

+------+

5 rows in set (0.00 sec)

Connection 2

mysql> BEGIN;

Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t VALUES(6);

Query OK, 1 row affected (0.00 sec)

mysql> COMMIT;

Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM t;

+------+

| f |

+------+

| 1 |

| 2 |

| 3 |

| 4 |

| 55 |

| 6 |

+------+

6 rows in set (0.00 sec)

Remember that it does not matter to the second connection that the SELECT statement was run after the COMMIT. Within the transaction, the new record is immediately visible.

Connection 1:

mysql> SELECT * FROM t;

+------+

| f |

+------+

| 1 |

| 2 |

| 3 |

| 4 |

| 55 |

+------+

5 rows in set (0.00 sec)

mysql> COMMIT;

Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM t;

+------+

| f |

+------+

| 1 |

| 2 |

| 3 |

| 4 |

| 55 |

| 6 |

+------+

6 rows in set (0.00 sec)

This is the essence of the repeatable read. The SELECT query returns a consistent result within a transaction, and new records added from another window during the transaction are not immediately visible. For a result to be visible, both the updating transaction, and any transactions that are already open, needs to be committed.

Uncommitted Reads

Let's see what happens with the READ UNCOMMITTED transaction isolation level. To change this, you will need to have the SUPER privilege.

mysql> SET GLOBAL TRANSACTION ISOLATION 
  http://www.databasejournal.com/img/return.gifLEVEL READ UNCOMMITTED;
Query OK, 0 rows affected (0.00 sec)

Use two new connections for the exercise below, as the new transaction isolation level takes effect only for new connections made after the command is run.

Connection 1:

mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
+------+
6 rows in set (0.00 sec)

Connection 2:

mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)
 
mysql> INSERT INTO t VALUES (7),(8);
Query OK, 1 row affected (0.06 sec)

Connection 1:

mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
+------+
6 rows in set (0.00 sec)

This is known as a dirty read - the new records have not even been committed by the second transaction, yet they are still visible to the first transaction.

Connection 2:

mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)

Connection 1:

mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
+------+
6 rows in set (0.00 sec)

There are dangers with this level of isolation and it bends the rules of transactions. You would only want to use this where you really do not care about the consistency of your results, but do care about potential locks impacting performance.

Committed Reads

mysql> SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
Query OK, 0 rows affected (0.00 sec)

Connection 1:

mysql>BEGIN;
Query OK, 0 rows affected (0.00 sec)
 
mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
+------+
6 rows in set (0.00 sec)

Connection 2:

mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)
 
mysql> INSERT INTO t VALUES (7),(8);
Query OK, 1 row affected (0.05 sec)

Connection 1:

mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
+------+
6 rows in set (0.00 sec)

Connection 2:

mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)

Connection 1:

mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
|    7 |
|    8 |
+------+
8 rows in set (0.00 sec)
 
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)

The important difference is that an uncommitted INSERT did not have any impact on the transaction in Connection 1. Once the second connection's transaction was committed, the result was visible in the first transaction. It is also important to distinguish the difference between this and the default repeatable read transaction isolation level we saw at the beginning. With READ COMMITTED, changes are visible when other transactions commit them. With REPEATABLE READ, changes are only visible when both other transactions commit them, and only in a new transaction. Understanding this important point brings you to the essence of the difference between the two states.

Serializable

Serializable takes locking a step further than even REPEATABLE READ. In this state, all plain SELECT queries are treated as if they had a LOCK IN SHARE MODE appended.

Connection 1:

mysql> BEGIN;
Query OK, 0 rows affected (0.06 sec)
 
mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
|    7 |
|    8 |
+------+
8 rows in set (0.06 sec)

Connection 2:

mysql> BEGIN;
Query OK, 0 rows affected (0.06 sec)
 
mysql> UPDATE t SET f=88 WHERE f=8; 

Because of the SELECT statement from the first connection, the UPDATE is locked, just as with an ordinary LOCK IN SHARE MODE. Only once the first transaction is committed does the UPDATE take place.

Connection 1:

mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)
 

Connection 2:

Query OK, 1 rows affected (4.23 sec)
Rows matched: 1  Changed: 1  Warnings: 0
 
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)
 
mysql> SELECT * FROM t;
+------+
| f    |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|   55 |
|    6 |
|    7 |
|   88 |
+------+
8 rows in set (0.00 sec)

Conclusion

Repeatable reads makes sense as a default transaction isolation level, and in most cases, you are unlikely to want to change this. Locking issues can lead to endless hours of fun if you are not careful and do not take note of the subtleties.