Skip to content

test(k8s): live check of the SearXNG service #3929

Closed

Description

@dan-petty

Problem

No document settles three points about the pinned SearXNG, and nothing in the repository fails if a later digest bump changes one. (1) Which categories the kept engines answer in. (2) Whether a query that starts with ! gives a redirect or selects an engine that is off. (3) Whether the NetworkPolicy layer holds: a pod without the label cannot reach the service, and the SearXNG pod cannot reach a private ClusterIP, a node address or the metadata address. The researcher could not run the image on 2026-11-07, so none of this was run.

Expected

A live-marked test (it skips where the cluster or a port-forward is missing, as other live tests do) that sends requests to the service for: a plain query with format=json; a query with format=html if json is the only format allowed; a query that starts with ! and names an engine that the ConfigMap leaves off; and a request with a category that no kept engine serves. It checks the reply keys, that the redirect is not followed, and that unresponsive_engines is a list. A second part runs a throwaway pod with the label of searxng and one without it, and checks the connect results to the service, to a private ClusterIP and to the metadata address. The test file names the image digest it was written for.

Acceptance criteria

  • The test fails when SearXNG starts with a keyed or suspended-prone engine (brave, braveapi, google, bing, startpage, mojeek, qwant) on, and passes on the pinned digest (run once by hand, cite the output in the PR comment).
  • The test fails when search.formats lacks json and passes with it.
  • The NetworkPolicy part: the pod without the label gets no connection to 8080; the pod with the label of searxng cannot connect to a private ClusterIP or to the metadata address.
  • The test runs in the devcontainer and on the GitHub runner, or skips with a reason (owner rule of 2026-10-24: no host changes on runners).
  • The PR comment lists the result per request and per target. No private host name or address appears in the file or the comment (use roles such as <service-ip>).

Existing tool considered

The project's live-test marker and HTTP client; kubectl run for the throwaway pod. No new scanner.

Related

Same method as #3894 (live check of Crawl4AI). Depends on the SearXNG manifest item. Run it again at each digest bump. Related: #3877.

Part of the search provider plan of 2026-11-07 (SearXNG; the Brave Search API was dropped by the owner on 2026-11-07).

Proposed design

Problem statement

