Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
plugged everythinh together
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekziade committed Feb 12, 2013
1 parent d0bd68a commit 15725f2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Makefile
Expand Up @@ -29,13 +29,15 @@ test: build

testjs: build
elasticsearch/bin/elasticsearch -p es.pid; sleep 5
$(BIN)/python tools/create_es.py 9998
-testacular start --single-run
kill $(cat es.pid)
kill `cat es.pid`

elasticsearch:
curl -C - --progress-bar http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$(ES_VERSION).tar.gz | tar -zx
mv elasticsearch-$(ES_VERSION) elasticsearch
chmod a+x elasticsearch/bin/elasticsearch
mv elasticsearch/config/elasticsearch.yml elasticsearch/config/elasticsearch.in.yml
cp elasticsearch.yml elasticsearch/config/elasticsearch.yml
elasticsearch/bin/elasticsearch -p es.pid; sleep 5
$(BIN)/python tools/create_es.py 9998
kill `cat es.pid`
3 changes: 3 additions & 0 deletions monolith/media/lib/monolith.js
Expand Up @@ -32,6 +32,8 @@ Highcharts.setOptions({
});


jQuery.support.cors = true;

function queryES(server, query) {
var result;
query = JSON.stringify(query);
Expand All @@ -42,6 +44,7 @@ function queryES(server, query) {
dataType: "json",
processData: false,
dataType: "json",
//crossDomain: true,
data: query,
async: false,
success: function(json) { result = json;},
Expand Down
21 changes: 8 additions & 13 deletions monolith/tests/client.js
@@ -1,21 +1,16 @@


describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});

describe("Utils suite", function() {
it("'queryES'", function() {

var query = {"query": { "match_all": {}}};

result = queryES("http://0.0.0.0:9998/time_2012-01/_search", query);
var total = result.hits.total;
expect(total).toBe(3100);
});
});

describe("A suite is just a function", function() {
var a;

it("and so is a spec", function() {
a = true;
expect(a).toBe(true);
});
});


12 changes: 9 additions & 3 deletions tools/create_es.py
Expand Up @@ -6,8 +6,8 @@
from pyelasticsearch import ElasticSearch


def feed(index='monolith', type='downloads'):
client = ElasticSearch('http://localhost:9200/')
def feed(index='monolith', type='downloads', es_port=9200):
client = ElasticSearch('http://0.0.0.0:%d/' % es_port)
platforms = ['Mac OS X', 'Windows 8', 'Ubuntu']

# indexing a year of data (2012)
Expand Down Expand Up @@ -47,9 +47,15 @@ def feed(index='monolith', type='downloads'):
sys.stdout.flush()

client.optimize('time_*', max_num_segments=1, wait_for_merge=True)
client.flush()
sys.stdout.write('\nDone!\n')


if __name__ == '__main__':
feed()
if len(sys.argv) > 1:
port = int(sys.argv[1])
else:
port = 9200

feed(es_port=port)

0 comments on commit 15725f2

Please sign in to comment.