-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Basic framework for stress testing
- Loading branch information
1 parent
768e4be
commit d8423a3
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
lunit = require "lunit" | ||
|
||
package.path = package.path .. ";../src/?.lua" | ||
|
||
-- Requiring test files | ||
require "stress.test" | ||
|
||
local _, emsg = xpcall(function() | ||
lunit.main(arg) | ||
end, debug.traceback) | ||
if emsg then | ||
print(emsg) | ||
os.exit(1) | ||
end | ||
if lunit.stats.failed > 0 or lunit.stats.errors > 0 then | ||
os.exit(1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
if [ -n "$GITHUB_API_KEY" ]; then | ||
git branch -D stress-test | ||
git checkout -b stress-test | ||
cp tests/stress/.travis.yml .travis.yml | ||
git add .travis.yml | ||
git -c user.name='travis' -c user.email='travis' commit -m "Updated travis.yml for stress tests" | ||
git push -f -q https://DhavalKapil:$GITHUB_API_KEY@github.com/DhavalKapil/elasticsearch-lua stress-test &2>/dev/null | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
language: c | ||
|
||
sudo: required | ||
|
||
env: | ||
global: | ||
- LUAROCKS=2.2.2 | ||
matrix: | ||
- LUA=lua5.1 | ||
- LUA=lua5.2 | ||
- LUA=lua5.3 | ||
- LUA=luajit # latest stable version (2.0.4) | ||
- LUA=luajit2.0 # current head of 2.0 branch | ||
# - LUA=luajit2.1 # current head of 2.1 branch | ||
|
||
before_install: | ||
- sudo apt-get update && sudo apt-get install wget -y | ||
- .travis/install_es.sh | ||
- source .travis/setenv_lua.sh | ||
- luarocks install lunitx | ||
|
||
install: | ||
- luarocks make elasticsearch-scm-0.rockspec | ||
|
||
before_script: | ||
- echo 'elasticsearch version ' && curl http://localhost:9200/ | ||
|
||
script: | ||
- cd tests | ||
- ./dataset/download-dataset.sh | ||
- cd stress | ||
- lua run-test.lua | ||
|
||
after_script: | ||
- git push origin --delete stress-test | ||
|
||
notifications: | ||
email: | ||
on_success: change | ||
on_failure: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local elasticsearch = require "elasticsearch" | ||
local dataset = require "dataset.dataset" | ||
|
||
local client = elasticsearch.client() | ||
|
||
-- Setting up environment | ||
local _ENV = lunit.TEST_CASE "tests.stress.test" | ||
|
||
function test() | ||
local res, status = client:index{ | ||
index = "my_index", | ||
type = "my_type", | ||
id = "my_id", | ||
body = dataset[1] | ||
} | ||
|
||
assert_not_nil(res) | ||
assert_true(res.created) | ||
assert_true(status == 200 or status == 201) | ||
end |