test: 8 стресс-функций (py/go/js), crash-тесты, stress_test.sh — 32 строки в PG
This commit is contained in:
@@ -194,3 +194,184 @@ output "table_writer_url" {
|
||||
value = sless_trigger.postgres_table_writer_http.url
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# STRESS-ТЕСТЫ: 8 функций для проверки устойчивости платформы.
|
||||
# Python: slow, divzero, bigloop, writer
|
||||
# Go: fast, nil-panic
|
||||
# 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]
|
||||
}
|
||||
resource "sless_trigger" "stress_slow_http" {
|
||||
name = "stress-slow-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_slow.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_divzero_http" {
|
||||
name = "stress-divzero-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_divzero.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_bigloop_http" {
|
||||
name = "stress-bigloop-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_bigloop.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_writer_http" {
|
||||
name = "stress-writer-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_writer.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_go_fast_http" {
|
||||
name = "stress-go-fast-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_go_fast.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_go_nil_http" {
|
||||
name = "stress-go-nil-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_go_nil.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_js_async_http" {
|
||||
name = "stress-js-async-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_js_async.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# --- [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]
|
||||
}
|
||||
resource "sless_trigger" "stress_js_badenv_http" {
|
||||
name = "stress-js-badenv-http"
|
||||
type = "http"
|
||||
function = sless_function.stress_js_badenv.name
|
||||
enabled = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user