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
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def initialize(app_id, api_key, hosts, client_name, opts = {})
@app_id = app_id
@api_key = api_key
@client_side_validation = opts[:client_side_validation].nil? ? true : opts[:client_side_validation]
@connect_timeout = opts[:connect_timeout] || 2_000
@read_timeout = opts[:read_timeout] || 5_000
@write_timeout = opts[:write_timeout] || 30_000
@connect_timeout = opts[:connect_timeout]
@read_timeout = opts[:read_timeout]
@write_timeout = opts[:write_timeout]
@compression_type = opts[:compression_type] || "none"
@requester = opts[:requester]

Expand Down
6 changes: 6 additions & 0 deletions scripts/cts/testServer/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ function addRoutes(app: express.Express): void {
res.setHeader('Content-Type', 'text/html');
res.status(429).send('<html><body>429 Too Many Requests</body></html>');
});

app.get('/1/long-wait', (req, res) => {
setTimeout(() => {
res.json({ message: 'OK' });
}, 8000);
});
}

export function timeoutServer(): Promise<Server> {
Expand Down
2 changes: 1 addition & 1 deletion templates/javascript/tests/client/tests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('{{testType}}', () => {
}
{{/times}}
{{/steps}}
}, 15000);
}, 25000);

{{/tests}}
});
24 changes: 12 additions & 12 deletions templates/ruby/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ module {{moduleName}}
region = nil
end

if opts.nil? || opts[:connect_timeout].nil?
opts[:connect_timeout] = {{x-timeouts.server.connect}}
end

if opts.nil? || opts[:read_timeout].nil?
opts[:read_timeout] = {{x-timeouts.server.read}}
end

if opts.nil? || opts[:write_timeout].nil?
opts[:write_timeout] = {{x-timeouts.server.write}}
end

{{^fallbackToAliasHost}}
raise "`region` is required and must be one of the following: #{regions.join(', ')}" if region.nil? || !region.is_a?(String) || !regions.include?(region)
{{/fallbackToAliasHost}}
Expand Down Expand Up @@ -70,6 +58,18 @@ module {{moduleName}}
end

def self.create_with_config(config)
if config.connect_timeout.nil? ||config.connect_timeout.empty?
config.connect_timeout = {{x-timeouts.server.connect}}
end

if config.read_timeout.nil? || config.read_timeout.empty?
config.read_timeout = {{x-timeouts.server.read}}
end

if config.write_timeout.nil? || config.write_timeout.empty?
config.write_timeout = {{x-timeouts.server.write}}
end

new(config)
end

Expand Down
30 changes: 30 additions & 0 deletions tests/CTS/client/ingestion/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,36 @@
}
]
},
{
"testName": "can leave call opened for a long time",
"autoCreateClient": false,
"steps": [
{
"type": "createClient",
"parameters": {
"appId": "test-app-id",
"apiKey": "test-api-key",
"region": "us",
"customHosts": [
{
"port": 6676
}
]
}
},
{
"type": "method",
"method": "customGet",
"parameters": {
"path": "1/long-wait"
},
"expected": {
"type": "response",
"match": {"message":"OK"}
}
}
]
},
{
"testName": "endpoint level timeout",
"steps": [
Expand Down
Loading