Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel
test_rate_limiting.cpython-311.pyc7.1 kB
� K�h�� �F�dZddlZddlZddlZej�ej�ej�ej�e��������ddl m Z Gd�dej ��Z e dkrej��dSdS)z+ TDD Tests for rate limiting stress tester �N)�RateLimitStressTesterc�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d S) �TestRateLimitStressTesterz.Test rate limiting stress tester functionalityc�<�|�td��dS)z,Test that RateLimitStressTester class existsz(RateLimitStressTester class should existN)�assertIsNotNoner)�selfs �I/home/pshempel/src/local/time-node_tdd/tests/stress/test_rate_limiting.py�$test_rate_limit_stress_tester_existsz>TestRateLimitStressTester.test_rate_limit_stress_tester_existss �� ���2�4^�_�_�_�_�_�c��tdd���}|�|��|�|jd��|�|jd��dS)z8Test that we can create a RateLimitStressTester instance� ���� rate_limit� window_msN)rr� assertEqualrr)r�testers r �test_can_create_tester_instancez9TestRateLimitStressTester.test_can_create_tester_instances`��&�"��E�E�E�� ���V�$�$�$� ����*�B�/�/�/� ����)�4�0�0�0�0�0r c�~�tdd���}|�t|d����|���}|�d|��|�d|��|�d|��|�d|��|�|dd ��d S) zTest burst at limit scenario�rr�test_burst_at_limit�scenario�successful_requests�rate_limited_requests�errors�burst_at_limitN)r� assertTrue�hasattrr�assertInr�rr�results r �test_burst_at_limit_scenarioz6TestRateLimitStressTester.test_burst_at_limit_scenarios���&�!�t�D�D�D�� �����(=�>�>�?�?�?��+�+�-�-�� � � �j�&�)�)�)� � � �+�V�4�4�4� � � �-�v�6�6�6� � � �h��'�'�'� ���� �+�-=�>�>�>�>�>r c���tdd���}|�t|d����|�d���}|�d|��|�d|��|�d |��|�d |��|�|dd ��|�t |d��d��d S) z"Test parallel connections scenariorrr�test_parallel_connections�)�num_connectionsr� connections�total_requests�bypass_detected�parallel_connectionsN)rrrr$rr�lenr s r �"test_parallel_connections_scenarioz<TestRateLimitStressTester.test_parallel_connections_scenario-s���&�!�t�D�D�D�� �����(C�D�D�E�E�E��1�1�!�1�D�D�� � � �j�&�)�)�)� � � �m�V�,�,�,� � � �&��/�/�/� � � �'��0�0�0� ���� �+�-C�D�D�D� ����V�M�2�3�3�Q�7�7�7�7�7r c��tdd���}|�t|d����|�d���}|�d|��|�d|��|�d |��|�d |��|�d |��|�|dd ��d S)z!Test memory exhaustion prevention�di`�r�test_memory_exhaustionr)�duration_secondsr�memory_start_mb� memory_end_mb�memory_growth_mb� requests_made�memory_exhaustionN)rrrr/rrr s r �test_memory_exhaustion_scenarioz9TestRateLimitStressTester.test_memory_exhaustion_scenario?s���&�#��G�G�G�� �����(@�A�A�B�B�B��.�.��.�B�B�� � � �j�&�)�)�)� � � �'��0�0�0� � � �o�v�.�.�.� � � �(�&�1�1�1� � � �o�v�.�.�.� ���� �+�-@�A�A�A�A�Ar c��tdd���}|�t|d����|�d���}|�d|��|�d|��|�d |��|�d |��|�d |��|�|dd ��|�t |d��d��d S)z(Test rapid disconnect/reconnect scenariorrr�test_rapid_reconnectr%)� num_cyclesr�cyclesr(�expected_limited�actual_limited�rapid_reconnectN)rrrr8rrr+r s r �test_rapid_reconnect_scenarioz7TestRateLimitStressTester.test_rapid_reconnect_scenarioQs���&�!�t�D�D�D�� �����(>�?�?�@�@�@��,�,��,�:�:�� � � �j�&�)�)�)� � � �h��'�'�'� � � �&��/�/�/� � � �(�&�1�1�1� � � �&��/�/�/� ���� �+�->�?�?�?� ����V�H�-�.�.��2�2�2�2�2r c���tdd���}|�t|d����dddd�}|�|��}|�|�d ����d S) z&Test that results can be saved to filerrr� save_results�testz2025-01-01T00:00:00T)r� timestamp�successz.jsonN)rrrr@�endswith)rr�results�filenames r �test_can_save_resultsz/TestRateLimitStressTester.test_can_save_resultsds���&�!�t�D�D�D�� ������7�7�8�8�8��.�� � ���&�&�w�/�/�� ����)�)�'�2�2�3�3�3�3�3r N) �__name__� __module__� __qualname__�__doc__r rr"r,r6r>rG�r r rrs�������8�8�`�`�`�1�1�1�?�?�?�"8�8�8�$B�B�B�$3�3�3�&4�4�4�4�4r r�__main__)rK�unittest�sys�os�path�append�dirname�abspath�__file__�stress.rate_limit_stressr�TestCaserrH�mainrLr r �<module>rYs��������� � � � � � � � ������������������0I�0I� J� J�K�K�L�L�L�:�:�:�:�:�:�f4�f4�f4�f4�f4�� 1�f4�f4�f4�R �z����H�M�O�O�O�O�O��r

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pshempel/mcp-time-server-node'

If you have feedback or need assistance with the MCP directory API, please join our Discord server