1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import ndb
import sys,time,random,struct,math
import myprep
myprep.prep()
### Connect to cluster
BATCH_SIZE=1
i=1
print "connecting to cluster\n"
connection = ndb.Ndb_cluster_connection()
try:
connection.connect(1,1,0)
except RuntimeError, e:
print e
sys.exit(-1)
if (connection.wait_until_ready(30,30)):
print "Cluster was not ready within 30 secs."
sys.exit(-1);
myNdb = ndb.Ndb(connection,"TEST_DB_1" )
if (myNdb.init(4) == -1):
print myNdb.getNdbError().getMessage()
sys.exit(-1)
print "running tests:\n"
### Fill db
try:
myTransaction= myNdb.startTransaction()
except RuntimeError, e:
print e
sys.exit(-1)
myOperation=myTransaction.getNdbOperation("MYTABLENAME")
myOperation.insertTuple()
auto_id = myNdb.getAutoIncrementValue("MYTABLENAME",BATCH_SIZE)
myOperation.equal("ATTR1",auto_id);
myOperation.setValue("ATTR2", i);
ret = myTransaction.execute( ndb.Commit )
if ret == -1:
print myTransaction.getNdbError().getMessage()
myNdb.closeTransaction(myTransaction)
|