mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Make unit tets run again.
This commit is contained in:
+4
-2
@@ -1,20 +1,22 @@
|
||||
ttl: &ttl 30
|
||||
loop_wait: &loop_wait 10
|
||||
scope: &scope batman
|
||||
restapi:
|
||||
listen: 127.0.0.1:8008
|
||||
connect_address: 127.0.0.1:8008
|
||||
etcd:
|
||||
scope: batman
|
||||
scope: *scope
|
||||
ttl: *ttl
|
||||
host: 127.0.0.1:4001
|
||||
#discovery_srv: my-etcd.domain
|
||||
#zookeeper:
|
||||
# scope: batman
|
||||
# scope: *scope
|
||||
# session_timeout: *ttl
|
||||
# reconnect_timeout: *loop_wait
|
||||
# hosts: 127.0.0.1:2181
|
||||
postgresql:
|
||||
name: postgresql0
|
||||
scope: *scope
|
||||
listen: 127.0.0.1:5432
|
||||
connect_address: 127.0.0.1:5432
|
||||
data_dir: data/postgresql0
|
||||
|
||||
+4
-2
@@ -1,20 +1,22 @@
|
||||
ttl: &ttl 30
|
||||
loop_wait: &loop_wait 10
|
||||
scope: &scope batman
|
||||
restapi:
|
||||
listen: 127.0.0.1:8009
|
||||
connect_address: 127.0.0.1:8009
|
||||
etcd:
|
||||
scope: batman
|
||||
scope: *scope
|
||||
ttl: *ttl
|
||||
host: 127.0.0.1:4001
|
||||
#discovery_srv: my-etcd.domain
|
||||
#zookeeper:
|
||||
# scope: batman
|
||||
# scope: *scope
|
||||
# session_timeout: *ttl
|
||||
# reconnect_timeout: *loop_wait
|
||||
# hosts: 127.0.0.1:2181
|
||||
postgresql:
|
||||
name: postgresql1
|
||||
scope: *scope
|
||||
listen: 127.0.0.1:5433
|
||||
connect_address: 127.0.0.1:5433
|
||||
data_dir: data/postgresql1
|
||||
|
||||
+25
-7
@@ -2,7 +2,7 @@ import unittest
|
||||
import requests
|
||||
import boto.ec2
|
||||
from collections import namedtuple
|
||||
from helpers.aws import AWSConnection
|
||||
from scripts.aws import AWSConnection
|
||||
from requests.exceptions import RequestException
|
||||
import yaml
|
||||
|
||||
@@ -24,6 +24,16 @@ class MockEc2Connection:
|
||||
return True
|
||||
|
||||
|
||||
class MockResponse:
|
||||
|
||||
def __init__(self, content):
|
||||
self.content = content
|
||||
self.ok = True
|
||||
|
||||
def json(self):
|
||||
return self.content
|
||||
|
||||
|
||||
class TestAWSConnection(unittest.TestCase):
|
||||
|
||||
def __init__(self, method_name='runTest'):
|
||||
@@ -44,25 +54,28 @@ class TestAWSConnection(unittest.TestCase):
|
||||
result = namedtuple('Request', 'ok content')
|
||||
result.ok = True
|
||||
if url.split('/')[-1] == 'document':
|
||||
result.content = '{\n "instanceId" : "012345",\n "region" : "eu-west-1"\n}'
|
||||
result = {"instanceId": "012345", "region": "eu-west-1"}
|
||||
else:
|
||||
result.content = 'foo'
|
||||
return result
|
||||
result = 'foo'
|
||||
return MockResponse(result)
|
||||
|
||||
def setUp(self):
|
||||
self.error = False
|
||||
requests.get = self.requests_get
|
||||
boto.ec2.connect_to_region = self.boto_ec2_connect_to_region
|
||||
self.config_string = """
|
||||
loop_wait: 10
|
||||
scope: &scope test
|
||||
ttl: &ttl 30
|
||||
loop_wait: &loop_wait 10
|
||||
restapi:
|
||||
listen: 0.0.0.0:8008
|
||||
connect_address: 127.0.0.1:5432
|
||||
etcd:
|
||||
scope: test
|
||||
ttl: 30
|
||||
scope: *scope
|
||||
ttl: *ttl
|
||||
host: 127.0.0.1:8080
|
||||
postgresql:
|
||||
scope: *scope
|
||||
name: postgresql_foo
|
||||
listen: 0.0.0.0:5432
|
||||
connect_address: 127.0.0.1:5432
|
||||
@@ -76,6 +89,11 @@ postgresql:
|
||||
admin:
|
||||
username: admin
|
||||
password: admin
|
||||
callbacks:
|
||||
on_start: patroni/scripts/aws.py
|
||||
on_stop: patroni/scripts/aws.py
|
||||
on_restart: patroni/scripts/aws.py
|
||||
on_role_change: patroni/scripts/aws.py
|
||||
parameters:
|
||||
archive_mode: "on"
|
||||
wal_level: hot_standby
|
||||
|
||||
@@ -110,15 +110,15 @@ class TestPostgresql(unittest.TestCase):
|
||||
def set_up(self):
|
||||
subprocess.call = subprocess_call
|
||||
shutil.copy = nop
|
||||
self.p = Postgresql({'name': 'test0', 'data_dir': 'data/test0', 'listen': '127.0.0.1, *:5432',
|
||||
'connect_address': '127.0.0.2:5432',
|
||||
self.p = Postgresql({'name': 'test0', 'scope': 'batman', 'data_dir': 'data/test0',
|
||||
'listen': '127.0.0.1, *:5432', 'connect_address': '127.0.0.2:5432',
|
||||
'pg_hba': ['hostssl all all 0.0.0.0/0 md5', 'host all all 0.0.0.0/0 md5'],
|
||||
'superuser': {'password': ''}, 'admin': {'username': 'admin', 'password': 'admin'},
|
||||
'superuser': {'password': ''},
|
||||
'admin': {'username': 'admin', 'password': 'admin'},
|
||||
'replication': {'username': 'replicator',
|
||||
'password': 'rep-pass',
|
||||
'network': '127.0.0.1/32'},
|
||||
'parameters': {'foo': 'bar'}, 'recovery_conf': {'foo': 'bar'}},
|
||||
on_change_callback=lambda state: True)
|
||||
'parameters': {'foo': 'bar'}, 'recovery_conf': {'foo': 'bar'}})
|
||||
psycopg2.connect = psycopg2_connect
|
||||
if not os.path.exists(self.p.data_dir):
|
||||
os.makedirs(self.p.data_dir)
|
||||
|
||||
Reference in New Issue
Block a user