diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-19 20:14:42 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-19 20:14:42 (GMT) |
commit | cf182734df3a529a8006ec3926d4ba211454016a (patch) | |
tree | 3f64a268dfc1d9cd16751a4225ccf006bbde739a /webapp | |
parent | 3ddbc51283961373366bb8400f2b4a1b4fdc222e (diff) |
Cleaning deploy directory
Diffstat (limited to 'webapp')
-rwxr-xr-x | webapp/deploy/deploy | 4 | ||||
-rw-r--r-- | webapp/deploy/deploy.py | 15 | ||||
-rw-r--r-- | webapp/deploy/deploy_prod.sh | 25 | ||||
-rw-r--r-- | webapp/deploy/deploy_staging.sh | 26 | ||||
-rw-r--r-- | webapp/deploy/envs.py | 22 | ||||
-rw-r--r-- | webapp/deploy/mocks.py | 12 | ||||
-rw-r--r-- | webapp/deploy/requirements.py | 21 | ||||
-rw-r--r-- | webapp/deploy/settings.py | 12 | ||||
-rw-r--r-- | webapp/deploy/test_deploy.py | 70 | ||||
-rw-r--r-- | webapp/deploy/test_requirements.py | 28 |
10 files changed, 0 insertions, 235 deletions
diff --git a/webapp/deploy/deploy b/webapp/deploy/deploy deleted file mode 100755 index 18af6bf..0000000 --- a/webapp/deploy/deploy +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -SCRIPT_BASE=`dirname $0` -python $SCRIPT_BASE/deploy.py $1 diff --git a/webapp/deploy/deploy.py b/webapp/deploy/deploy.py deleted file mode 100644 index 599804e..0000000 --- a/webapp/deploy/deploy.py +++ /dev/null @@ -1,15 +0,0 @@ -import sys - -from settings import CONFIG - - -def main(env_name): - env = CONFIG[env_name]['class']() - reqs = CONFIG[env_name]['requirements'] - - ret_val = 0 if env.check([r() for r in reqs]) else 1 - sys.exit(ret_val) - - -if __name__ == '__main__': - main(sys.argv[1]) diff --git a/webapp/deploy/deploy_prod.sh b/webapp/deploy/deploy_prod.sh deleted file mode 100644 index 780b03a..0000000 --- a/webapp/deploy/deploy_prod.sh +++ /dev/null @@ -1,25 +0,0 @@ -cd $WORKSPACE - -# hacer el archive -ARCHIVE="$BUILD_NUMBER.tar" -git archive --format=tar HEAD webapp > $ARCHIVE - -# Copiar al server -PROD=190.0.148.232 -USER=activitycentral -scp $ARCHIVE $USER@$PROD: - -#pisar -REPO=virtualenvs/polls -ssh $USER@$PROD <<END -tar --overwrite --exclude='webapp/db' -xvf $ARCHIVE -C $REPO -sudo chown -R www-data $REPO/webapp/webapp/media -sudo chown -R www-data $REPO/webapp/db -cp -f $REPO/webapp/deploy/prod/env_settings.py $REPO/webapp/webapp/ -END - -# reiniciar uwsgi y apache -ssh $USER@$PROD <<END -sudo service uwsgi restart -sudo service apache2 restart -END diff --git a/webapp/deploy/deploy_staging.sh b/webapp/deploy/deploy_staging.sh deleted file mode 100644 index 5b97ab3..0000000 --- a/webapp/deploy/deploy_staging.sh +++ /dev/null @@ -1,26 +0,0 @@ -cd $WORKSPACE - -# hacer el archive -ARCHIVE="$BUILD_NUMBER.tar" -git archive --format=tar HEAD webapp > $ARCHIVE - -# Copiar al server -ENV=staging -SERVER=127.0.0.1 -USER=ceibal -scp $ARCHIVE $USER@$SERVER: - -#pisar -REPO=virtualenvs/polls/$ENV -ssh $USER@$SERVER <<END -tar --overwrite --exclude='webapp/db' -xvf $ARCHIVE -C $REPO -sudo chown -R www-data $REPO/webapp/webapp/media -sudo chown -R www-data $REPO/webapp/db -cp -f $REPO/webapp/deploy/$ENV/env_settings.py $REPO/webapp/webapp/ -END - -# reiniciar uwsgi y apache -ssh $USER@$SERVER <<END -sudo service uwsgi restart -sudo service apache2 restart -END diff --git a/webapp/deploy/envs.py b/webapp/deploy/envs.py deleted file mode 100644 index 2b97dd4..0000000 --- a/webapp/deploy/envs.py +++ /dev/null @@ -1,22 +0,0 @@ -class Env(object): - - def check(self, reqs): - for r in reqs: - if not r.is_satified_in(self): - return False - return True - - def __str__(self): - return "ENV" - - -class ValidEnv(Env): - - def __str__(self): - return "VALID_ENV" - - -class NginxEnv(Env): - - def __str__(self): - return "NGINX_ENV" diff --git a/webapp/deploy/mocks.py b/webapp/deploy/mocks.py deleted file mode 100644 index a1bdaab..0000000 --- a/webapp/deploy/mocks.py +++ /dev/null @@ -1,12 +0,0 @@ -class MockFabric(object): - - def __init__(self): - self._succeeded = None - - @property - def succeeded(self): - return self._succeeded - - @succeeded.setter - def succeeded(self, value): - self._succeeded = value diff --git a/webapp/deploy/requirements.py b/webapp/deploy/requirements.py deleted file mode 100644 index 5a0a595..0000000 --- a/webapp/deploy/requirements.py +++ /dev/null @@ -1,21 +0,0 @@ -class EasyRequirement(object): - - def is_satified_in(self, env): - return True - - -class HardRequirement(object): - - def is_satified_in(self, env): - return False - - -class NginxRequirement(object): - - def __init__(self, remote_run): - self.remote_run = remote_run - - def is_satisfied_in(self, env): - cmd = "" - output = self.remote_run(cmd) - return True if output.succeeded else False diff --git a/webapp/deploy/settings.py b/webapp/deploy/settings.py deleted file mode 100644 index 1ea77f7..0000000 --- a/webapp/deploy/settings.py +++ /dev/null @@ -1,12 +0,0 @@ -from envs import ValidEnv -from requirements import EasyRequirement - - -CONFIG = { - 'VALID_ENV': { - 'class': ValidEnv, - 'requirements': [ - EasyRequirement, - ] - } -} diff --git a/webapp/deploy/test_deploy.py b/webapp/deploy/test_deploy.py deleted file mode 100644 index aad22ef..0000000 --- a/webapp/deploy/test_deploy.py +++ /dev/null @@ -1,70 +0,0 @@ -import unittest -import os - -from fabric.api import local, hide, settings - -from envs import Env -from requirements import EasyRequirement, HardRequirement - -SCRIPT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'deploy {0}') - - -class RunDeployTEST(unittest.TestCase): - - def test_it_should_run_without_errors(self): - command = SCRIPT.format('VALID_ENV') - with settings(warn_only=True), hide('everything'): - ret_val = local(command, capture=True) - self.assertTrue(ret_val.succeeded) - - def test_it_should_fail_with_dirty_env(self): - dirty_env = Env() - command = SCRIPT.format(dirty_env) - with settings(warn_only=True), hide('everything'): - ret_val = local(command, capture=True) - self.assertTrue(ret_val.failed) - - -class CheckEnvTesst(unittest.TestCase): - - def setUp(self): - self.env = Env() - - def test_it_should_succeed_with_empty_reqs(self): - empty_env = Env() - requirements = [] - self.assertTrue(empty_env.check(requirements)) - - def test_it_shoud_fail_with_unsatisfied_reqs(self): - env = self.env - requirement1 = HardRequirement() - requirement2 = HardRequirement() - reqs = [requirement1, requirement2] - self.assertFalse(env.check(reqs)) - - def test_it_should_succeed_with_satisfied_reqs(self): - env = self.env - requirement1 = EasyRequirement() - requirement2 = EasyRequirement() - reqs = [requirement1, requirement2] - self.assertTrue(env.check(reqs)) - - def test_it_should_fail_with_satisfied_reqs_but_one(self): - env = self.env - requirement1 = EasyRequirement() - requirement2 = HardRequirement() - requirement3 = EasyRequirement() - reqs = [requirement1, requirement2, requirement3] - self.assertFalse(env.check(reqs)) - - -class SatisfyRequirementTest(unittest.TestCase): - - def test_is_should_succeed_with_a_valid_env(self): - valid_env = Env() - requirement = EasyRequirement() - self.assertTrue(requirement.is_satified_in(valid_env)) - - -if __name__ == '__main__': - unittest.main() diff --git a/webapp/deploy/test_requirements.py b/webapp/deploy/test_requirements.py deleted file mode 100644 index 4898b99..0000000 --- a/webapp/deploy/test_requirements.py +++ /dev/null @@ -1,28 +0,0 @@ -import unittest - -from envs import Env, NginxEnv -from requirements import NginxRequirement -from mocks import MockFabric - - -class NginxRequirementTest(unittest.TestCase): - - def test_it_should_success_if_nginx_is_installed(self): - nginx_env = NginxEnv() - mock_fabric_run = MockFabric() - mock_fabric_run.succeeded = True - nginx_req = NginxRequirement(lambda cmd: mock_fabric_run) - - self.assertTrue(nginx_req.is_satisfied_in(nginx_env)) - - def test_it_should_fail_if_nginx_is_not_installed(self): - no_nginx_env = Env() - mock_fabric_run = MockFabric() - mock_fabric_run.succeeded = False - nginx_req = NginxRequirement(lambda cmd: mock_fabric_run) - - self.assertFalse(nginx_req.is_satisfied_in(no_nginx_env)) - - -if __name__ == '__main__': - unittest.main() |