You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test_with_server"Given response_from is set to Kafka, the http response (code, content-type, body) is taken from the Kafka response topic instead of forwarding the backend's original response."do
47
+
test_name="proxy-http-response-from-kafka"
48
48
kafka_config=kafka_config()
49
49
{:ok,kafka_client}=RigKafka.start(kafka_config)
50
+
%{response_topic: kafka_topic}=config()
50
51
51
52
api_id="mock-#{test_name}-api"
52
53
endpoint_id="mock-#{test_name}-endpoint"
53
-
%{response_topic: kafka_topic}=config()
54
54
endpoint_path="/#{endpoint_id}"
55
+
55
56
sync_response=%{"message"=>"the client never sees this response"}
56
57
async_response=%{"message"=>"this is the async response that reaches the client instead"}
57
58
58
-
# The following service fake also shows how a real service should
# ...but the client got the response sent to the Kafka topic:
120
+
# The body is taken from the async response as well:
123
121
assertJason.decode!(res_body)==async_response
124
122
125
123
RigKafka.Client.stop_supervised(kafka_client)
@@ -202,9 +200,10 @@ defmodule RigTests.Proxy.ResponseFrom.KafkaTest do
202
200
end
203
201
204
202
@tag:kafka
205
-
test_with_server"Given response_from and target are set to Kafka, the http response is taken from the Kafka response topic instead of forwarding the backend's original response."do
203
+
test_with_server"response_from and target can both be set to Kafka."do
206
204
test_name="proxy-http-response-from-kafka-target"
207
205
topic="rig-test"
206
+
%{response_topic: response_topic}=config()
208
207
209
208
api_id="mock-#{test_name}-api"
210
209
endpoint_id="mock-#{test_name}-endpoint"
@@ -219,7 +218,7 @@ defmodule RigTests.Proxy.ResponseFrom.KafkaTest do
219
218
assert:ok==
220
219
RigKafka.produce(
221
220
kafka_config,
222
-
config().response_topic,
221
+
response_topic,
223
222
"",
224
223
"response",
225
224
Jason.encode!(async_response),
@@ -281,19 +280,17 @@ defmodule RigTests.Proxy.ResponseFrom.KafkaTest do
281
280
}
282
281
})
283
282
284
-
# consumer start tends to be slower sometimes, therefore we give it some time before producing
283
+
# Wait for the Kafka consumer to get its assignments..
0 commit comments