Skip to content

Commit

Permalink
table crud
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Wang committed Sep 19, 2014
1 parent 55d98a8 commit 1a98a3e
Show file tree
Hide file tree
Showing 39 changed files with 2,076 additions and 213 deletions.
1 change: 0 additions & 1 deletion tests/get_item_populated_table/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
IS_FIRST_RUN = False
SLAVE_COUNT = 2
LOCUST_COUNT = 10
HATCH_RATE = 10
Expand Down
3 changes: 1 addition & 2 deletions tests/get_item_populated_table/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import importlib
import os
import random
import string
Expand Down Expand Up @@ -167,7 +166,7 @@ def setup(host, keystone_url, user, password, domain_name, project_name):
kscfg.TOKEN = token
kscfg.PROJECT_ID = project_id
kscfg.req_headers['X-Auth-Token'] = token
print "req_headers: %s", json.dumps(kscfg.req_headers)

table_3_fields_no_lsi_list = []
table_3_fields_1_lsi_list = []
table_10_fields_5_lsi_list = []
Expand Down
2 changes: 1 addition & 1 deletion tests/get_item_populated_table/teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import requests

import ks_config as kscfg
import config as cfg
import ks_config as kscfg


def cleanup(host):
Expand Down
1 change: 0 additions & 1 deletion tests/kvaasloader/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
IS_FIRST_RUN = False
SLAVE_COUNT = 2
LOCUST_COUNT = 100
HATCH_RATE = 10
Expand Down
1 change: 0 additions & 1 deletion tests/put_item_populated_table/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
IS_FIRST_RUN = False
SLAVE_COUNT = 2
LOCUST_COUNT = 100
HATCH_RATE = 10
Expand Down
1 change: 1 addition & 0 deletions tests/put_item_populated_table/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class MagnetoDBUser(locust.HttpLocust):
min_wait = cfg.MIN_WAIT
max_wait = cfg.MAX_WAIT


IS_FIRST_RUN = True
# Master code
def on_slave_report(client_id, data):
Expand Down
1 change: 0 additions & 1 deletion tests/put_item_populated_table/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def setup(host, keystone_url, user, password, domain_name, project_name):
kscfg.PROJECT_ID = project_id
kscfg.req_headers['X-Auth-Token'] = token


table_3_fields_no_lsi_list = []
table_3_fields_1_lsi_list = []
table_10_fields_5_lsi_list = []
Expand Down
1 change: 1 addition & 0 deletions tests/put_item_populated_table/teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import config as cfg
import ks_config as kscfg


def cleanup(host):
print "Clean up ..."
with open(cfg.TABLE_LIST) as table_list_file:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
IS_FIRST_RUN = False
SLAVE_COUNT = 2
LOCUST_COUNT = 100
LOCUST_COUNT = 10
HATCH_RATE = 10
MIN_WAIT = 0
MAX_WAIT = 0
Expand All @@ -9,6 +8,9 @@
BATCH_SIZE = 1000
TOKEN_PROJECT = "/tmp/token_project.txt"
TABLE_LIST='/tmp/table_list.txt'
ITEM_KEY_LIST = '/tmp/item_key_list.txt'
CASSANDRA_NODES='127.0.0.1'
CASSANDRA_CLEANER='/root/scripts/cleaner.sh'

