Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cts): add client test for retry strategy #2633

Merged
merged 44 commits into from
Feb 14, 2024
Merged

feat(cts): add client test for retry strategy #2633

merged 44 commits into from
Feb 14, 2024

Conversation

millotp
Copy link
Collaborator

@millotp millotp commented Jan 29, 2024

🧭 What and Why

DI-1810

Add a retry strategy test, which works by creating 2 servers, the first one should timeout, and the second one returns something we can check against, then we make sure we had the correct response, and that the timeout server was called.

This ensures 3 things in the client:

  • The hosts are configurable
  • The timeout is correct
  • The retry strategy tries another host.

Note: this only works in js for now, but we can add it everywhere

@millotp millotp self-assigned this Jan 29, 2024
Copy link

netlify bot commented Jan 29, 2024

Deploy Preview for api-clients-automation ready!

Name Link
🔨 Latest commit c25519d
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/65ccdb19ca97f6000838ae12
😎 Deploy Preview https://deploy-preview-2633--api-clients-automation.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@algolia-bot
Copy link
Collaborator

algolia-bot commented Jan 29, 2024

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.

Copy link
Contributor

@Fluf22 Fluf22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's so cool!
Looking forward to it

@morganleroi
Copy link
Contributor

Whooo ! So nice, so fast !

@millotp millotp mentioned this pull request Jan 30, 2024
@millotp millotp marked this pull request as ready for review February 14, 2024 10:46
@millotp millotp requested a review from a team as a code owner February 14, 2024 10:46
Fluf22
Fluf22 previously approved these changes Feb 14, 2024
Copy link
Contributor

@Fluf22 Fluf22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go! Great improvements in our testing strats

Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a wonderful idea

Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks really nice

@@ -148,7 +154,16 @@ private function request(

$retry = 1;
foreach ($hosts as $host) {
$uri = $uri->withHost($host);
if ($this->config->getHasFullHosts()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so IIUC the user has to explicitly call setFullHost to make that work right? if that's the case we should provide some inlined doc to at least explain what we expect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if they want to specify a different scheme/port, they need to use setFullHosts() , I guess this would require some explanation indeed ...

templates/python/config.mustache Outdated Show resolved Hide resolved
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks super nice, some questions but nothing really blocking

@@ -13,6 +13,11 @@ export type Host = {
* The protocol of the host URL.
*/
protocol: 'http' | 'https';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we have a mix of scheme and protocol in the clients

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's from the legacy, I can rename everything if you want, but I have no preference

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk the real definition of both I guess there's some overlap? to me scheme is http or https and protocol is how we transfer data, which is defined by the scheme?

idk idk up to you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer scheme anyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to many idk ahah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahahah that's my state of mind

Comment on lines +214 to +224
public function setFullHosts($hosts)
{
$this->config['hasFullHosts'] = true;

return $this->setHosts($hosts);
}

public function getHasFullHosts()
{
return $this->config['hasFullHosts'];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really a fan of this I kind of prefer the scheme port and host standalone definitions so there's no parsing etc. not sure what you prefer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this but flemme to do more php

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be improved in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damcou wdyt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a small commit for a php master like you is what? 3 minutes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not perfect like that but unfortunately we tried to use the same methotology as in the other languages, and it's not as simple since we reuse the Retry Strategy of the current PHP client and it would require quite a lot of rework :(

Copy link
Contributor

@damcou damcou Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this, this method will be only used for this test anyway.

Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:( PHP

@shortcuts
Copy link
Member

(btw gg to everyone who contributed to this, it's huge!)

@millotp millotp merged commit 65bd154 into main Feb 14, 2024
26 checks passed
@millotp millotp deleted the feat/retry-test branch February 14, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants