Skip to content

Commit b660fa6

Browse files
committed
Add Turing index test scripts and samples
Add a CLI Python tool (turing-utils/scripts/turing_index_test.py) to POST test payloads to /api/sn/import (supports --specs-file, --token/--header, --dry-run, --insecure, validates docs require an 'id' and checks spec types). Include a Windows wrapper (run_wknd_index_test.cmd) and sample files (sample_wknd_document.json, sample_wknd_field_specs.json) for quick local testing. Update .gitignore to ignore turing-utils/scripts/__pycache__. Append Agent Operational Memory notes to agents.md with various testing and runtime tips.
1 parent 7cea5b6 commit b660fa6

File tree

6 files changed

+412
-0
lines changed

6 files changed

+412
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ turing-app/src/main/resources/public/favicon.ico
4545
turing-js-sdk/node_modules/
4646
turing-js-sdk/dist/
4747
/.claude
48+
/turing-utils/scripts/__pycache__

agents.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ mvn clean install
6969
- Anthropic and Gemini providers don't support embedding — throw `UnsupportedOperationException`
7070
- Frontend npm builds may fail with EBUSY on Windows if IDE locks files — use `-Dskip.npm=true` for backend-only testing
7171

72+
### Agent Operational Memory (Repository)
73+
- In `react-hook-form`, `disabled` fields are omitted from submission payloads; use `readOnly` when a value must be non-editable but still sent.
74+
- `TurAuthenticationEntryPoint` tests should validate `commence(...)` output directly: HTTP 401, `application/json`, and `{"error":"Unauthorized"}`.
75+
- For custom `/api/login` session auth alongside `httpBasic`, explicitly use `HttpSessionSecurityContextRepository` with `SessionCreationPolicy.IF_REQUIRED` to avoid browser requests returning 401 with valid `JSESSIONID`.
76+
- In SN field-check flows, `TurSolrFieldBean.getType()` may be `null`; prefer `Objects.equals(actual, expected)` over calling `.equals()` on nullable values.
77+
- For write-only secret fields modeled as JPA `@Transient` (`apiKey`, `credential`), MockMvc/Jackson binding may skip values; extract secrets from raw request payload map in controller tests and runtime paths.
78+
- Liquibase updates on reused local H2 files can fail with `Duplicate column name`; make changeSets idempotent with `preConditions` (`columnExists` + `onFail: MARK_RAN`).
79+
- In PowerShell, quote Maven test filters like `"-Dtest=A,B"` to avoid comma parsing issues.
80+
- In JUnit `@CsvSource`, quote regex values containing commas (for example `'1[.,]5B'`) and use `nullValues = "null"` when a true `null` is required.
81+
- In this Windows workspace, `py` may be unavailable; prefer `python` (for example `python -m py_compile ...`).
82+
- If `rg` is unavailable in PowerShell, use `Get-ChildItem` + `Select-String` for scripted searches.
83+
7284
### Frontend TypeScript Check (Windows EBUSY workaround)
7385
When `node_modules` native binaries are locked by the IDE/Vite dev server:
7486
1. **Don't loop** retrying `npm ci`, `npm install`, `npx tsc`, or other install variations — they will all fail with EBUSY/EPERM while the IDE holds locks.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@echo off
2+
setlocal
3+
4+
set "SCRIPT_DIR=%~dp0"
5+
set "BASE_URL=http://localhost:2700"
6+
if not "%~1"=="" set "BASE_URL=%~1"
7+
8+
set "MODE_FLAG="
9+
if /I "%~2"=="--dry-run" set "MODE_FLAG=--dry-run"
10+
11+
rem Optional: path to field specs JSON (defaults to sample_wknd_field_specs.json)
12+
set "SPECS_FILE=%SCRIPT_DIR%sample_wknd_field_specs.json"
13+
if not "%~3"=="" set "SPECS_FILE=%~3"
14+
15+
rem Detect whether the specs file is available
16+
set "HAS_SPECS="
17+
if exist "%SPECS_FILE%" set "HAS_SPECS=1"
18+
19+
where python >nul 2>nul
20+
if errorlevel 1 (
21+
echo Python nao encontrado no PATH.
22+
exit /b 1
23+
)
24+
25+
echo Running Turing indexing test...
26+
echo Base URL: %BASE_URL%
27+
echo Site: wknd
28+
echo Locale: en_US
29+
echo JSON: %SCRIPT_DIR%sample_wknd_document.json
30+
if defined HAS_SPECS (echo Specs: %SPECS_FILE%) else (echo Specs: [none])
31+
echo.
32+
33+
if defined HAS_SPECS (
34+
python "%SCRIPT_DIR%turing_index_test.py" ^
35+
--base-url "%BASE_URL%" ^
36+
--header "Key: 09e069003cd047fc918e62be8" ^
37+
--site wknd ^
38+
--locale en_US ^
39+
--json-file "%SCRIPT_DIR%sample_wknd_document.json" ^
40+
--specs-file "%SPECS_FILE%" ^
41+
%MODE_FLAG%
42+
) else (
43+
python "%SCRIPT_DIR%turing_index_test.py" ^
44+
--base-url "%BASE_URL%" ^
45+
--header "Key: 09e069003cd047fc918e62be8" ^
46+
--site wknd ^
47+
--locale en_US ^
48+
--json-file "%SCRIPT_DIR%sample_wknd_document.json" ^
49+
%MODE_FLAG%
50+
)
51+
52+
set "EXIT_CODE=%ERRORLEVEL%"
53+
if not "%EXIT_CODE%"=="0" (
54+
echo.
55+
echo Falha na indexacao. Exit code: %EXIT_CODE%
56+
exit /b %EXIT_CODE%
57+
)
58+
59+
echo.
60+
echo Indexacao enviada com sucesso.
61+
exit /b 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "wknd-example-001",
3+
"title": "WKND Example Article 1",
4+
"modification_date": "2026-03-09T10:30:00Z",
5+
"abstract": "Sample content for Turing indexing test.",
6+
"price": 19.92,
7+
"url": "https://www.example.com/wknd/example-article-1"
8+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[
2+
{
3+
"name": "id",
4+
"type": "STRING",
5+
"mandatory": true,
6+
"multiValued": false,
7+
"description": "Unique document identifier",
8+
"facet": false
9+
},
10+
{
11+
"name": "title",
12+
"type": "TEXT",
13+
"mandatory": true,
14+
"multiValued": false,
15+
"description": "Article title",
16+
"facet": false
17+
},
18+
{
19+
"name": "modification_date",
20+
"type": "DATE",
21+
"mandatory": false,
22+
"multiValued": false,
23+
"description": "Last modification date (ISO 8601)",
24+
"facet": false
25+
},
26+
{
27+
"name": "abstract",
28+
"type": "TEXT",
29+
"mandatory": false,
30+
"multiValued": false,
31+
"description": "Short summary of the article",
32+
"facet": false
33+
},
34+
{
35+
"name": "price",
36+
"type": "FLOAT",
37+
"mandatory": false,
38+
"multiValued": false,
39+
"description": "Article price in the default currency",
40+
"facet": true,
41+
"facetName": {
42+
"en": "Price",
43+
"pt": "Preco",
44+
"es": "Precio"
45+
}
46+
},
47+
{
48+
"name": "url",
49+
"type": "STRING",
50+
"mandatory": false,
51+
"multiValued": false,
52+
"description": "Canonical URL of the article",
53+
"facet": false
54+
}
55+
]

0 commit comments

Comments
 (0)