Skip to content

Commit

Permalink
Added Basic framework for stress testing
Browse files Browse the repository at this point in the history
  • Loading branch information
DhavalKapil committed Jul 3, 2016
1 parent 768e4be commit 2b18ffc
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -36,6 +36,7 @@ after_success:
- mv luacov.stats.out ../
- cd ../
- luacov-coveralls -c tests/.luacov
- tests/run-stress-test.sh

notifications:
email:
Expand Down
17 changes: 17 additions & 0 deletions tests/run-stress-test.lua
@@ -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
13 changes: 13 additions & 0 deletions tests/run-stress-test.sh
@@ -0,0 +1,13 @@
#!/bin/bash

if [ -n "$GITHUB_API_KEY" ]; then
git ls-remote --exit-code origin stress-test
if ! test $? = 0; 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
fi
fi
39 changes: 39 additions & 0 deletions tests/stress/.travis.yml
@@ -0,0 +1,39 @@
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
- lua run-test.lua

after_script:
- git push https://DhavalKapil:$GITHUB_API_KEY@github.com/DhavalKapil/elasticsearch-lua --delete stress-test

notifications:
email:
on_success: change
on_failure: always
20 changes: 20 additions & 0 deletions tests/stress/test.lua
@@ -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

0 comments on commit 2b18ffc

Please sign in to comment.