Package com.privalia.qa.specs
Class BigDataGSpec
- java.lang.Object
-
- com.privalia.qa.specs.BaseGSpec
-
- com.privalia.qa.specs.BigDataGSpec
-
public class BigDataGSpec extends BaseGSpec
Steps definition for big data functionality
-
-
Field Summary
Fields Modifier and Type Field Description static String
ES_DEFAULT_CLUSTER_NAME
static Integer
ES_DEFAULT_NATIVE_PORT
static int
VALUE_SUBSTRING
-
Fields inherited from class com.privalia.qa.specs.BaseGSpec
commonspec
-
-
Constructor Summary
Constructors Constructor Description BigDataGSpec(CommonG spec)
Generic constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
aMongoDataBaseContainsaTable(String database, String tableName)
Checks if a MongoDB database contains a table.void
assertKeyspaceOnCassandraExists(String keyspace)
Checks if a keyspaces exists in Cassandra.void
assertRowNumberOfTableOnCassandraKeyspace(String keyspace, String tableName, String numberRows)
Checks the number of rows in a cassandra table.void
assertTableExistsOnCassandraKeyspace(String keyspace, String tableName)
Checks if a cassandra keyspace contains a table.void
assertValuesOfTable(String keyspace, String tableName, io.cucumber.datatable.DataTable data)
Checks if a cassandra table contains the values of a DataTable.void
assertValuesOfTableMongo(String dataBase, String tableName, io.cucumber.datatable.DataTable data)
Checks the values of a MongoDB table.void
checkZnodeExists(String zNode, String foo, String document)
Read zPathvoid
checkZnodeNotExist(String zNode)
void
connect(String clusterType, String url)
Connect to cluster.void
connectToElasticSearch(String host, String foo, String nativePort, String bar, String clusterName)
Connect to ElasticSearch using custom parametersvoid
connectToZk(String zookeeperHosts)
Connect to zookeeper.void
createBasicMapping(String index_name, String table, String column, String keyspace)
Create a basic Index.void
createCassandraKeyspace(String keyspace)
Create a Cassandra Keyspace.void
createCustomMapping(String index_name, String schema, String type, String table, String magic_column, String keyspace, io.cucumber.datatable.DataTable modifications)
Create a Cassandra index.void
createElasticsearchIndex(String index, String removeIndex)
Create an elasticsearch index.void
createMongoDBDataBase(String databaseName)
Create a MongoDB dataBase.void
createTableWithData(String table, String keyspace, io.cucumber.datatable.DataTable datatable)
Create tablevoid
createZNode(String path, String foo, String content, boolean ephemeral)
Create zPath and domcumentvoid
disconnectFromZk()
Disconnect from zookeeper.void
dropCassandraKeyspace(String keyspace)
Drop a Cassandra Keyspace.void
dropElasticsearchIndex(String index)
Drop an specific index of ElasticSearch.void
dropElasticsearchIndexes()
Drop all the ElasticSearch indexes.void
dropMongoDBDataBase(String databaseName)
Drop MongoDB Database.void
dropTableWithData(String table, String keyspace)
Drop tablevoid
elasticSearchIndexContainsDocument(String indexName, String mappingName, String columnName, String columnValue)
Check that an elasticsearch index contains a specific documentvoid
elasticSearchIndexDoesNotExist(String indexName)
Check that the ElasticSearch index does not exist.void
elasticSearchIndexExist(String indexName)
Check that the ElasticSearch index exists.void
elasticSearchQueryWithFilter(String indexName, String mappingName, String columnName, String filterType, String value)
Execute query with filter over elasticsearchvoid
indexElasticsearchDocument(String indexName, String mappingName, String key, String value)
Index a document within a mapping type.void
insertData(String keyspace, String table, io.cucumber.datatable.DataTable datatable)
Insert Datavoid
insertOnMongoTable(String dataBase, String tabName, io.cucumber.datatable.DataTable table)
Insert data in a MongoDB table.void
insertOnMongoTable(String dataBase, String collection, String document)
Insert document in a MongoDB table.void
removeZNode(String zNode)
Delete zPath, it should be emptyvoid
saveElasticCluster(String host, String envVar)
Save clustername of elasticsearch in an environment varible for future use.void
sendQueryOfType(String query, String type, String database, String collection, io.cucumber.datatable.DataTable modifications)
Execute a query on (mongo) databasevoid
sendQueryOfType(String fields, String schema, String type, String magic_column, String table, String keyspace, io.cucumber.datatable.DataTable modifications)
Execute a query with schema over a clustervoid
truncateTable(String table, String keyspace)
Truncate tablevoid
truncateTableInMongo(String database, String table)
Truncate table in MongoDB.-
Methods inherited from class com.privalia.qa.specs.BaseGSpec
getCommonSpec
-
-
-
-
Field Detail
-
ES_DEFAULT_NATIVE_PORT
public static final Integer ES_DEFAULT_NATIVE_PORT
-
ES_DEFAULT_CLUSTER_NAME
public static final String ES_DEFAULT_CLUSTER_NAME
- See Also:
- Constant Field Values
-
VALUE_SUBSTRING
public static final int VALUE_SUBSTRING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BigDataGSpec
public BigDataGSpec(CommonG spec)
Generic constructor.- Parameters:
spec
- object
-
-
Method Detail
-
createBasicMapping
@Given("^I create a Cassandra index named \'(.+?)\' in table \'(.+?)\' using magic_column \'(.+?)\' using keyspace \'(.+?)\'$") public void createBasicMapping(String index_name, String table, String column, String keyspace) throws Exception
Create a basic Index.- Parameters:
index_name
- index nametable
- the table where index will be created.column
- the column where index will be savedkeyspace
- keyspace used- Throws:
Exception
- exception
-
createCassandraKeyspace
@Given("^I create a Cassandra keyspace named \'(.+)\'$") public void createCassandraKeyspace(String keyspace)
Create a Cassandra Keyspace.- Parameters:
keyspace
- cassandra keyspace
-
connect
@Given("^I connect to \'(Cassandra|Mongo|Elasticsearch)\' cluster at \'(.+)\'$") public void connect(String clusterType, String url) throws DBException, UnknownHostException
Connect to cluster.- Parameters:
clusterType
- DB type (Cassandra|Mongo|Elasticsearch)url
- url where is started Cassandra cluster- Throws:
DBException
- DBExceptionUnknownHostException
- UnknownHostException
-
connectToElasticSearch
@Given("^I connect to Elasticsearch cluster at host \'(.+?)\'( using native port \'(.+?)\')?( using cluster name \'(.+?)\')?$") public void connectToElasticSearch(String host, String foo, String nativePort, String bar, String clusterName) throws DBException, UnknownHostException, NumberFormatException
Connect to ElasticSearch using custom parameters- Parameters:
host
- ES hostfoo
- regex needed to match methodnativePort
- ES portbar
- regex needed to match methodclusterName
- ES clustername- Throws:
DBException
- exceptionUnknownHostException
- exceptionNumberFormatException
- exception
-
createTableWithData
@Given("^I create a Cassandra table named \'(.+?)\' using keyspace \'(.+?)\' with:$") public void createTableWithData(String table, String keyspace, io.cucumber.datatable.DataTable datatable)
Create table- Parameters:
table
- Cassandra tabledatatable
- datatable used for parsing elementskeyspace
- Cassandra keyspace
-
insertData
@Given("^I insert in keyspace \'(.+?)\' and table \'(.+?)\' with:$") public void insertData(String keyspace, String table, io.cucumber.datatable.DataTable datatable)
Insert Data- Parameters:
table
- Cassandra tabledatatable
- datatable used for parsing elementskeyspace
- Cassandra keyspace
-
saveElasticCluster
@Given("^I obtain elasticsearch cluster name in \'(.+?)\' and save it in variable \'(.+?)\'?$") public void saveElasticCluster(String host, String envVar) throws Exception
Save clustername of elasticsearch in an environment varible for future use.- Parameters:
host
- elasticsearch connectionenvVar
- thread variable where to store the value- Throws:
IllegalAccessException
- exceptionIllegalArgumentException
- exceptionSecurityException
- exceptionNoSuchFieldException
- exceptionClassNotFoundException
- exceptionInstantiationException
- exceptionInvocationTargetException
- exceptionNoSuchMethodException
- exceptionException
-
dropElasticsearchIndexes
@Given("^I drop every existing elasticsearch index$") public void dropElasticsearchIndexes()
Drop all the ElasticSearch indexes.
-
dropElasticsearchIndex
@Given("^I drop an elasticsearch index named \'(.+?)\'$") public void dropElasticsearchIndex(String index)
Drop an specific index of ElasticSearch.- Parameters:
index
- ES index
-
dropCassandraKeyspace
@Given("^I drop a Cassandra keyspace \'(.+)\'$") public void dropCassandraKeyspace(String keyspace)
Drop a Cassandra Keyspace.- Parameters:
keyspace
- Cassandra keyspace
-
createMongoDBDataBase
@Given("^I create a MongoDB dataBase \'(.+?)\'$") public void createMongoDBDataBase(String databaseName)
Create a MongoDB dataBase.- Parameters:
databaseName
- Mongo database
-
dropMongoDBDataBase
@Given("^I drop a MongoDB database \'(.+?)\'$") public void dropMongoDBDataBase(String databaseName)
Drop MongoDB Database.- Parameters:
databaseName
- mongo database
-
insertOnMongoTable
@Given("^I insert into a MongoDB database \'(.+?)\' and table \'(.+?)\' this values:$") public void insertOnMongoTable(String dataBase, String tabName, io.cucumber.datatable.DataTable table)
Insert data in a MongoDB table.- Parameters:
dataBase
- Mongo databasetabName
- Mongo tabletable
- Datatable used for insert elements
-
truncateTableInMongo
@Given("^I drop every document at a MongoDB database \'(.+?)\' and table \'(.+?)\'") public void truncateTableInMongo(String database, String table)
Truncate table in MongoDB.- Parameters:
database
- Mongo databasetable
- Mongo table
-
insertOnMongoTable
@Given("^I insert into MongoDB database \'(.+?)\' and collection \'(.+?)\' the document from schema \'(.+?)\'$") public void insertOnMongoTable(String dataBase, String collection, String document) throws Exception
Insert document in a MongoDB table.- Parameters:
dataBase
- Mongo databasecollection
- Mongo collectiondocument
- document used for schema- Throws:
Exception
- Exception
-
connectToZk
@Given("^I connect to Zookeeper at \'(.+)\'$") public void connectToZk(String zookeeperHosts) throws InterruptedException
Connect to zookeeper.- Parameters:
zookeeperHosts
- as host:port (comma separated)- Throws:
InterruptedException
- exception
-
disconnectFromZk
@Given("^I disconnect from Zookeeper$") public void disconnectFromZk() throws InterruptedException
Disconnect from zookeeper.- Throws:
InterruptedException
- InterruptedException
-
sendQueryOfType
@When("^I execute a query over fields \'(.+?)\' with schema \'(.+?)\' of type \'(json|string)\' with magic_column \'(.+?)\' from table: \'(.+?)\' using keyspace: \'(.+?)\' with:$") public void sendQueryOfType(String fields, String schema, String type, String magic_column, String table, String keyspace, io.cucumber.datatable.DataTable modifications)
Execute a query with schema over a cluster- Parameters:
fields
- columns on which the query is executed. Example: "latitude,longitude" or "*" or "count(*)"schema
- the file of configuration (.conf) with the options of mappin. If schema is the word "empty", method will not add a where clause.type
- type of the changes in schema (string or json)table
- table for create the indexmagic_column
- magic column where index will be saved. If you don't need index, you can add the word "empty"keyspace
- keyspace usedmodifications
- all data in "where" clause. Where schema is "empty", query has not a where clause. So it is necessary to provide an empty table. Example: ||.
-
sendQueryOfType
@When("^I execute a query \'(.+?)\' of type \'(json|string)\' in mongo \'(.+?)\' database using collection \'(.+?)\' with:$") public void sendQueryOfType(String query, String type, String database, String collection, io.cucumber.datatable.DataTable modifications) throws Exception
Execute a query on (mongo) database- Parameters:
query
- path to querytype
- type of data in query (string or json)database
- MongoDB databasecollection
- collection in databasemodifications
- modifications to perform in query- Throws:
Exception
- Exception
-
elasticSearchQueryWithFilter
@When("^I execute an elasticsearch query over index \'(.*?)\' and mapping \'(.*?)\' and column \'(.*?)\' with value \'(.*?)\' to \'(.*?)\'$") public void elasticSearchQueryWithFilter(String indexName, String mappingName, String columnName, String filterType, String value)
Execute query with filter over elasticsearch- Parameters:
indexName
- index namemappingName
- mapping namecolumnName
- column NamefilterType
- it could be equals, gt, gte, lt and lte.value
- value of the column to be filtered.
-
createCustomMapping
@When("^I create a Cassandra index named \'(.+?)\' with schema \'(.+?)\' of type \'(json|string)\' in table \'(.+?)\' using magic_column \'(.+?)\' using keyspace \'(.+?)\' with:$") public void createCustomMapping(String index_name, String schema, String type, String table, String magic_column, String keyspace, io.cucumber.datatable.DataTable modifications) throws Exception
Create a Cassandra index.- Parameters:
index_name
- index nameschema
- the file of configuration (.conf) with the options of mappintype
- type of the changes in schema (string or json)table
- table for create the indexmagic_column
- magic column where index will be savedkeyspace
- keyspace usedmodifications
- data introduced for query fields defined on schema- Throws:
Exception
- Exception
-
dropTableWithData
@When("^I drop a Cassandra table named \'(.+?)\' using keyspace \'(.+?)\'$") public void dropTableWithData(String table, String keyspace)
Drop table- Parameters:
table
- Table namekeyspace
- Keyspace
-
truncateTable
@When("^I truncate a Cassandra table named \'(.+?)\' using keyspace \'(.+?)\'$") public void truncateTable(String table, String keyspace)
Truncate table- Parameters:
table
- table namekeyspace
- keyspace
-
removeZNode
@When("^I remove the zNode \'(.+?)\'$") public void removeZNode(String zNode) throws Exception
Delete zPath, it should be empty- Parameters:
zNode
- Path at zookeeper- Throws:
Exception
- Exception
-
createZNode
@When("^I create the zNode \'(.+?)\'( with content \'(.+?)\')? which (IS|IS NOT) ephemeral$") public void createZNode(String path, String foo, String content, boolean ephemeral) throws Exception
Create zPath and domcument- Parameters:
path
- path at zookeeperfoo
- a dummy match groupcontent
- if it has content it should be definedephemeral
- if it's created as ephemeral or not- Throws:
Exception
- Exception
-
createElasticsearchIndex
@When("^I create an elasticsearch index named \'(.+?)\'( removing existing index if exist)?$") public void createElasticsearchIndex(String index, String removeIndex)
Create an elasticsearch index.- Parameters:
index
- indexremoveIndex
- removeIndex
-
indexElasticsearchDocument
@When("^I index a document in the index named \'(.+?)\' using the mapping named \'(.+?)\' with key \'(.+?)\' and value \'(.+?)\'$") public void indexElasticsearchDocument(String indexName, String mappingName, String key, String value) throws Exception
Index a document within a mapping type.- Parameters:
indexName
- indexNamemappingName
- mappingNamekey
- keyvalue
- value- Throws:
Exception
- Exception
-
assertKeyspaceOnCassandraExists
@Then("^a Cassandra keyspace \'(.+?)\' exists$") public void assertKeyspaceOnCassandraExists(String keyspace)
Checks if a keyspaces exists in Cassandra.- Parameters:
keyspace
- keyspace
-
assertTableExistsOnCassandraKeyspace
@Then("^a Cassandra keyspace \'(.+?)\' contains a table \'(.+?)\'$") public void assertTableExistsOnCassandraKeyspace(String keyspace, String tableName)
Checks if a cassandra keyspace contains a table.- Parameters:
keyspace
- keyspacetableName
- tableName
-
assertRowNumberOfTableOnCassandraKeyspace
@Then("^a Cassandra keyspace \'(.+?)\' contains a table \'(.+?)\' with \'(.+?)\' rows$") public void assertRowNumberOfTableOnCassandraKeyspace(String keyspace, String tableName, String numberRows)
Checks the number of rows in a cassandra table.- Parameters:
keyspace
- keyspacetableName
- tableNamenumberRows
- numberRows
-
assertValuesOfTable
@Then("^a Cassandra keyspace \'(.+?)\' contains a table \'(.+?)\' with values:$") public void assertValuesOfTable(String keyspace, String tableName, io.cucumber.datatable.DataTable data) throws InterruptedException
Checks if a cassandra table contains the values of a DataTable.- Parameters:
keyspace
- keyspacetableName
- tableNamedata
- data- Throws:
InterruptedException
- InterruptedException
-
assertValuesOfTableMongo
@Then("^a Mongo dataBase \'(.+?)\' contains a table \'(.+?)\' with values:") public void assertValuesOfTableMongo(String dataBase, String tableName, io.cucumber.datatable.DataTable data)
Checks the values of a MongoDB table.- Parameters:
dataBase
- dataBasetableName
- tableNamedata
- data
-
aMongoDataBaseContainsaTable
@Then("^a Mongo dataBase \'(.+?)\' doesnt contains a table \'(.+?)\'$") public void aMongoDataBaseContainsaTable(String database, String tableName)
Checks if a MongoDB database contains a table.- Parameters:
database
- databasetableName
- tableName
-
checkZnodeExists
@Then("^the zNode \'(.+?)\' exists( and contains \'(.+?)\')?$") public void checkZnodeExists(String zNode, String foo, String document) throws Exception
Read zPath- Parameters:
zNode
- path at zookeeperdocument
- expected content of znodefoo
- Required parameter for optional string- Throws:
Exception
- Exception
-
checkZnodeNotExist
@Then("^the zNode \'(.+?)\' does not exist") public void checkZnodeNotExist(String zNode) throws Exception
- Throws:
Exception
-
elasticSearchIndexExist
@Then("^An elasticsearch index named \'(.+?)\' exists") public void elasticSearchIndexExist(String indexName)
Check that the ElasticSearch index exists.- Parameters:
indexName
- indexName
-
elasticSearchIndexDoesNotExist
@Then("^An elasticsearch index named \'(.+?)\' does not exist") public void elasticSearchIndexDoesNotExist(String indexName)
Check that the ElasticSearch index does not exist.- Parameters:
indexName
- indexName
-
elasticSearchIndexContainsDocument
@Then("^The Elasticsearch index named \'(.+?)\' and mapping \'(.+?)\' contains a column named \'(.+?)\' with the value \'(.+?)\'$") public void elasticSearchIndexContainsDocument(String indexName, String mappingName, String columnName, String columnValue) throws Exception
Check that an elasticsearch index contains a specific document- Parameters:
indexName
- indexNamecolumnName
- columnNamecolumnValue
- columnValuemappingName
- mappingName- Throws:
Exception
- Exception
-
-