Merge branch 'wip' into 'master'
Wip See merge request ungleich-public/ucloud-scheduler!1
This commit is contained in:
commit
3d249b5ce9
8 changed files with 14 additions and 15 deletions
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
3
Pipfile
Normal file → Executable file
3
Pipfile
Normal file → Executable file
|
@ -7,12 +7,15 @@ verify_ssl = true
|
||||||
bandit = "*"
|
bandit = "*"
|
||||||
flake8 = "*"
|
flake8 = "*"
|
||||||
black = "==19.3b0"
|
black = "==19.3b0"
|
||||||
|
pylint = "*"
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
python-decouple = "*"
|
python-decouple = "*"
|
||||||
pytest = "*"
|
pytest = "*"
|
||||||
coverage = "*"
|
coverage = "*"
|
||||||
|
grpcio = "*"
|
||||||
python-etcd3 = {editable = true,git = "https://github.com/kragniz/python-etcd3"}
|
python-etcd3 = {editable = true,git = "https://github.com/kragniz/python-etcd3"}
|
||||||
|
pylint = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.7"
|
python_version = "3.7"
|
||||||
|
|
0
Pipfile.lock
generated
Normal file → Executable file
0
Pipfile.lock
generated
Normal file → Executable file
4
config.py
Normal file
4
config.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from decouple import config
|
||||||
|
from etcd3_wrapper import Etcd3Wrapper
|
||||||
|
|
||||||
|
etcd_client = Etcd3Wrapper(host=config("ETCD_URL"))
|
5
helper.py
Normal file → Executable file
5
helper.py
Normal file → Executable file
|
@ -5,12 +5,9 @@ from ucloud_common.vm import VmPool, VMStatus
|
||||||
from ucloud_common.host import HostPool, HostStatus
|
from ucloud_common.host import HostPool, HostStatus
|
||||||
from ucloud_common.request import RequestEntry, RequestPool, RequestType
|
from ucloud_common.request import RequestEntry, RequestPool, RequestType
|
||||||
|
|
||||||
from etcd3_wrapper import Etcd3Wrapper
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
from config import etcd_client as client
|
||||||
|
|
||||||
client = Etcd3Wrapper(
|
|
||||||
host=config("ETCD_HOST"), port=int(config("ETCD_PORT"))
|
|
||||||
)
|
|
||||||
vm_pool = VmPool(client, config("VM_PREFIX"))
|
vm_pool = VmPool(client, config("VM_PREFIX"))
|
||||||
host_pool = HostPool(client, config("HOST_PREFIX"))
|
host_pool = HostPool(client, config("HOST_PREFIX"))
|
||||||
request_pool = RequestPool(client, config("REQUEST_PREFIX"))
|
request_pool = RequestPool(client, config("REQUEST_PREFIX"))
|
||||||
|
|
6
main.py
Normal file → Executable file
6
main.py
Normal file → Executable file
|
@ -9,7 +9,7 @@ import logging
|
||||||
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
|
||||||
from etcd3_wrapper import Etcd3Wrapper
|
from config import etcd_client as client
|
||||||
|
|
||||||
from ucloud_common.vm import VmPool
|
from ucloud_common.vm import VmPool
|
||||||
from ucloud_common.host import HostPool
|
from ucloud_common.host import HostPool
|
||||||
|
@ -28,9 +28,7 @@ logging.basicConfig(
|
||||||
|
|
||||||
def main(vm_prefix, host_prefix, request_prefix):
|
def main(vm_prefix, host_prefix, request_prefix):
|
||||||
logging.info(f"{'*' * 5} SESSION STARTED {'*' * 5}")
|
logging.info(f"{'*' * 5} SESSION STARTED {'*' * 5}")
|
||||||
client = Etcd3Wrapper(
|
|
||||||
host=config("ETCD_HOST"), port=int(config("ETCD_PORT"))
|
|
||||||
)
|
|
||||||
vm_pool = VmPool(client, vm_prefix)
|
vm_pool = VmPool(client, vm_prefix)
|
||||||
host_pool = HostPool(client, host_prefix)
|
host_pool = HostPool(client, host_prefix)
|
||||||
request_pool = RequestPool(client, request_prefix)
|
request_pool = RequestPool(client, request_prefix)
|
||||||
|
|
5
tests/test_basics.py
Normal file → Executable file
5
tests/test_basics.py
Normal file → Executable file
|
@ -20,13 +20,12 @@ from main import (
|
||||||
main,
|
main,
|
||||||
)
|
)
|
||||||
|
|
||||||
from etcd3_wrapper import Etcd3Wrapper
|
from config import etcd_client
|
||||||
|
|
||||||
|
|
||||||
class TestFunctions(unittest.TestCase):
|
class TestFunctions(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.client = Etcd3Wrapper()
|
cls.client = etcd_client
|
||||||
cls.host_prefix = "/test/host"
|
cls.host_prefix = "/test/host"
|
||||||
cls.vm_prefix = "/test/vm"
|
cls.vm_prefix = "/test/vm"
|
||||||
|
|
||||||
|
|
6
tests/test_dead_host_mechanism.py
Normal file → Executable file
6
tests/test_dead_host_mechanism.py
Normal file → Executable file
|
@ -16,14 +16,12 @@ from main import (
|
||||||
dead_host_detection,
|
dead_host_detection,
|
||||||
dead_host_mitigation,
|
dead_host_mitigation,
|
||||||
main,
|
main,
|
||||||
|
config
|
||||||
)
|
)
|
||||||
|
|
||||||
from etcd3_wrapper import Etcd3Wrapper
|
|
||||||
|
|
||||||
|
|
||||||
class TestDeadHostMechanism(unittest.TestCase):
|
class TestDeadHostMechanism(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.client = Etcd3Wrapper()
|
self.client = config.etcd_client
|
||||||
self.host_prefix = "/test/host"
|
self.host_prefix = "/test/host"
|
||||||
self.vm_prefix = "/test/vm"
|
self.vm_prefix = "/test/vm"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue