Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/v1/logs/SubmitLog_2329487120.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Send deflate logs with explicit compression returns "Response from server (always 200 empty JSON)." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::LogsAPI.new

body = [
DatadogAPIClient::V1::HTTPLogItem.new({
message: "Example-Log",
ddtags: "host:ExampleLog",
}),
]
opts = {
content_encoding: ContentEncoding::DEFLATE,
}
p api_instance.submit_log(body, opts)
15 changes: 15 additions & 0 deletions examples/v1/logs/SubmitLog_348923381.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Send gzip logs with explicit compression returns "Response from server (always 200 empty JSON)." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::LogsAPI.new

body = [
DatadogAPIClient::V1::HTTPLogItem.new({
message: "Example-Log",
ddtags: "host:ExampleLog",
}),
]
opts = {
content_encoding: ContentEncoding::GZIP,
}
p api_instance.submit_log(body, opts)
18 changes: 18 additions & 0 deletions examples/v2/logs/SubmitLog_1695361854.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Send deflate logs with explicit compression returns "Request accepted for processing (always 202 empty JSON)." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new

body = [
DatadogAPIClient::V2::HTTPLogItem.new({
ddsource: "nginx",
ddtags: "env:staging,version:5.1",
hostname: "i-012345678",
message: "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
service: "payment",
}),
]
opts = {
content_encoding: ContentEncoding::DEFLATE,
}
p api_instance.submit_log(body, opts)
18 changes: 18 additions & 0 deletions examples/v2/logs/SubmitLog_3804768803.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Send gzip logs with explicit compression returns "Request accepted for processing (always 202 empty JSON)." response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::LogsAPI.new

body = [
DatadogAPIClient::V2::HTTPLogItem.new({
ddsource: "nginx",
ddtags: "env:staging,version:5.1",
hostname: "i-012345678",
message: "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
service: "payment",
}),
]
opts = {
content_encoding: ContentEncoding::GZIP,
}
p api_instance.submit_log(body, opts)
15 changes: 15 additions & 0 deletions features/step_definitions/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,21 @@ def model_builder(param, obj, schema = nil)
@api_method = generated_operation_method(@api_instance, name)
end

Then('the request uses {string} compression') do |compression|
next unless test_server_enabled?

result = test_server_request(
:get,
"/__openapi_transformer__/sessions/#{@test_server_session}/last-request"
)
actual = result.fetch('request').fetch('headers')['content-encoding']
raise "Expected Content-Encoding #{compression.inspect}, got #{actual.inspect}" unless actual == compression.downcase
end

Given('the client selects {string} compression') do |_compression|
# The generated request plan passes the selected compression to the client call.
end

When('the request is sent') do
prepare_test_runner_request if test_runner_enabled?
params = @api_method.parameters.select { |p| p[0] == :req }.map { |p| opts.delete(p[1]) }
Expand Down
5 changes: 5 additions & 0 deletions features/support/test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def prepare_test_runner_request
opts[:body] = model_builder('body', value, request['body']['schema'])
end

if request['selected_compression']
name = scenario_parameter_name('Content-Encoding')
opts[name.to_sym] = request['selected_compression']
end

request.fetch('parameters').each do |parameter|
source = parameter.fetch('source')
value = if source.fetch('type') == 'fixture'
Expand Down
18 changes: 18 additions & 0 deletions features/v1/logs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ Feature: Logs
When the request is sent
Then the response status is 200 Response from server (always 200 empty JSON).

@skip-terraform-config @skip-validation @team:DataDog/event-platform-intake
Scenario: Send deflate logs with explicit compression returns "Response from server (always 200 empty JSON)." response
Given new "SubmitLog" request
And body with value [{"message": "{{ unique }}", "ddtags": "host:{{ unique_alnum }}"}]
And the client selects "deflate" compression
When the request is sent
Then the response status is 200 Response from server (always 200 empty JSON).
And the request uses "deflate" compression