Nothing in the repository fails when a later SearXNG digest bump changes three points: the categories that the kept engines answer in, the result of a query that starts with ! and names an engine that the ConfigMap leaves off, and the NetworkPolicy peers of the service. The owner chose a devops k8s command over a live pytest on 2026-11-07. This item builds the devops k8s searxng-check command, shares the throwaway-pod and report code of the Crawl4AI check (#3894), and replaces the hand-made search reply fixture with a reply from the pinned digest.

Acceptance criteria

Requirement: Command shares the Crawl4AI code

The change SHALL add a devops k8s searxng-check command and SHALL reuse the throwaway-pod and report code of devops k8s crawl4ai-check (#3894).

Scenario: Shared helpers called

  • WHEN A test patches the shared throwaway-pod and report helpers and runs the command.
  • THEN The command calls the patched helpers and its module holds no second definition of them.

Requirement: JSON reply keys

The check SHALL send a plain query with format=json and SHALL assert the keys answers, corrections, infoboxes, query, results, suggestions and unresponsive_engines.

Scenario: A reply key is missing

  • WHEN A fake reply leaves out one expected key.
  • THEN The check reports a failure that names the missing key.

Requirement: Unresponsive engines list

The check SHALL assert that unresponsive_engines is a list.

Scenario: Unresponsive engines is a string

  • WHEN A fake reply gives a string for unresponsive_engines.
  • THEN The check reports a failure that names unresponsive_engines.

Requirement: Bang query redirect

The check SHALL send a query that starts with ! and names an engine that the ConfigMap leaves off, and it MUST NOT follow a redirect.

Scenario: Redirect is not followed

  • WHEN The fake service answers the ! query with a 302 status and a Location header.
  • THEN The check records the 302 status and sends no request to the Location address.

Requirement: Unused category request

The check SHALL send a request with a category that no kept engine serves and SHALL record the reply.

Scenario: Unused category reply

  • WHEN The fake service answers the request for the unused category.
  • THEN The report holds one line for that category with its status and its result count.

Requirement: Keyed and suspended-prone engines

The check SHALL fail when the SearXNG settings keep brave, braveapi, google, bing, startpage, mojeek or qwant on.

Scenario: A keyed engine is on

  • WHEN The settings keep google on.
  • THEN The check reports a failure that names google.

Requirement: JSON format is required

The check SHALL fail when search.formats lacks json.

Scenario: JSON format is absent

  • WHEN The settings give search.formats without json.
  • THEN The check reports a failure that names search.formats.

Requirement: Kept engine categories

The check SHALL verify that the kept engines answer in general, it and science, and the change SHALL keep DEFAULT_SEARXNG_CATEGORIES equal to the categories that they answer in.

Scenario: A kept engine lacks a category

  • WHEN A fake reply shows that no kept engine answers in science.
  • THEN The check reports a failure that names science.

Requirement: Unlabeled pod is blocked

The check SHALL run a throwaway pod without the searxng label and MUST assert that it gets no connection to port 8080.

Scenario: Unlabeled pod connects

  • WHEN The unlabeled pod gets a connection to port 8080.
  • THEN The check reports a failure for the unlabeled pod and the service target.

Requirement: Labeled pod egress is blocked

The check SHALL run a throwaway pod with the searxng label and MUST assert that it gets no connection to a private ClusterIP or to the metadata address.

Scenario: Labeled pod reaches the metadata address

  • WHEN The labeled pod connects to the metadata address.
  • THEN The check reports a failure for the labeled pod and the metadata target.

Requirement: Private values are masked

The check SHALL write each private host name and address as a role such as <service-ip>.

Scenario: Address is masked

  • WHEN A fake result holds a private address.
  • THEN The report shows the role token and not the address.

Requirement: Run or state a reason

The check SHALL run in the devcontainer and on the GitHub runner, or it SHALL exit with a stated reason and MUST NOT change the host.

Scenario: No cluster is reachable

  • WHEN The command finds no kube context.
  • THEN The command exits with a stated reason and makes no host change.

Requirement: Fixture from the pinned digest

The change SHALL replace tests/fixtures/searxng/search_reply.json with a reply saved from the pinned digest and SHALL name that digest in the test file.

Scenario: Fixture names the digest

  • WHEN A test reads the fixture and the pinned digest.
  • THEN The fixture holds the seven reply keys and the test file holds the same digest string.

Existing Tool Considered

No alternatives check has run. No open, maintained tool covers a live check of this cluster's SearXNG and its NetworkPolicy. The existing devops k8s crawl4ai-check (#3894) covers the throwaway-pod and report code. It lacks the SearXNG reply keys, the ! redirect rule, the category check and the NetworkPolicy peers. This item adds those targets and writes no second copy.

Key questions

  • Should the live check be a live-marked pytest test or a devops k8s command?: A devops k8s searxng-check command in the shape of devops k8s crawl4ai-check (test(k8s): live check that Crawl4AI refuses internal URLs #3894). The owner chose the command on 2026-11-07. The test floor forbids a skip on host state. (best practice) [sources: docs/TESTING.md, AGENTS.md, tests/commands/k8s/test_k8s.py]
    • Rejected: Live-marked pytest test that skips without a cluster. docs/TESTING.md forbids a skip on host state, and the owner rejected it.
    • Chosen: devops k8s command that shares the Crawl4AI check code. The owner chose it, and it reuses the throwaway-pod and report code.
  • Which categories must the check verify, and what value must DEFAULT_SEARXNG_CATEGORIES hold?: general, it and science. The provider sends these three categories. The change updates DEFAULT_SEARXNG_CATEGORIES when a kept engine does not answer in one. (best practice) [sources: src/devops_cli/config/defaults.py, src/devops_cli/ai/web_search.py, openspec/changes/archive/2026-11-07-3927-searxng-search-provider/design.md]
    • Rejected: Keep general only. The provider already sends three categories.
    • Chosen: general,it,science. The engine files of the kept engines at the pinned commit give these categories.
  • Does this item replace the hand-made reply fixture, and how?: Yes. This item saves a reply from the pinned digest and replaces tests/fixtures/searxng/search_reply.json with it. The file names the digest. (best practice) [sources: tests/ai/test_web_search_searxng.py, src/devops_cli/ai/web_search.py]
    • Rejected: Keep the hand-made fixture. The provider PR kept it only because the manifest item was not merged.
    • Chosen: Replace it with a saved live reply. The owner gave this item the fixture work on 2026-11-05.
  • How does the check treat a query that starts with ! and names an engine that the ConfigMap leaves off?: The check sends the query and does not follow a redirect. It records the status and asserts that unresponsive_engines is a list. (best practice) [sources: src/devops_cli/ai/web_search.py, openspec/changes/archive/2026-11-07-3927-searxng-search-provider/design.md]
    • Rejected: Follow the redirect. A followed redirect hides whether the service selected the engine or refused it.
    • Chosen: Record the status and do not follow. The result shows whether the service redirects or selects an off engine.
  • Which NetworkPolicy peers does the check test?: A pod without the searxng label must get no connection to port 8080. A pod with the label must reach the service. It must get no connection to a private ClusterIP or the metadata address. (best practice) [sources: tests/commands/k8s/test_k8s_network_policies.py, tests/invariants/test_k8s_searxng.py]
    • Rejected: Test only the labeled pod. The unlabeled pod proves that the policy selects the right pods.
    • Chosen: Test both pods against all targets. This covers ingress and egress in one run.
  • Which code must the SearXNG check share, and which item delivers it?: The throwaway-pod and report code of devops k8s crawl4ai-check, which test(k8s): live check that Crawl4AI refuses internal URLs #3894 delivers. This item starts after test(k8s): live check that Crawl4AI refuses internal URLs #3894 merges. [sources: tests/commands/k8s/test_k8s.py, src/devops_cli/commands/k8s/stack_lifecycle.py]
  • Which reply keys does the SearXNG search API return?: answers, corrections, infoboxes, query, results, suggestions and unresponsive_engines. [sources: openspec/changes/archive/2026-11-07-3924-searxng-manifests/proposal.md, src/devops_cli/ai/web_search.py]
  • Which engines must the check keep off?: brave, braveapi, google, bing, startpage, mojeek and qwant. [sources: tests/invariants/test_k8s_searxng.py, k8s/README.md]
  • How does the check report private host names and addresses?: The check writes each private host name and address as a role such as <service-ip>. The file and the report hold no private value. (best practice) [sources: AGENTS.md, docs/CONFIGURATION.md]
    • Rejected: Write the real values. A private address in a public repository is a leak.
    • Chosen: Mask each value as a role. The body requires roles and the project's masking rule agrees.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#3894

Activity

  1. added
    source/agent
    type/test
    scope/k8s
    status/new
    value/high
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/test. The test prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. It verifies NetworkPolicy enforcement and service behaviour, but it depends on the manifest item that is not yet merged.
    • Value: High. It guards against silent digest bumps that weaken NetworkPolicy or change engine availability.
    • Effort: Medium. It uses the existing live-test marker and HTTP client, but covers multiple request shapes and two pod-based NetworkPolicy checks.
    • Related: feat(k8s): run SearXNG in namespace devops #3924, which asks for a different change. Both concern SearXNG in the cluster, but 3924 delivers the manifests and this candidate delivers a live test that verifies those manifests at runtime.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards, under the owner's instruction of 2026-11-05.

    Question: who replaces the hand-made reply fixture of the SearXNG provider (#3927) with a real reply, and who checks its categories value?
    Answer: this item. The provider PR (#3927) keeps a fixture that holds the shape of the SearXNG search API document (docs/dev/search_api.rst at commit 629368e40), because the manifest item (#3924) is not merged and no live pod exists. The provider sends categories=general,it,science, read from the engine files of the kept engines at the pinned commit. Add two criteria here: (1) save a reply from the pinned digest and replace tests/fixtures/searxng/search_reply.json with it, citing the digest; (2) check that the kept engines answer in these categories, and change DEFAULT_SEARXNG_CATEGORIES in src/devops_cli/config/defaults.py if they do not.
    Rule: AGENTS.md rule 2 (record how the premise was checked, and what was not run) and the "Partial work" rule of the delivery brief (move a criterion whose work is separate).

  5. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards, under the owner's instruction of 2026-11-07.

    The owner chose a devops k8s command over a live pytest for cluster checks. The test floor fakes the network and the keyring, and it forbids a skip on host state (docs/TESTING.md). A live-marked test that skips where the cluster is missing therefore does not fit.

    This item should build a command in the same shape as the Crawl4AI check of #3894 (devops k8s crawl4ai-check):

    • Share its throwaway-pod code and its report code. Do not write a second copy.
    • Add the SearXNG targets: the reply keys, the redirect rule for a query that starts with !, the category check, and the NetworkPolicy peers (a pod without the label of searxng, a pod with it, a private ClusterIP and the metadata address).
    • Start after test(k8s): live check that Crawl4AI refuses internal URLs #3894 is merged, so that the shared code exists.

    A manual check on 2026-11-07 already showed these results:

    • The pod answers /search with format=json and the 7 expected reply keys.
    • The pod of Crawl4AI cannot reach searxng:8080.
    • A pod of roadmap-service can reach searxng:8080.

    The acceptance criteria of the issue body that name a live-marked test stay unchanged here. The command replaces the test when this item is built.

  6. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  7. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 768dbd3 (see proposed design in issue body).

  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 8, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 8, 2026
  10. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-08 06:26 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/testvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions