v0.5.10: главная — полное руководство: задержка, сброс, fail-next, отладка, lifecycle
This commit is contained in:
@@ -80,7 +80,7 @@ SERVICES = _DF["SERVICES"]
|
|||||||
OPS_INDEX = _DF["OPS_INDEX"]
|
OPS_INDEX = _DF["OPS_INDEX"]
|
||||||
|
|
||||||
DELAY = float(os.getenv("MOCK_OP_DELAY", "0.1"))
|
DELAY = float(os.getenv("MOCK_OP_DELAY", "0.1"))
|
||||||
VERSION = "0.5.9"
|
VERSION = "0.5.10"
|
||||||
|
|
||||||
|
|
||||||
def get_services(stand_id):
|
def get_services(stand_id):
|
||||||
|
|||||||
@@ -175,6 +175,34 @@ main {
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Feature Grid ── */
|
||||||
|
.feature-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-item {
|
||||||
|
background: var(--brand-grey-light);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-item h4 {
|
||||||
|
font-size: 15px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-item p {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-item .code-block {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Dots ── */
|
/* ── Dots ── */
|
||||||
.dot {
|
.dot {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@@ -92,31 +92,85 @@
|
|||||||
{% if stands_list|length > 1 %}<span class="muted">Стенд: <strong>{{ current_stand }}</strong></span>{% endif %}
|
{% if stands_list|length > 1 %}<span class="muted">Стенд: <strong>{{ current_stand }}</strong></span>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h3 class="h4">1. Получить список сервисов</h3>
|
|
||||||
|
<h3 class="h4">📡 Базовые команды</h3>
|
||||||
|
|
||||||
|
<p><strong>Получить список сервисов:</strong></p>
|
||||||
<pre class="code-block"><code>curl -s {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/services | python3 -m json.tool</code></pre>
|
<pre class="code-block"><code>curl -s {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/services | python3 -m json.tool</code></pre>
|
||||||
|
|
||||||
<h3 class="h4">2. Создать инстанс</h3>
|
<p><strong>Создать инстанс:</strong></p>
|
||||||
<pre class="code-block"><code>curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instances \
|
<pre class="code-block"><code>curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instances \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"serviceId": 1, "displayName": "my-instance"}' | python3 -m json.tool</code></pre>
|
-d '{"serviceId": 1, "displayName": "my-instance"}' | python3 -m json.tool</code></pre>
|
||||||
|
|
||||||
<h3 class="h4">3. Создать и запустить операцию</h3>
|
<p><strong>Создать операцию, установить параметры, запустить:</strong></p>
|
||||||
<pre class="code-block"><code># Создать операцию
|
<pre class="code-block"><code># 1. Создать операцию (получить opUid из ответа)
|
||||||
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instanceOperations \
|
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instanceOperations \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"instanceUid": "<uid>", "operation": "create", "svcOperationId": 18}'
|
-d '{"instanceUid": "<uid>", "operation": "create", "svcOperationId": 18}'
|
||||||
|
|
||||||
# Установить параметры
|
# 2. Установить каждый параметр (повторить для всех)
|
||||||
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instanceOperationCfsParams \
|
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instanceOperationCfsParams \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"instanceOperationUid": "<opUid>", "svcOperationCfsParamId": 242, "paramValue": "my-value"}'
|
-d '{"instanceOperationUid": "<opUid>", "svcOperationCfsParamId": 242, "paramValue": "my-value"}'
|
||||||
|
|
||||||
# Запустить
|
# 3. Запустить операцию (будет ждать {{ delay }}s)
|
||||||
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instanceOperations/<opUid>/run</code></pre>
|
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/instanceOperations/<opUid>/run</code></pre>
|
||||||
|
|
||||||
<h3 class="h4">4. Сбросить состояние</h3>
|
<hr style="margin: 20px 0; border: none; border-top: 1px solid var(--border);">
|
||||||
<pre class="code-block"><code>curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/reset \
|
|
||||||
-H "X-Mock-Auth: test-token-123"</code></pre>
|
<h3 class="h4">🛠 Управление полигоном (служебные эндпоинты)</h3>
|
||||||
|
|
||||||
|
<div class="feature-grid">
|
||||||
|
<div class="feature-item">
|
||||||
|
<h4>⏱ Задержка операций</h4>
|
||||||
|
<p>Каждый <code>POST /run</code> ждёт <strong>{{ delay }} секунд</strong> перед ответом — эмуляция времени выполнения в облаке.</p>
|
||||||
|
<p><strong>Текущая:</strong> <code>{{ delay }}s</code></p>
|
||||||
|
<pre class="code-block"><code># Сделать операции мгновенными
|
||||||
|
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/delay/0
|
||||||
|
|
||||||
|
# Поставить задержку 3 секунды
|
||||||
|
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/delay/3
|
||||||
|
|
||||||
|
# Максимум — 5 секунд (защита healthcheck'а)</code></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="feature-item">
|
||||||
|
<h4>🧹 Сброс состояния</h4>
|
||||||
|
<p>Удаляет <strong>все</strong> инстансы и операции на текущем стенде. Полезно перед каждым тестом.</p>
|
||||||
|
<pre class="code-block"><code>curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/reset</code></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="feature-item">
|
||||||
|
<h4>💥 Симуляция ошибок</h4>
|
||||||
|
<p>Следующий <code>POST /run</code> <strong>упадёт</strong> с ошибкой. One-shot: после использования флаг сбрасывается.</p>
|
||||||
|
<pre class="code-block"><code># Включить
|
||||||
|
curl -s -X POST {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/fail-next
|
||||||
|
|
||||||
|
# Следующий run → {"ok": false, "error": "mock failure..."}
|
||||||
|
# После этого — снова работает нормально</code></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="feature-item">
|
||||||
|
<h4>📊 Отладка</h4>
|
||||||
|
<p>Посмотреть текущее состояние всех инстансов и операций:</p>
|
||||||
|
<pre class="code-block"><code>curl -s {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/state | python3 -m json.tool</code></pre>
|
||||||
|
<p>Список загруженных сервисов:</p>
|
||||||
|
<pre class="code-block"><code>curl -s {{ endpoint }}/{% if stands_list|length > 1 %}{{ current_stand }}/{% endif %}api/v1/svc/_mock/services | python3 -m json.tool</code></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr style="margin: 20px 0; border: none; border-top: 1px solid var(--border);">
|
||||||
|
|
||||||
|
<h3 class="h4">🔁 Жизненный цикл операции</h3>
|
||||||
|
<ol style="line-height: 2;">
|
||||||
|
<li><code>GET /instanceOperations/default/{svcOperationId}</code> — узнать какие параметры нужны</li>
|
||||||
|
<li><code>POST /instanceOperations</code> — создать операцию (получить opUid)</li>
|
||||||
|
<li><code>POST /instanceOperationCfsParams</code> × N — установить каждый параметр</li>
|
||||||
|
<li><code>GET /{opUid}/validate-cfs</code> — проверить корректность</li>
|
||||||
|
<li><code>POST /{opUid}/run</code> — выполнить (ждёт <strong>{{ delay }}s</strong>)</li>
|
||||||
|
<li><code>GET /{opUid}?fields=dtFinish,isSuccessful</code> — проверить результат</li>
|
||||||
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user