@integration-only @skip-terraform-config @skip-validation @team:DataDog/event-platform-intake
Scenario: Send gzip logs returns "Response from server (always 200 empty JSON)." response
Given new "SubmitLog" request
Expand All @@ -48,6 +57,15 @@ Feature: Logs
When the request is sent
Then the response status is 200 Response from server (always 200 empty JSON).

@skip-terraform-config @skip-validation @team:DataDog/event-platform-intake
Scenario: Send gzip logs with explicit compression returns "Response from server (always 200 empty JSON)." response
Given new "SubmitLog" request
And body with value [{"message": "{{ unique }}", "ddtags": "host:{{ unique_alnum }}"}]
And the client selects "gzip" compression
When the request is sent
Then the response status is 200 Response from server (always 200 empty JSON).
And the request uses "gzip" compression

@team:DataDog/event-platform-intake
Scenario: Send logs returns "Response from server (always 200 empty JSON)." response
Given new "SubmitLog" request
Expand Down
18 changes: 18 additions & 0 deletions features/v2/logs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ Feature: Logs
When the request is sent
Then the response status is 202 Response from server (always 202 empty JSON).

@skip-terraform-config @skip-validation @team:DataDog/event-platform-intake @team:DataDog/logs-backend @team:DataDog/logs-ingestion
Scenario: Send deflate logs with explicit compression returns "Request accepted for processing (always 202 empty JSON)." response
Given new "SubmitLog" request
And body with value [{"ddsource": "nginx", "ddtags": "env:staging,version:5.1", "hostname": "i-012345678", "message": "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World", "service": "payment"}]
And the client selects "deflate" compression
When the request is sent
Then the response status is 202 Response from server (always 202 empty JSON).
And the request uses "deflate" compression

@integration-only @skip-terraform-config @skip-validation @team:DataDog/event-platform-intake @team:DataDog/logs-backend @team:DataDog/logs-ingestion
Scenario: Send gzip logs returns "Request accepted for processing (always 202 empty JSON)." response
Given new "SubmitLog" request
Expand All @@ -144,6 +153,15 @@ Feature: Logs
When the request is sent
Then the response status is 202 Request accepted for processing (always 202 empty JSON).

@skip-terraform-config @skip-validation @team:DataDog/event-platform-intake @team:DataDog/logs-backend @team:DataDog/logs-ingestion
Scenario: Send gzip logs with explicit compression returns "Request accepted for processing (always 202 empty JSON)." response
Given new "SubmitLog" request
And body with value [{"ddsource": "nginx", "ddtags": "env:staging,version:5.1", "hostname": "i-012345678", "message": "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World", "service": "payment"}]
And the client selects "gzip" compression
When the request is sent
Then the response status is 202 Request accepted for processing (always 202 empty JSON).
And the request uses "gzip" compression

