
    Yaj                    R    d dl mZ d dlmZ d dlmZmZmZ ddZdd	Z	dd
Z
ddZdS )    )annotations)Path)ALLOWED_ACTIONSrestart_system_componentsystem_statustmp_pathr   returnNonec                   | dz  }| dz  }|                                  |                                  t          ||d          }|d         dk    sJ |d         d         d	v sJ |d
         d         d	v sJ |d         dk    sJ |d         du sJ dt          |                                          vsJ dt          |                                          vsJ d S )Nruntimerepozhttp://100.85.29.67:8000)runtime_dir	repo_rootapi_urlpurposesystem_ops_status_v1backendstatus>   offlinerunningfrontendr   runtime_db_availableFtokensecret)mkdirr   strlower)r   r   r   r   s       )tests/unit/test_system_ops_controls_v1.pyCtest_system_status_reports_backend_frontend_runtime_without_secretsr      s   "GfDMMOOOTZZ\\\w$HbcccF) 66666)X&*@@@@@*h'+AAAAA) :::::()U2222#f++++------3v;;,,........    c                4   | dz  }| dz  }|dz  }|                     d           |                                  |dz  }|                    dd	           |                    d
           t          d||          }|d         dk    sJ |d         dk    sJ |d         sJ |d         dk    sJ |d         sJ dt	          |                                          vsJ |dz  dz  }|                                sJ d|                    d	          v sJ d S )Nr   r   scriptsTparentszrestart_frontend.shz,#!/usr/bin/env bash
echo restarted frontend
utf-8encoding  r   r   r   r   	scheduledactionrestart_frontendmessagescriptzscripts/restart_frontend.sh
worker_pidzrestarted frontendlogszops_actions.jsonl)r   
write_textchmodr   r   r   exists	read_text)r   r   r   r"   r.   resultops_logs          r   Ftest_restart_uses_only_allowed_repo_scripts_and_writes_runtime_ops_logr7      se   "GfDYGMM$MMMOOO,,F
FQXYYY
LL%jgQUVVVF({****(11111)(<<<<<,s6{{'8'8':':::::!44G>>!2!2G!2!D!DDDDDDDr    c                8   | dz  }| dz  }|                                  |                                  t          t                    h dk    sJ 	 t          d||           t	          d          # t
          $ r}dt          |          v sJ Y d }~d S d }~ww xY w)Nr   r   >   r   r   	dashboardzrm -rf /r)   zfree-form command was acceptedunsupported_system_action)r   setr   r   AssertionError
ValueErrorr   )r   r   r   excs       r   Dtest_restart_rejects_unknown_actions_and_never_accepts_free_commandsr?   .   s    "GfDMMOOOTZZ\\\#G#G#GGGGG? DQQQQ =>>>  7 7 7*c#hh66666666667s   A1 1
B;BBc                   | dz  }| dz  }|dz  }|                     d           |                                  |dz  }|                    dd	           |                    d
           t          d||          }|d         dk    sJ |d         J |d                             d          sJ dt          |          vsJ d S )Nr   r   r"   Tr#   zrestart_backend.shz:#!/usr/bin/env bash
echo redacted-sensitive-marker
exit 7
r%   r&   r(   r   r)   r   r*   return_code
worker_logzrestart_backend.logzredacted-sensitive-marker)r   r1   r2   r   endswithr   )r   r   r   r"   r.   r5   s         r   9test_restart_schedules_worker_without_returning_long_logsrD   <   s    "GfDYGMM$MMMOOO++F
U`ghhh
LL%iWPTUUUF({****- (((,(()>?????&c&kk999999r    N)r   r   r	   r
   )
__future__r   pathlibr   "jarvis_finance.services.system_opsr   r   r   r   r7   r?   rD    r    r   <module>rI      s    " " " " " "       g g g g g g g g g g/ / / /E E E E.? ? ? ?: : : : : :r    