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

HTTP extractor #1

Merged
merged 42 commits into from
Feb 6, 2018
Merged

HTTP extractor #1

merged 42 commits into from
Feb 6, 2018

Conversation

tomasfejfar
Copy link
Collaborator

@tomasfejfar tomasfejfar commented Jan 29, 2018

  • dopsat README
  • dopsat integrační test
  • dohodnout static vs $this u assertů a podle toho upravit - dohodli jsme se, že si každý bude používat co chce, protože to není dostatečně důležité aby na to byl sniff
  • dohodnout a odstranit/nechat neformátovací Slevomat CS checky + pokud dávají smysl, udělat extra repository, ať se dají hlídat a upravovat na jednom místě. [PoC] Add as much of Slevomat CS as possible #2
  • pročistit historii (?) - je otázka, jestli je to potřeba, ale přehledná moc není. Můžu to přecommitnout načisto.
  • udělat knihovnu na konfigy a vyzkoušet ji na tomhle projektu Create abstract config class and use it on HTTP extractor #3

@tomasfejfar tomasfejfar self-assigned this Jan 29, 2018
Copy link

@mhujer mhujer left a comment

Choose a reason for hiding this comment

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

:-P

composer.json Outdated
"@tests"
],
"ci": [
"@composer validate --no-check-all",
Copy link

Choose a reason for hiding this comment

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

composer.json Outdated
},
"scripts": {
"tests": "phpunit",
"phpstan": "phpstan analyse ./src --level=max --no-progress",
Copy link

Choose a reason for hiding this comment

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

přidej tests

composer.json Outdated
"phpunit/phpunit": "~6.5",
"squizlabs/php_codesniffer": "~3.2",
"phpstan/phpstan-shim": "^0.9.2",
"jakub-onderka/php-parallel-lint": "^0.9.2"
Copy link

Choose a reason for hiding this comment

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

Chybí:

    "config": {
        "sort-packages": true
    },

phpcs.xml Outdated
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.TypeHints.m, "/>
Copy link

Choose a reason for hiding this comment

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

typo


public function testExtract(): void
{
$resource = new Uri('http://example.com/result.txt');
Copy link
Member

Choose a reason for hiding this comment

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

Ideálně bych to viděl v něčem, co si ten test nebo developer sám nasetupuje. Můžeš pak snadno simulovat 404, 403, 500, https, potenciálně to můžeš snadno rozšiřovat o přihlašování apod. Může to bejt něco v AWS (statický fajly v S3) nebo to může bejt třeba nějaká docker servisa s jednoduchým HTTP serverem. Tady a teď to je asi overkill, ale už ta 404 na example.com nepůjde :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ale půjde, viz nový test pod tím. Ale v rámci integračního testu to bude potřeba. To jsme se už bavili. Ale s tím budu asi potřebovat nějak pomoct.

Copy link
Member

Choose a reason for hiding this comment

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

Ježiš, jsem si nevšiml, že ten Guzzle je mockovanej, samozřejmě, omg! 404 a vše ostatní není problém. Integrační test naladíme, to nebude problém, co všechno tam budeš chtít testovat?

@ondrejhlavacek
Copy link
Member

ondrejhlavacek commented Jan 31, 2018 via email


before_script:
- docker -v
- docker build -t keboola/ex-http .
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nechal jsem si to přes noc projít hlavou a vidím tady v použití čistého dockeru ještě jeden potenciální problém. A to, že pokud jsou někde na build potřeba další servicy (třeba databáze, redis nebo tak něco), tak se to bude muset dělat buď ručně nebo přepsat zpátky na compose.

Zkusil jsem si okolo toho něco načíst, ale vypadá to, že to fakt nikdo nijak "standardizovaně" neřeší.

Hlavní problém, který řešíme je, že bysme chtěli mít jakoby víc konfigurací najednou (jednu na vývoj, jednu na travis, jednu na produkci). Mělo by jít použít víc docker-compose souborů a ty pozdějí overridují ten dřívější. Ale znamenalo by to mít v rootu jen tu defaultní "produkční" konfiguraci. A pak mít ještě šložku s travis konfigurací. A volat to docker-compose -f docker-compose.yml -f docker-compose/dev.yml up resp. docker-compose -f docker-compose.yml -f docker-compose/travis.yml up. Případně mít ten root docker-compose.yml pro vývojáře (dev) a ve složce mít extra compose pro build a produkci (tam parametr navíc nevadí - je to stejně napevno napsané v buildu).
Každopádně to zvyšuje složitost.

Nicméně pomocí tohohle a extension points by to šlo udělat DRY. Ale stále bysme se nevyhnuli více souborům :(

Je ten scénář s více službami potřebnými k testování reálný? Mohl bych projít všechny repozitáře a podívat se, ale přeci jen asi bude rychlejší, když mi to někdo kdo má přehled řekne :)

Copy link
Member

Choose a reason for hiding this comment

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

Neni realny, vetsina komponenta potrebuje jen samu sebe, A kdyz ne, tak bych to resil az to bude aktualni, anebo proste nejak jinak - treba generic ma custom testy https://github.com/keboola/generic-extractor/blob/master/.travis.yml protoze si jeste testuje example a proxy a tech vic konfiguraci tam zadnou neplechu nedela. Asi by to slo resit pres vic docker-compose souboru, ale takhle me to prijde v pohode

Copy link
Member

Choose a reason for hiding this comment

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

Mohl bys třeba pro mysql extraktor chtít pustit mysql server lokálně v dockeru, ale asi nevidím problém pustit docker-compose up mysql lokálně i na travisu a pak to prolinkovat s testovaným kontejnerem přes docker run --link...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Super, jestli jste s tím OK, tak fajn.

@Halama
Copy link
Member

Halama commented Feb 4, 2018

Prošel jsem to a za mě je to super bez výhrad. Byl bych pro merge a release.
Na číštění historie bych se vyprdnul. A ty další věci jako separaci knihovny na configy atd. udělal v dalších PR.

use GuzzleHttp\Psr7\Uri;
use Keboola\HttpExtractor\HttpExtractor;
use PHPUnit\Framework\TestCase;
use function file_get_contents;
Copy link

Choose a reason for hiding this comment

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

cool, I've not seen this before.
Just curious what benefit it brings and do you do that with all native methods?

$extractor->extract($resource, $destination);
}

private function getMockedGuzzle(array $responses): Client
Copy link

Choose a reason for hiding this comment

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

This is great, stealing it now ;-)

@tomasfejfar
Copy link
Collaborator Author

OK, prošel jsem ty zbývající věci a z čeho šlo udělal samostatnou issue. Takže tohle je Ready For Merge, pokud už nikdo nic nemá.

@odinuv odinuv merged commit 8ff1059 into master Feb 6, 2018
@tomasfejfar tomasfejfar deleted the tf-dev branch May 30, 2018 13:41
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.

6 participants