<commit_before>## Connections Stress Test

Verify that ContextBroker works properly with a large number of stablished connections.

#### Tests procedure:
- drop the database in mongo
- create 5000 subscriptions with subject.entities.idPattern: .*
- verify/modify the notification listener with a delay of 10 minutes before answering (recomend to use `notif_listener_with_delay_in_response` script).
- modify the ContextBroker config with: `"-httpTimeout 600000 -notificationMode threadpool:60000:5000"` and restart it.
- launch an entity update, that it triggers all subscriptions.
- launch indefinitely a "/version" request per second and:
     - report that its response is correct.
     - report the number of established connections (if `-noEstablished` param is used this column is ignored)
     - report the queue size into ContextBroker (if `-noQueueSize` param is used this column is ignored)
     
#### Mehod of use:
- firstly, launch established connections listener (rpyc_classic.py) in CB machine. 
    - download from `https://pypi.python.org/pypi/rpyc`
    - install the dependencies: `pip install rpyc psutil`
    - unzip and execute `python bin/rpyc_classic.py`
    Note: if you have problem with `psutil` installation, use `yum install python-devel python-psutil` to install it on your CentOS system.
- after, launch the notifications listener `./notif_listener_with_delay_in_response`.
- ContextBroker configuration recommended:
```
    BROKER_EXTRA_OPS="-reqMutexPolicy none -writeConcern 0 -httpTimeout 600000 -notificationMode threadpool:60000:5000 -statTiming -statSemWait -statCounters -statNotifQueue -multiservice -subCacheIval 5"
```   
- finally, execute in local the `connections_stress_test.py` script
   
#### Usage
       Parameters:                                                                                                  
          -host=<host>         : CB host (OPTIONAL) (default: localhost).                                           
          -u                   : show this usage (OPTIONAL).                                                        
          -v                   : verbose with all responses (OPTIONAL) (default: False). 
          -noEstablished       : is used to ignore the established connections (OPTIONAL) (default: False).                         
          -noQueueSize         : is used to ignore the Queue size (OPTIONAL) (default: False).                         
          -service=<value>     : service header (OPTIONAL) (default: epoll).                                        
          -service_path=<value>: service path header (OPTIONAL) (default: /test)                                    
          -notif_url=<value>   : url used to notifications (OPTIONAL) (default: http://localhost:9999/notify)       
          -mongo=<value>       : mongo host used to clean de bd (OPTIONAL) (default: localhost)                     
          -duration=<value>    : test duration, value is in minutes (OPTIONAL) (default: 60 minutes)                
                                                                                                                    
       Examples:                                                                                                    
        python connections_stress_tests.py -host=10.10.10.10 -notif_url=http://10.0.0.1:1234/notify duration=100 -v 
                                                                                                                    
       Note:                                                                                                        
         - the version delay is a second                                                                            
         - the number of subscriptions is 5000     

#### notif_listener_with_delay_in_response script
It is a server to receive all notifications sent from CB, the port used is `8090` and any path is allowed. <commit_msg>[REFACTOR]in doc<commit_after>## Connections Stress Test

Verify that ContextBroker works properly with a large number of stablished connections.

#### Tests procedure:
- drop the database in mongo
- create 5000 subscriptions with subject.entities.idPattern: .*
- verify/modify the notification listener with a delay of 10 minutes before answering (recomend to use `notif_listener_with_delay_in_response` script).
- modify the ContextBroker config with: `"-httpTimeout 600000 -notificationMode threadpool:60000:5000"` and restart it.
- launch an entity update, that it triggers all subscriptions.
- launch indefinitely a "/version" request per second and:
     - report that its response is correct.
     - report the number of established connections (if `-noEstablished` param is used this column is ignored)
     - report the queue size into ContextBroker (if `-noQueueSize` param is used this column is ignored)
     
#### Mehod of use:
- firstly, launch established connections listener (rpyc_classic.py) in CB machine. 
    - download from `https://pypi.python.org/pypi/rpyc`
    - install the dependencies: `pip install rpyc psutil`. If you have problem with `psutil` installation, use `yum install python-devel python-psutil` to install it on your CentOS system.
    - unzip and execute `python bin/rpyc_classic.py`.
- after, launch the notifications listener `./notif_listener_with_delay_in_response`.
- ContextBroker configuration recommended:
```
    BROKER_EXTRA_OPS="-reqMutexPolicy none -writeConcern 0 -httpTimeout 600000 -notificationMode threadpool:60000:5000 -statTiming -statSemWait -statCounters -statNotifQueue -multiservice -subCacheIval 5"
```   
- finally, execute in local the `connections_stress_test.py` script
   
#### Usage
       Parameters:                                                                                                  
          -host=<host>         : CB host (OPTIONAL) (default: localhost).                                           
          -u                   : show this usage (OPTIONAL).                                                        
          -v                   : verbose with all responses (OPTIONAL) (default: False). 
          -noEstablished       : is used to ignore the established connections (OPTIONAL) (default: False).                         
          -noQueueSize         : is used to ignore the Queue size (OPTIONAL) (default: False).                         
          -service=<value>     : service header (OPTIONAL) (default: epoll).                                        
          -service_path=<value>: service path header (OPTIONAL) (default: /test)                                    
          -notif_url=<value>   : url used to notifications (OPTIONAL) (default: http://localhost:9999/notify)       
          -mongo=<value>       : mongo host used to clean de bd (OPTIONAL) (default: localhost)                     
          -duration=<value>    : test duration, value is in minutes (OPTIONAL) (default: 60 minutes)                
                                                                                                                    
       Examples:                                                                                                    
        python connections_stress_tests.py -host=10.10.10.10 -notif_url=http://10.0.0.1:1234/notify duration=100 -v 
                                                                                                                    
       Note:                                                                                                        
         - the version delay is a second                                                                            
         - the number of subscriptions is 5000     

#### notif_listener_with_delay_in_response script
It is a server to receive all notifications sent from CB, the port used is `8090` and any path is allowed. 
{'fraction_non_alphanumeric': 0.06752818953503104, 'fraction_numerical': 0.018244013683010263, 'mean_word_length': 1.4614904895541003, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 68, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7052315', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1694, 'n_words': 634}