-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Yakubov
committed
Jan 3, 2017
1 parent
5cf5b0d
commit e0a127c
Showing
11 changed files
with
141 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./ps/empty_database |
Empty file.
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,4 @@ | ||
exit_code: 0 | ||
output: | ||
string: '' | ||
exactly: true |
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,4 @@ | ||
#!/bin/bash | ||
|
||
restart_db.sh | ||
|
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,3 @@ | ||
#!/bin/bash | ||
|
||
dcomp ps |
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,4 @@ | ||
exit_code: 0 | ||
output: | ||
file: output_orig | ||
exactly: false |
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,13 @@ | ||
Usage: | ||
dcomp ps [OPTIONS] | ||
|
||
Show job information | ||
-a Show all jobs includng finished | ||
-compress | ||
get log file compressed | ||
-help | ||
Print usage | ||
-id string | ||
Job Id | ||
-log | ||
Get log file for a specified job |
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,4 @@ | ||
#!/bin/bash | ||
|
||
dcomp ps --help | ||
|
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,104 @@ | ||
#!/usr/bin/python | ||
|
||
import os | ||
import subprocess | ||
from subprocess import Popen, PIPE | ||
|
||
import yaml | ||
|
||
DEVNULL = open(os.devnull, 'wb') | ||
|
||
class bcolors: | ||
HEADER = '\033[95m' | ||
OKBLUE = '\033[94m' | ||
OKGREEN = '\033[92m' | ||
WARNING = '\033[93m' | ||
FAIL = '\033[91m' | ||
ENDC = '\033[0m' | ||
BOLD = '\033[1m' | ||
UNDERLINE = '\033[4m' | ||
|
||
failed=[] | ||
include=[] | ||
exclude=[] | ||
|
||
try: | ||
with open("./include", 'r') as f: | ||
include=f.read().splitlines() | ||
except: | ||
pass | ||
|
||
try: | ||
with open("./exclude", 'r') as f: | ||
exclude=f.read().splitlines() | ||
except: | ||
pass | ||
|
||
|
||
|
||
def check_test(path,fname,exit_code,output): | ||
fullname = os.path.join(dirpath,fname) | ||
with open(fullname, 'r') as stream: | ||
struct=yaml.load(stream) | ||
|
||
if struct['exit_code'] != exit_code: | ||
return False | ||
|
||
exactly=True | ||
if 'exactly' in struct['output']: | ||
exactly=struct['output']['exactly'] | ||
|
||
data="" | ||
if 'string' in struct['output']: | ||
data=struct['output']['string'] | ||
elif 'file' in struct['output']: | ||
fullname = os.path.join(dirpath,struct['output']['file']) | ||
with open(fullname, 'r') as myfile: | ||
data=myfile.read() | ||
|
||
data=data.lower().replace(" ", "").replace('\n','') | ||
output=output.lower().replace(" ", "").replace('\n','') | ||
|
||
if exactly: | ||
ok = data == output | ||
else: | ||
ok = output in data or data in output | ||
|
||
return ok | ||
|
||
for dirpath, dirs, files in os.walk("."): | ||
if dirpath in exclude: | ||
continue | ||
if len(include)>0 and dirpath not in include: | ||
continue | ||
|
||
|
||
if "run.sh" in files: | ||
print "Testing " + dirpath + "...", | ||
if "init.sh" in files: | ||
fname = os.path.join(dirpath,"init.sh") | ||
subprocess.call([fname],stdout=DEVNULL) | ||
fname = os.path.join(dirpath,"run.sh") | ||
|
||
p = Popen([fname], stdin=PIPE, stdout=PIPE, stderr=subprocess.STDOUT) | ||
output, err = p.communicate() | ||
exit_code = p.returncode | ||
|
||
result=check_test(dirpath,"check.yaml",exit_code,output) | ||
if "cleanup.sh" in files: | ||
fname = os.path.join(dirpath,"cleanup.sh") | ||
subprocess.call([fname]) | ||
if result: | ||
print bcolors.OKGREEN + "OK" + bcolors.ENDC | ||
else: | ||
print bcolors.FAIL + "FAIL" + bcolors.ENDC | ||
failed.append(dirpath) | ||
|
||
if len(failed)>0: | ||
print bcolors.FAIL + "FAILED:" + bcolors.ENDC | ||
for failure in failed: | ||
print bcolors.FAIL + failure + bcolors.ENDC | ||
exit(1) | ||
else: | ||
print bcolors.OKGREEN + "ALL OK" + bcolors.ENDC | ||
exit(0) |
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,4 @@ | ||
#!/bin/bash | ||
stop_db.sh | ||
start_db.sh | ||
|
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 |
---|---|---|
@@ -1,7 +1 @@ | ||
#docker network create --subnet=172.18.0.0/16 mynet | ||
#docker run --net mynet --ip 172.18.0.2 --name mongodb -p 27017:27017 -d mongo | ||
docker run --name mongodb -p 27017:27017 -d mongo | ||
#docker run --net mynet --ip 172.18.0.3 --name dcompd -P -d yakser/dcompd | ||
#docker run --net mynet --ip 172.18.0.4 --name dcompestd -P -d yakser/dcompestd | ||
#docker run --net mynet --ip 172.18.0.5 --name dcompauthd -P -d yakser/dcompauthd | ||
#docker run --net mynet --ip 172.18.0.6 --name dcompdmd -P -v /dcompdata:/dcompdata -d yakser/dcompdmd |