Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
712u3 committed Feb 15, 2024
1 parent 995d0d9 commit 779bdc1
Show file tree
Hide file tree
Showing 142 changed files with 374 additions and 81 deletions.
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/different_datacenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server

if TYPE_CHECKING:
from frontik.app import FrontikApplication


class Page(PageHandler):
@router.get()
async def get_page(self):
free_server = get_server(self, 'free')
free_server.datacenter = 'dc1'
Expand All @@ -37,6 +38,7 @@ async def get_page(self):

self.text = result.data

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server


class Page(PageHandler):
@router.get()
async def get_page(self):
free_server = get_server(self, 'free')
free_server.datacenter = 'dc1'
Expand All @@ -30,6 +31,7 @@ async def get_page(self):

self.text = result.data

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
3 changes: 3 additions & 0 deletions tests/projects/balancer_app/pages/no_available_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from http_client.request_response import NoAvailableServerException

from frontik import handler, media_types
from frontik.handler import router
from tests.projects.balancer_app.pages import check_all_requests_done


class Page(handler.PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('no_available_backend', {}, []))

Expand All @@ -20,6 +22,7 @@ async def request_with_processing() -> None:
self.run_task(request_with_processing())
check_all_requests_done(self, 'no_available_backend')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from http_client.request_response import NoAvailableServerException

from frontik import handler, media_types
from frontik.handler import router
from tests.projects.balancer_app.pages import check_all_requests_done


class Page(handler.PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('no_available_backend', {}, []))

Expand All @@ -22,6 +24,7 @@ async def get_page(self):

check_all_requests_done(self, 'no_available_backend')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
3 changes: 3 additions & 0 deletions tests/projects/balancer_app/pages/no_retry_error.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from http_client.balancing import Upstream

from frontik import handler, media_types
from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done


class Page(handler.PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('no_retry_error', {}, [get_server(self, 'broken')]))

Expand All @@ -17,6 +19,7 @@ async def get_page(self):

check_all_requests_done(self, 'no_retry_error')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
3 changes: 3 additions & 0 deletions tests/projects/balancer_app/pages/no_retry_error_async.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from http_client.balancing import Upstream

from frontik import handler, media_types
from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done


class Page(handler.PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('no_retry_error_async', {}, [get_server(self, 'broken')]),
Expand All @@ -20,6 +22,7 @@ async def get_page(self):

check_all_requests_done(self, 'no_retry_error_async')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
3 changes: 3 additions & 0 deletions tests/projects/balancer_app/pages/no_retry_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from http_client.balancing import Upstream

from frontik import handler, media_types
from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done


class Page(handler.PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('no_retry_timeout', {}, [get_server(self, 'broken')]),
Expand All @@ -21,6 +23,7 @@ async def get_page(self):

check_all_requests_done(self, 'no_retry_timeout')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
3 changes: 3 additions & 0 deletions tests/projects/balancer_app/pages/no_retry_timeout_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from http_client.balancing import Upstream, UpstreamConfig

from frontik import handler, media_types
from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done


class Page(handler.PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.upstreams['no_retry_timeout_async'] = Upstream(
'no_retry_timeout_async',
Expand All @@ -33,6 +35,7 @@ async def get_page(self):

check_all_requests_done(self, 'no_retry_timeout_async')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/profile_with_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server


class Page(PageHandler):
@router.get()
async def get_page(self):
servers = [get_server(self, 'broken'), get_server(self, 'normal')]
upstream_config = {
Expand All @@ -27,6 +28,7 @@ async def get_page(self):

self.text = result.data

@router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/profile_without_retry.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream, UpstreamConfig

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server


class Page(PageHandler):
@router.get()
async def get_page(self):
servers = [get_server(self, 'broken'), get_server(self, 'normal')]
upstream_config = {
Expand All @@ -26,6 +27,7 @@ async def get_page(self):

self.text = result.data

@router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/requests_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from http_client.balancing import Upstream

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done, check_all_servers_were_occupied


class Page(PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('requests_count', {}, [get_server(self, 'normal')]))
self.text = ''
Expand All @@ -28,6 +29,7 @@ async def request_with_processing() -> None:
await asyncio.sleep(0.1)
check_all_servers_were_occupied(self, 'requests_count')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = str(self.application.upstream_manager.upstreams['requests_count'].servers[0].stat_requests)
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/requests_count_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from http_client.balancing import Upstream

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done, check_all_servers_occupied


class Page(PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('requests_count_async', {}, [get_server(self, 'normal')]),
Expand All @@ -32,6 +33,7 @@ async def get_page(self):

check_all_requests_done(self, 'requests_count_async')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
servers = self.application.upstream_manager.upstreams['requests_count_async'].servers
Expand Down
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/retry_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from frontik.util import gather_list
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied


class Page(PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect', {}, [get_server(self, 'free'), get_server(self, 'normal')]),
Expand All @@ -30,6 +31,7 @@ async def get_page(self):

self.text = self.text + result.data

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/retry_connect_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied


class Page(PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect_async', {}, [get_server(self, 'free'), get_server(self, 'normal')]),
Expand All @@ -36,6 +37,7 @@ async def make_request() -> None:

check_all_servers_were_occupied(self, 'retry_connect_async')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
4 changes: 3 additions & 1 deletion tests/projects/balancer_app/pages/retry_connect_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from frontik.util import gather_list
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied


class Page(PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect_timeout', {}, [get_server(self, 'normal')]),
Expand All @@ -30,6 +31,7 @@ async def get_page(self):

self.text = self.text + result.data

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from tornado.web import HTTPError

from frontik import media_types
from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied


class Page(PageHandler):
@router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect_timeout', {}, [get_server(self, 'normal')]),
Expand All @@ -36,6 +37,7 @@ async def make_request() -> None:

check_all_servers_were_occupied(self, 'retry_connect_timeout')

@router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
3 changes: 2 additions & 1 deletion tests/projects/balancer_app/pages/retry_count_limit.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream, UpstreamConfig

from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.instances import find_free_port
from tests.projects.balancer_app import get_server_with_port


class Page(PageHandler):
@router.get()
async def get_page(self):
upstream = Upstream(
'retry_count_limit',
Expand Down
3 changes: 2 additions & 1 deletion tests/projects/balancer_app/pages/retry_count_limit_async.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream, UpstreamConfig

from frontik.handler import PageHandler
from frontik.handler import PageHandler, router
from tests.instances import find_free_port
from tests.projects.balancer_app import get_server_with_port


class Page(PageHandler):
@router.get()
async def get_page(self):
upstream = Upstream(
'retry_count_limit_async',
Expand Down
Loading

0 comments on commit 779bdc1

Please sign in to comment.