Class OpenSearchTestSetupService

java.lang.Object
ai.pipestream.module.pipelineprobe.opensearch.OpenSearchTestSetupService

@ApplicationScoped public class OpenSearchTestSetupService extends Object
Blocking, non-Mutiny equivalent of E2EPipelineTestService's registerConfigs(...) chain — registers the minimum ChunkerConfigs, EmbeddingConfigs, VectorSet recipes, and IndexPlan the opensearch-sink needs to resolve a plan and publish indexing work (inline Kafka event below the size threshold, S3 claim-check + pointer above it; OSM's KafkaIndexingConsumer indexes — no redis on this path).

Targets the same data the court-1000 chunker fixtures actually carry: chunk_config_id values "sentence-10-3" and "sentences_internal", both on source_field_name = "body".

Idempotent: every step recovers from ALREADY_EXISTS by looking up the existing row by name and reusing its id. Re-running setup against the same OSM instance is safe — it returns the same plan id every time.

Exceptions on the gRPC stubs propagate verbatim — no swallowing, no debug-only logging.

  • Field Details

    • DEFAULT_INDEX_NAME

      public static final String DEFAULT_INDEX_NAME
      Default index name when the caller doesn't override. Prefix matches the cleanup allow-list (idx-test-) so /cleanup can drop it.
      See Also:
  • Constructor Details

    • OpenSearchTestSetupService

      public OpenSearchTestSetupService()
      CDI.
  • Method Details

    • setup

      Run the full setup. Sequential — Hibernate session corruption shows up under concurrent create-with-duplicate-key contention (see comment in E2EPipelineTestService#registerConfigs).
      Parameters:
      indexName - OS index name; defaults to DEFAULT_INDEX_NAME
      Returns:
      ids of everything created or reused, plus a human audit log
    • setupToJson

      Flattens a OpenSearchTestSetupService.SetupResult into an ordered map shape suitable for JAX-RS serialization, exposing every id field plus the audit log.
      Parameters:
      r - the setup result to convert
      Returns:
      an ordered map of the result's fields ready for JSON serialization
    • setupForSink

      public OpenSearchTestSetupService.SinkPerfSetup setupForSink(String indexName, ai.pipestream.opensearch.v1.IndexingStrategy strategy, List<String> vectorSetIds)
      E2E-faithful sink setup for the module perf test: create an IndexPlan with a PINNED id (plan-<indexName> — the sink resolves plan_ids[] entries via GetIndexPlan(id), so the id must be the value we hand it), the caller-chosen IndexingStrategy, and the caller's vector-set ids (the e2e 2×2 from EmbedderFixturesRegistrar.registerForEmbedderPipeline()), then gate on READY exactly like the crawl does — the sink rejects any doc whose plan isn't READY.
      Parameters:
      indexName - OS index name; also names the plan as plan-<indexName>
      strategy - the indexing strategy to provision the plan with
      vectorSetIds - vector-set ids to attach to the plan
      Returns:
      the pinned plan id plus the index and vector sets to tear down
    • teardown

      Teardown for a setupForSink(String, IndexingStrategy, List) session — same steps as teardown(SetupResult), driven off the sink-perf result's ids.
      Parameters:
      s - the sink-perf setup to tear down
      Returns:
      human audit log of what was destroyed or skipped
    • teardown

      Inverse of setup(String): destroy everything a setup run provisioned for one index, leaving the shared deterministic recipes (ChunkerConfigs, EmbeddingConfig, VectorSet definitions) in place for the next run to reuse.
      1. Unbind each vector set from the index (drops the binding rows).
      2. DeleteIndexPlan(deleteIndices=true) — OSM resolves the plan's strategy and drops every OS index it governs (including SEPARATE_INDICES per-vector-set indices) plus the plan row.
      3. Delete the session's claim-check drives ({account}:index:{indexName}) — the sink's S3-staged indexing payloads (Kafka carries pointers).

      Refuses (throws) unless the index name starts with a disposable prefix — same spirit as the cleanup endpoint's allow-list, hard-coded here because this path is only ever called on indices this service itself named.

      Best-effort per step: a failed unbind or trim is recorded in the audit and the remaining steps still run, so a partial earlier failure never wedges cleanup permanently.

      Parameters:
      r - the setup result whose index, plan, and vector sets to destroy
      Returns:
      human audit log of what was destroyed/skipped
    • teardown

      public List<String> teardown(String idx, String planId, List<String> vectorSetIds)
      Core teardown by ids — see teardown(SetupResult) for semantics.
      Parameters:
      idx - OS index name; must start with a disposable prefix (TEARDOWN_PREFIXES) or teardown is refused
      planId - id of the IndexPlan to delete (along with its indices)
      vectorSetIds - vector-set ids to unbind from the index
      Returns:
      human audit log of what was destroyed or skipped