@Test
    public void testRejection() {
        var prompts = testPrompts();
        var promptsToUse = prompts.size();
        var parallelRequests = 2;
        var additionalQueue = 100;
        var queueWaitTime = 10;
        // 8 should be rejected due to queue wait time

        var futures = new ArrayList<CompletableFuture<Completion.FinishReason>>(
                Collections.nCopies(promptsToUse, null));
        var completions = new ArrayList<StringBuilder>(Collections.nCopies(promptsToUse, null));

        var config = new LlmLocalClientConfig.Builder()
                .parallelRequests(parallelRequests)
                .maxQueueSize(additionalQueue)
                .maxQueueWait(queueWaitTime)
                .model(ModelReference.valueOf(model));
        var llm = new LocalLLM(config.build());

        var rejected = new AtomicInteger(0);
        var timedOut = new AtomicInteger(0);

        try {
            for (int i = 0; i < promptsToUse; i++) {
                final var seq = i;

                completions.set(seq, new StringBuilder());
                try {
                    var future = llm.completeAsync(StringPrompt.from(prompts.get(seq)), defaultOptions(), completion -> {
                        completions.get(seq).append(completion.text());
                    }).exceptionally(exception -> {
                        if (exception instanceof LanguageModelException lme) {
                            if (lme.code() == 504) {
                                timedOut.incrementAndGet();
                            }
                        }
                        return Completion.FinishReason.error;
                    });
                    futures.set(seq, future);
                } catch (RejectedExecutionException e) {
                    rejected.incrementAndGet();
                }
            }
            for (int i = 0; i < promptsToUse; i++) {
                if (futures.get(i) != null) {
                    futures.get(i).join();
                }
            }
        } finally {
            llm.deconstruct();
        }
        assertEquals(0, rejected.get());
        assertEquals(8, timedOut.get());
    }
Tests for LocalLLM.
Tests are disabled to avoid running them automatically as part of the CI/CD.
The reason for this is the long time it takes to download (2-5 min) and run LLMs (10-60 seconds).
Still, these tests can be triggered manually and are useful for debugging runtime issues.

@author lesters
@author glebashnik
model-integration/src/test/java/ai/vespa/llm/clients/LocalLLMTest.java