mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-16 16:34:45 +00:00
PERF: speed up spec (#794)
~500ms -> ~100ms It is still not a super fast spec given search is not free, but it is a bit faster and clearer
This commit is contained in:
parent
cabecb801e
commit
a5b5c3bebe
@ -63,12 +63,26 @@ describe DiscourseAi::Embeddings::EmbeddingsController do
|
|||||||
context "when rate limiting is enabled" do
|
context "when rate limiting is enabled" do
|
||||||
before { RateLimiter.enable }
|
before { RateLimiter.enable }
|
||||||
|
|
||||||
it "will not rate limit API for hyde search" do
|
use_redis_snapshotting
|
||||||
10.times do |i|
|
|
||||||
query = "test #{SecureRandom.hex}"
|
it "will rate limit correctly" do
|
||||||
stub_embedding(query)
|
stub_const(subject.class, :MAX_HYDE_SEARCHES_PER_MINUTE, 1) do
|
||||||
get "/discourse-ai/embeddings/semantic-search.json?q=#{query}&hyde=false"
|
stub_const(subject.class, :MAX_SEARCHES_PER_MINUTE, 2) do
|
||||||
expect(response.status).to eq(200)
|
query = "test #{SecureRandom.hex}"
|
||||||
|
stub_embedding(query)
|
||||||
|
get "/discourse-ai/embeddings/semantic-search.json?q=#{query}&hyde=false"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
query = "test #{SecureRandom.hex}"
|
||||||
|
stub_embedding(query)
|
||||||
|
get "/discourse-ai/embeddings/semantic-search.json?q=#{query}&hyde=false"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
query = "test #{SecureRandom.hex}"
|
||||||
|
stub_embedding(query)
|
||||||
|
get "/discourse-ai/embeddings/semantic-search.json?q=#{query}&hyde=false"
|
||||||
|
expect(response.status).to eq(429)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user