From dac9c3293bdb80c8958af1cc975a72dc9182ac96 Mon Sep 17 00:00:00 2001 From: Naeel Date: Fri, 20 Mar 2026 13:19:39 +0300 Subject: [PATCH] feat: remove stress_* functions from examples/POSTGRES --- examples/POSTGRES/functions.tf | 160 +-------------------------------- 1 file changed, 2 insertions(+), 158 deletions(-) diff --git a/examples/POSTGRES/functions.tf b/examples/POSTGRES/functions.tf index 0d081b8..27ee8b2 100644 --- a/examples/POSTGRES/functions.tf +++ b/examples/POSTGRES/functions.tf @@ -1,7 +1,8 @@ +// 2026-03-20 — удалены stress_* функции (oneshot/Job). Архив: git history. // 2026-03-20 — выделено из resources.tf: sless функции, сервисы и джобы. // 2026-03-19 — миграция: sless_function (oneshot/Job) + sless_service (long-running Deployment). // sless_trigger(type=http) удалены — HTTP URL теперь автоматически в sless_service. -// postgres_sql_runner_create_table и stress-* остаются sless_function (oneshot/Job). +// postgres_sql_runner_create_table остаётся sless_function (oneshot/Job). // pg-info, pg-table-reader, pg-table-writer → sless_service. # Служебная функция выполняет SQL-операторы из event_json. @@ -121,160 +122,3 @@ resource "sless_service" "postgres_table_writer" { output "table_writer_url" { value = sless_service.postgres_table_writer.url } - -# ============================================================================= -# STRESS-ТЕСТЫ: 9 функций для проверки устойчивости платформы. -# Python: slow, divzero, bigloop, writer -# Go: fast, nil-panic, pgstorm -# NodeJS: async-parallel, badenv -# ============================================================================= - -# --- [1] Python: долгая (sleep N сек) --- -resource "sless_function" "stress_slow" { - name = "stress-slow" - runtime = "python3.11" - entrypoint = "stress_slow.run" - memory_mb = 128 - timeout_sec = 30 - - env_vars = {} - - source_dir = "${path.module}/code/stress-slow" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [2] Python: деление на ноль --- -resource "sless_function" "stress_divzero" { - name = "stress-divzero" - runtime = "python3.11" - entrypoint = "stress_divzero.run" - memory_mb = 128 - timeout_sec = 10 - - env_vars = {} - - source_dir = "${path.module}/code/stress-divzero" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [3] Python: CPU bigloop --- -resource "sless_function" "stress_bigloop" { - name = "stress-bigloop" - runtime = "python3.11" - entrypoint = "stress_bigloop.run" - memory_mb = 256 - timeout_sec = 30 - - env_vars = {} - - source_dir = "${path.module}/code/stress-bigloop" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [4] Python: массовая запись в PG --- -resource "sless_function" "stress_writer" { - name = "stress-writer" - runtime = "python3.11" - entrypoint = "stress_writer.run" - memory_mb = 128 - timeout_sec = 30 - - env_vars = { - PGHOST = local.pg_host - PGPORT = "5432" - PGDATABASE = local.pg_database - PGUSER = local.pg_username - PGPASSWORD = local.pg_password - PGSSLMODE = "require" - } - - source_dir = "${path.module}/code/stress-writer" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [5] Go: быстрая математика (факториал + Фибоначчи) --- -resource "sless_function" "stress_go_fast" { - name = "stress-go-fast" - runtime = "go1.23" - entrypoint = "handler.Handle" - memory_mb = 64 - timeout_sec = 10 - - env_vars = {} - - source_dir = "${path.module}/code/stress-go-fast" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [6] Go: nil pointer panic --- -resource "sless_function" "stress_go_nil" { - name = "stress-go-nil" - runtime = "go1.23" - entrypoint = "handler.Handle" - memory_mb = 64 - timeout_sec = 10 - - env_vars = {} - - source_dir = "${path.module}/code/stress-go-nil" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [7] NodeJS: 3 параллельных запроса к PG через Promise.all --- -resource "sless_function" "stress_js_async" { - name = "stress-js-async" - runtime = "nodejs20" - entrypoint = "stress_js_async.run" - memory_mb = 128 - timeout_sec = 15 - - env_vars = { - PGHOST = local.pg_host - PGPORT = "5432" - PGDATABASE = local.pg_database - PGUSER = local.pg_username - PGPASSWORD = local.pg_password - PGSSLMODE = "require" - } - - source_dir = "${path.module}/code/stress-js-async" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [8] NodeJS: TypeError на несуществующей env-переменной --- -resource "sless_function" "stress_js_badenv" { - name = "stress-js-badenv" - runtime = "nodejs20" - entrypoint = "stress_js_badenv.run" - memory_mb = 128 - timeout_sec = 10 - - env_vars = {} - - source_dir = "${path.module}/code/stress-js-badenv" - depends_on = [sless_job.postgres_table_init_job] -} - -# --- [9] Go: PG Storm — 100 горутин долбят PostgreSQL напрямую через pgxpool --- -# Тестирует: Go runtime под конкурентной нагрузкой, pgxpool connection pool, -# устойчивость managed PG при массовых INSERT/SELECT. -# Параметры: workers (default 100), duration_sec (default 600), max_delay_ms (default 300). -resource "sless_function" "stress_go_pgstorm" { - name = "stress-go-pgstorm" - runtime = "go1.23" - entrypoint = "handler.Handle" - memory_mb = 256 - timeout_sec = 700 - - env_vars = { - PGHOST = local.pg_host - PGPORT = "5432" - PGDATABASE = local.pg_database - PGUSER = local.pg_username - PGPASSWORD = local.pg_password - PGSSLMODE = "require" - } - - source_dir = "${path.module}/code/stress-go-pgstorm" - depends_on = [sless_job.postgres_table_init_job] -}