token_req_headers = {
'Content-Type': 'application/json',
Expand Down
20 changes: 20 additions & 0 deletions tests/query_populated_table/ks_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import json
import os.path

import config as cfg


TOKEN = None
PROJECT_ID = None

if os.path.isfile(cfg.TOKEN_PROJECT):
with open(cfg.TOKEN_PROJECT) as token_proj_file:
token_project = json.load(token_proj_file)
TOKEN = token_project['token'].strip()
PROJECT_ID = token_project['project_id'].strip()

req_headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Auth-Token': TOKEN
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import json


TABLE_LIST = '/tmp/table_list.txt'
ITEM_KEY_LIST = '/tmp/item_key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icN9Z4bMSsLQtTs_iQc7wHrn6nIM3wCdk6QTwCvskVXr2ChIYug5NpLkmCuJhEOts_TL4idLT5JsQ8Tashk22GUDveue1-panbeJBkSSu8yNj0yZHvTCNrCeu8ZiH-idt8K69PlhAd8Vhh7GuuF5hu4H_e5RmUb7WY-MhEyHHU12ZKFthyxKsf7qbsTbfBXP7iThJoXX3WkLrh_iplBF-t5vMlq8F75Eyd386Qk9GcY0eDNO87fjydE2S_WNNlmjavNDY6p7Fs1X_gSmpF2cvMptu1waOt4cqBOW-wd79X6P0UPzatrB-n5B5HXhGE_TfSHsRyvZbo71u98-lFNTTR985-EeuFBbK1mNVOosxKr7K3zYtyvUvPYieQnocD877pfp82K_MtZB722jx8H66zl-wZC-OYuPwV-LYpc_D0OxmJuJ7NwNp6k1U9F5c-428kC0l2e5UMroFJc8IryNpOO7Ozv1y8dFLBYtOML64UAb37i_ex9i9_FdXXqu7VBU3SVEXd7t-7fHv9HlS9Am1j9fhf8G36O5Vw==
""".strip()
PROJECT_ID = '9a3afecc2a464ae79b3883e1e9fee0df'

with open(TOKEN_PROJECT) as token_proj_file:
token_project = json.load(token_proj_file)
TOKEN = token_project['token'].strip()
PROJECT_ID = token_project['project_id'].strip()

req_headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Auth-Token': TOKEN
}

token_req_headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import json
import random
import string

import locust
from gevent import GreenletExit
from locust.events import EventHook
from locust import task
import config as cfg
import ks_config as kscfg
import queries as qry

IS_FIRST_RUN = cfg.IS_FIRST_RUN

table_3_fields_no_lsi_list = []
table_3_fields_1_lsi_list = []
Expand All @@ -18,7 +18,7 @@
key_3_fields_1_lsi_list = []
key_10_fields_5_lsi_list = []

PROJECT_ID = qry.PROJECT_ID
PROJECT_ID = kscfg.PROJECT_ID


class UserBehavior(locust.TaskSet):
Expand Down Expand Up @@ -46,7 +46,7 @@ def load_table_list(self):
global table_3_fields_1_lsi_list
global table_10_fields_5_lsi_list

with open(qry.TABLE_LIST) as table_list_file:
with open(cfg.TABLE_LIST) as table_list_file:
table_list = json.load(table_list_file)
table_3_fields_no_lsi_list = table_list['table_3_fields_no_lsi']
table_3_fields_1_lsi_list = table_list['table_3_fields_1_lsi']
Expand All @@ -57,7 +57,7 @@ def load_item_key_list(self):
global key_3_fields_1_lsi_list
global key_10_fields_5_lsi_list

with open(qry.ITEM_KEY_LIST) as item_key_list_file:
with open(cfg.ITEM_KEY_LIST) as item_key_list_file:
item_key_list = json.load(item_key_list_file)
key_3_fields_no_lsi_list = item_key_list['key_3_fields_no_lsi']
key_3_fields_1_lsi_list = item_key_list['key_3_fields_1_lsi']
Expand All @@ -71,7 +71,7 @@ def query_3_fields_no_lsi_1(self):
'/data/tables/' + table_name + '/query')
self.client.post(req_url,
qry.QUERY_3_FIELDS_NO_LSI_RQ1,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_only")

@task(1)
Expand All @@ -82,7 +82,7 @@ def query_3_fields_1_lsi_1(self):
'/data/tables/' + table_name + '/query')
self.client.post(req_url,
qry.QUERY_3_FIELDS_1_LSI_RQ1,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_only")

@task(5)
Expand All @@ -96,7 +96,7 @@ def query_3_fields_1_lsi_2(self):
post_by = attribute_key["LastPostedBy"]
self.client.post(req_url,
qry.QUERY_3_FIELDS_1_LSI_RQ2 % post_by,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_range")

@task(1)
Expand All @@ -107,7 +107,7 @@ def query_10_fields_5_lsi_1(self):
'/data/tables/' + table_name + '/query')
self.client.post(req_url,
qry.QUERY_10_FIELDS_5_LSI_RQ1,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_only")

@task(5)
Expand All @@ -121,7 +121,7 @@ def query_10_fields_5_lsi_2(self):
post_by = attribute_key["LastPostedBy"]
self.client.post(req_url,
qry.QUERY_10_FIELDS_5_LSI_RQ2 % post_by,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_range")

@task(5)
Expand All @@ -135,7 +135,7 @@ def query_10_fields_5_lsi_3(self):
addtional_field_1 = attribute_key["AdditionalField1"]
self.client.post(req_url,
qry.QUERY_10_FIELDS_5_LSI_RQ3 % addtional_field_1,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_range")

@task(5)
Expand All @@ -149,7 +149,7 @@ def query_10_fields_5_lsi_4(self):
addtional_field_2 = attribute_key["AdditionalField2"]
self.client.post(req_url,
qry.QUERY_10_FIELDS_5_LSI_RQ4 % addtional_field_2,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_range")

@task(5)
Expand All @@ -163,7 +163,7 @@ def query_10_fields_5_lsi_5(self):
addtional_field_3 = attribute_key["AdditionalField3"]
self.client.post(req_url,
qry.QUERY_10_FIELDS_5_LSI_RQ5 % addtional_field_3,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_range")

@task(5)
Expand All @@ -177,7 +177,7 @@ def query_10_fields_5_lsi_6(self):
addtional_field_4 = attribute_key["AdditionalField4"]
self.client.post(req_url,
qry.QUERY_10_FIELDS_5_LSI_RQ6 % addtional_field_4,
headers=qry.req_headers,
headers=kscfg.req_headers,
name="query_hash_range")


Expand All @@ -186,6 +186,8 @@ class MagnetoDBUser(locust.HttpLocust):
min_wait = cfg.MIN_WAIT
max_wait = cfg.MAX_WAIT

IS_FIRST_RUN = True


# Master code
def on_slave_report(client_id, data):
Expand Down
Loading

0 comments on commit 1a98a3e

Please sign in to comment.