Skip to content

Cache or Clear tables.#309

Closed
harikt wants to merge 9 commits into
cakephp:masterfrom
harikt:cache
Closed

Cache or Clear tables.#309
harikt wants to merge 9 commits into
cakephp:masterfrom
harikt:cache

Conversation

@harikt
Copy link
Copy Markdown
Contributor

@harikt harikt commented Mar 21, 2017

Hi,

This PR contains commit from : #308 .

This is WIP for there is no tests currently.

The idea is allow people to use cakephp/migrations as standalone .

Interested to know if you guys love this addition.

Thank you.

{
$this
->setName('orm-cache-build')
->setDescription('Build all metadata caches for the connection. If a table name is provided, only that table will be cached.')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line exceeds 120 characters; contains 138 characters

{
$this
->setName('orm-cache-clear')
->setDescription('Clear all metadata caches for the connection. If a table name is provided, only that table will be removed.')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line exceeds 120 characters; contains 139 characters

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #309 into master will decrease coverage by 1.73%.
The diff coverage is 40%.

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
- Coverage   85.97%   84.23%   -1.74%     
==========================================
  Files          33       36       +3     
  Lines        1782     1852      +70     
==========================================
+ Hits         1532     1560      +28     
- Misses        250      292      +42
Impacted Files Coverage Δ
src/Util/SchemaTrait.php 0% <0%> (ø)
src/MigrationsDispatcher.php 100% <100%> (ø) ⬆️
src/Command/CacheClear.php 44.82% <44.82%> (ø)
src/Command/CacheBuild.php 50% <50%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc0f313...4bbe93e. Read the comment docs.

Comment thread src/Util/SchemaTrait.php Outdated
/**
* Helper method to get the schema collection.
*
* @return false|\Cake\Database\Schema\Collection
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fallback value should be null for objects, not false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure. I can make the change.

@ADmad
Copy link
Copy Markdown
Member

ADmad commented Mar 21, 2017

Looks like stickler is using the wrong standard for checks. The .stickler.yml from cakephp/cakephp can be copied.

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 21, 2017

It does make sense to me to move those shells to this plugin

@harikt
Copy link
Copy Markdown
Contributor Author

harikt commented Mar 21, 2017

Hey guys,

Can anyone help me finish writing tests for this ?

vendor/bin/phpunit tests/TestCase/Command/CacheBuildTest.php

throws

1) Migrations\Test\Command\CacheBuildTest::testExecute
Symfony\Component\Console\Exception\InvalidArgumentException: The "source" option does not exist.

UPDATE : I have already modified this. So no more source is passed ;-) .

Thank you.

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 23, 2017

Seems like you are passing the source CLI option somewhere in your test?

@harikt
Copy link
Copy Markdown
Contributor Author

harikt commented Mar 23, 2017

@lorenzo source ? No. See the changes. Some how the tests are failing :-/ .

@harikt harikt changed the title WIP : Cache Cache or Clear tables. Mar 23, 2017
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 23, 2017

@harikt ok, looks like it is failing because you are missing some tearDown logic


Cache::enable();
$this->connection = ConnectionManager::get('test');
$this->connection->cacheMetadata(true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should revert this in tearDown

{
parent::setUp();

Cache::enable();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to disable in tearDown

@harikt
Copy link
Copy Markdown
Contributor Author

harikt commented Mar 23, 2017

@lorenzo other tests seems failing :( . I will investigate.

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 23, 2017

@harikt they fail because of corrupted state in a previous test

@harikt
Copy link
Copy Markdown
Contributor Author

harikt commented Mar 23, 2017

So there is a problem with the serialized value and the one running on containers. Do you know how we can fix that ?

Also there is a permission issues I noticed for some tests to fail on localhost. Files are in /tmp/ folder.

vendor/bin/phpunit 
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

.............................S.................................SS 65 / 99 ( 65%)
S..........................EEEEEEE

Time: 5.02 seconds, Memory: 18.00MB

There were 7 errors:

1) Migrations\Test\MigrationHelperTest::testIndexMethod
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

2) Migrations\Test\MigrationHelperTest::testColumnMethod
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

3) Migrations\Test\MigrationHelperTest::testColumns
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

4) Migrations\Test\MigrationHelperTest::testColumn
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

5) Migrations\Test\MigrationHelperTest::testValue
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

6) Migrations\Test\MigrationHelperTest::testAttributes
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

7) Migrations\Test\MigrationHelperTest::testStringifyList
dir(/tmp/systemd-private-0645317efcd547448e31d26ec6899e87-rtkit-daemon.service-BskPka/): failed to open dir: Permission denied

/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:309
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:286
/var/www/projects/github.com/harikt/cakephp-orm-migrations/vendor/cakephp/cakephp/src/Cache/Cache.php:451
/var/www/projects/github.com/harikt/cakephp-orm-migrations/tests/TestCase/View/Helper/MigrationHelperTest.php:46

FAILURES!
Tests: 99, Assertions: 328, Errors: 7, Skipped: 4.

If we do a git status there are many files added. Seems we could add those to gitignore itself.

 ✘  /var/www/projects/github.com/harikt/cakephp-orm-migrations   cache  gs
On branch cache
Your branch is up-to-date with 'origin/cache'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	cakephp_test
	composer.lock
	tests/test_app/Plugin/TestBlog/config/Migrations/
	tests/test_app/config/Create/20170323150809_TestCreate.php
	tests/test_app/config/Migrations/20170323150811_TestAutoIdDisabledSnapshotSqlite.php
	tests/test_app/config/Migrations/20170323150811_TestNotEmptySnapshotNoLockSqlite.php
	tests/test_app/config/Migrations/20170323150811_TestNotEmptySnapshotSqlite.php
	tests/test_app/config/Migrations/20170323150813_CreateUsers.php
	tests/test_app/config/TestsMigrations/schema-dump-test.lock

nothing added to commit but untracked files present (use "git add" to track)

I am leaving this to rest for now. Will come back when I have some more energy :) .

@harikt
Copy link
Copy Markdown
Contributor Author

harikt commented Mar 23, 2017

Closing this PR. Opening a rebased one.

@harikt harikt closed this Mar 23, 2017
@harikt harikt mentioned this pull request Mar 23, 2017
@HavokInspiration HavokInspiration modified the milestone: 1.6.8 Jun 7, 2017
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.

7 participants