@generated @skip @team:DataDog/event-platform-intake @team:DataDog/logs-backend @team:DataDog/logs-ingestion
Scenario: Send logs returns "Bad Request" response
Given new "SubmitLog" request
Expand Down
28 changes: 28 additions & 0 deletions generated-test/test-runner-data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,20 @@
"scenario": "Search test logs returns \"OK\" response",
"version": "v1"
},
{
"feature": "Logs",
"feature_file": "../../features/v1/logs.feature",
"file": "v1/logs/send-deflate-logs-with-explicit-compression-returns-response-from-server-always-200-empty-json-response.json",
"scenario": "Send deflate logs with explicit compression returns \"Response from server (always 200 empty JSON).\" response",
"version": "v1"
},
{
"feature": "Logs",
"feature_file": "../../features/v1/logs.feature",
"file": "v1/logs/send-gzip-logs-with-explicit-compression-returns-response-from-server-always-200-empty-json-response.json",
"scenario": "Send gzip logs with explicit compression returns \"Response from server (always 200 empty JSON).\" response",
"version": "v1"
},
{
"feature": "Logs",
"feature_file": "../../features/v1/logs.feature",
Expand Down Expand Up @@ -6391,6 +6405,20 @@
"scenario": "Search logs returns \"OK\" response with pagination",
"version": "v2"
},
{
"feature": "Logs",
"feature_file": "../../features/v2/logs.feature",
"file": "v2/logs/send-deflate-logs-with-explicit-compression-returns-request-accepted-for-processing-always-202-empty-json-response.json",
"scenario": "Send deflate logs with explicit compression returns \"Request accepted for processing (always 202 empty JSON).\" response",
"version": "v2"
},
{
"feature": "Logs",
"feature_file": "../../features/v2/logs.feature",
"file": "v2/logs/send-gzip-logs-with-explicit-compression-returns-request-accepted-for-processing-always-202-empty-json-response.json",
"scenario": "Send gzip logs with explicit compression returns \"Request accepted for processing (always 202 empty JSON).\" response",
"version": "v2"
},
{
"feature": "Logs",
"feature_file": "../../features/v2/logs.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"api": "Logs",
"expected_status": 200,
"feature": "Logs",
"id": "v1/Logs/Send deflate logs with explicit compression returns \"Response from server (always 200 empty JSON).\" response",
"operation_id": "SubmitLog",
"request": {
"body": {
"schema": {
"format": null,
"items": {
"format": null,
"ref": "HTTPLogItem",
"type": "object"
},
"ref": "HTTPLog",
"type": "array"
},
"source": "inline",
"value": [
{
"ddtags": "host:{{ unique_alnum }}",
"message": "{{ unique }}"
}
]
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/v1/input",
"selected_compression": "deflate"
},
"scenario": "Send deflate logs with explicit compression returns \"Response from server (always 200 empty JSON).\" response",
"schema_version": 1,
"version": "v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"api": "Logs",
"expected_status": 200,
"feature": "Logs",
"id": "v1/Logs/Send gzip logs with explicit compression returns \"Response from server (always 200 empty JSON).\" response",
"operation_id": "SubmitLog",
"request": {
"body": {
"schema": {
"format": null,
"items": {
"format": null,
"ref": "HTTPLogItem",
"type": "object"
},
"ref": "HTTPLog",
"type": "array"
},
"source": "inline",
"value": [
{
"ddtags": "host:{{ unique_alnum }}",
"message": "{{ unique }}"
}
]
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/v1/input",
"selected_compression": "gzip"
},
"scenario": "Send gzip logs with explicit compression returns \"Response from server (always 200 empty JSON).\" response",
"schema_version": 1,
"version": "v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"api": "Logs",
"expected_status": 202,
"feature": "Logs",
"id": "v2/Logs/Send deflate logs with explicit compression returns \"Request accepted for processing (always 202 empty JSON).\" response",
"operation_id": "SubmitLog",
"request": {
"body": {
"schema": {
"format": null,
"items": {
"format": null,
"ref": "HTTPLogItem",
"type": "object"
},
"ref": "HTTPLog",
"type": "array"
},
"source": "inline",
"value": [
{
"ddsource": "nginx",
"ddtags": "env:staging,version:5.1",
"hostname": "i-012345678",
"message": "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
"service": "payment"
}
]
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v2/logs",
"selected_compression": "deflate"
},
"scenario": "Send deflate logs with explicit compression returns \"Request accepted for processing (always 202 empty JSON).\" response",
"schema_version": 1,
"version": "v2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"api": "Logs",
"expected_status": 202,
"feature": "Logs",
"id": "v2/Logs/Send gzip logs with explicit compression returns \"Request accepted for processing (always 202 empty JSON).\" response",
"operation_id": "SubmitLog",
"request": {
"body": {
"schema": {
"format": null,
"items": {
"format": null,
"ref": "HTTPLogItem",
"type": "object"
},
"ref": "HTTPLog",
"type": "array"
},
"source": "inline",
"value": [
{
"ddsource": "nginx",
"ddtags": "env:staging,version:5.1",
"hostname": "i-012345678",
"message": "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
"service": "payment"
}
]
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v2/logs",
"selected_compression": "gzip"
},
"scenario": "Send gzip logs with explicit compression returns \"Request accepted for processing (always 202 empty JSON).\" response",
"schema_version": 1,
"version": "v2"
}
Loading
Loading