Skip to contentSkip to conversation

test/py: Set cache_dir to /tmp/.pytest_cache

PATCH New Tom Rini 3 participants 8 messages Oct 31, 2019

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
 test/py/pytest.ini | 1 +
 1 file changed, 1 insertion(+)
test/py/pytest.ini +1 -0
index e93d010f1fa2..56c1f0521a54 100644
@@ -11,3 +11,4 @@ markers =
     notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
     requiredtool: U-Boot: Required host tools for a test.
     slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

Hi Tom,

Quoted 5 lines · Tom Rini

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a

Thanks for checking Azure. Though I did not see such warning from pytest in my run below. Which job did you see it?
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=134

BTW: It looks the green check mark on
https://github.com/u-boot/u-boot/commits/master only contains Travis-CI results. Would you please set up the connection to Azure pipeline as well?

Quoted 26 lines

warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
 test/py/pytest.ini | 1 +
 1 file changed, 1 insertion(+)
test/py/pytest.ini +0 -0
index e93d010f1fa2..56c1f0521a54 100644

test/py/pytest.ini markers =

Quoted 5 lines
test/py/pytest.ini +1 -1
@@ -11,3 +11,4 @@ markers =
     notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
     requiredtool: U-Boot: Required host tools for a test.
     slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache
--

Regards,
Bin

author
#2 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

Quoted 4 lines · Bin Meng

Hi Tom,

Quoted 1 line · Tom Rini
Quoted 8 lines
Quoted 4 lines

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a

Thanks for checking Azure. Though I did not see such warning from pytest in my run below. Which job did you see it?
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=134

I don't see it myself now in a non-failing job and I hit rerun on the one that had failed (since it looked like one of the sometimes fails I see).

Quoted 4 lines

BTW: It looks the green check mark on
https://github.com/u-boot/u-boot/commits/master only contains Travis-CI results. Would you please set up the connection to Azure pipeline as well?

Thanks, I'll put it on my TODO list.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191031/d2694547/attachment.sig>
#3 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

In reply to Tom Rini
Quoted 30 lines · Tom Rini

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
  test/py/pytest.ini | 1 +
  1 file changed, 1 insertion(+)
test/py/pytest.ini +0 -0
index e93d010f1fa2..56c1f0521a54 100644

test/py/pytest.ini markers = · line 14

Quoted 4 lines
test/py/pytest.ini +1 -0
@@ -11,3 +11,4 @@ markers =
      notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
      requiredtool: U-Boot: Required host tools for a test.
      slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache

Won't this hard-coding break running parallel invocations; they'll all try to use the same cache directory and conflict with each-other?

Various test/py tests create data files (e.g. disk images, files for DFU to download/upload, etc.). That directory must be writable. Can we tell pytest to use (a sub-directory of that) directory as the cache?

author
#4 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

Quoted 39 lines · Stephen Warren
Quoted 30 lines · Tom Rini

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
  test/py/pytest.ini | 1 +
  1 file changed, 1 insertion(+)
test/py/pytest.ini +0 -0
index e93d010f1fa2..56c1f0521a54 100644

test/py/pytest.ini markers = · line 14

Quoted 4 lines
test/py/pytest.ini +1 -0
@@ -11,3 +11,4 @@ markers =
      notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
      requiredtool: U-Boot: Required host tools for a test.
      slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache

Won't this hard-coding break running parallel invocations; they'll all try to use the same cache directory and conflict with each-other?

Quoted 3 lines

Various test/py tests create data files (e.g. disk images, files for DFU to download/upload, etc.). That directory must be writable. Can we tell pytest to use (a sub-directory of that) directory as the cache?

I don't think it will break anything today at least. We don't use pytest's cache_dir directly for creating our disk images, we put those elsewhere. This is strictly used by pytest itself, afaict.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191031/dc0a3e44/attachment.sig>
#5 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

Quoted 40 lines · Tom Rini
Quoted 39 lines · Stephen Warren
Quoted 30 lines · Tom Rini

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
   test/py/pytest.ini | 1 +
   1 file changed, 1 insertion(+)
test/py/pytest.ini +0 -0
index e93d010f1fa2..56c1f0521a54 100644

test/py/pytest.ini markers = · line 14

Quoted 4 lines
test/py/pytest.ini +1 -0
@@ -11,3 +11,4 @@ markers =
       notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
       requiredtool: U-Boot: Required host tools for a test.
       slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache

Won't this hard-coding break running parallel invocations; they'll all try to use the same cache directory and conflict with each-other?

Quoted 7 lines
Quoted 3 lines

Various test/py tests create data files (e.g. disk images, files for DFU to download/upload, etc.). That directory must be writable. Can we tell pytest to use (a sub-directory of that) directory as the cache?

I don't think it will break anything today at least. We don't use pytest's cache_dir directly for creating our disk images, we put those elsewhere. This is strictly used by pytest itself, afaict.

Sure, but does pytest itself have all the required locking in place to support running multiple copies in parallel all set to the same cache directory? I run 3-5 instances of pytest at once on the same system, each managing a different target board.

author
#6 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

Quoted 45 lines · Stephen Warren
Quoted 44 lines · Tom Rini
Quoted 42 lines · Stephen Warren
Quoted 30 lines · Tom Rini

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
   test/py/pytest.ini | 1 +
   1 file changed, 1 insertion(+)
test/py/pytest.ini +0 -0
index e93d010f1fa2..56c1f0521a54 100644

test/py/pytest.ini markers = · line 14

Quoted 4 lines
test/py/pytest.ini +1 -0
@@ -11,3 +11,4 @@ markers =
       notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
       requiredtool: U-Boot: Required host tools for a test.
       slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache

Won't this hard-coding break running parallel invocations; they'll all try to use the same cache directory and conflict with each-other?

Various test/py tests create data files (e.g. disk images, files for DFU to download/upload, etc.). That directory must be writable. Can we tell pytest to use (a sub-directory of that) directory as the cache?

Quoted 8 lines
Quoted 3 lines

I don't think it will break anything today at least. We don't use pytest's cache_dir directly for creating our disk images, we put those elsewhere. This is strictly used by pytest itself, afaict.

Sure, but does pytest itself have all the required locking in place to support running multiple copies in parallel all set to the same cache directory? I run 3-5 instances of pytest at once on the same system, each managing a different target board.

I hope so. Can you throw this into your setup and see if anything breaks? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191031/a58ea2da/attachment.sig>
#7 lore raw

PATCH 1/1 test/py: Set cache_dir to /tmp/.pytest_cache

Quoted 50 lines · Tom Rini
Quoted 49 lines · Stephen Warren
Quoted 47 lines · Tom Rini
Quoted 39 lines · Stephen Warren
Quoted 30 lines · Tom Rini

For some time now, pytest has supported setting where a cache directory that it will use is located (and in turn has logic to re-use this cache and speed things up when possible). When running the pytest tests on Azure Pipelines, our source directory is read-only and we now see a warning about being unable to create the .pytest_cache directory as the default is in the same place as pytest.ini. Set cache_dir to /tmp/.pytest_cache so that it will always be placed in a read/write location.

Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

---
Looking at
https://docs.pytest.org/en/latest/customize.html#confval-cache_dir we could use an environment variable but TMP/TMPDIR/etc aren't always going to be set and that in turn leads to test/py/$TMPDIR/.pytest_cache being used. I think hard-coding to /tmp here ends up being less problematic but I am open to suggestions. We could even just ignore the warning, I only spotted it when seeing why a test had otherwise failed.

---
    test/py/pytest.ini | 1 +
    1 file changed, 1 insertion(+)
test/py/pytest.ini +0 -0
index e93d010f1fa2..56c1f0521a54 100644

test/py/pytest.ini markers = · line 14

Quoted 4 lines
test/py/pytest.ini +1 -0
@@ -11,3 +11,4 @@ markers =
        notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
        requiredtool: U-Boot: Required host tools for a test.
        slow: U-Boot: Specific test will run slowly.
+cache_dir = /tmp/.pytest_cache

Won't this hard-coding break running parallel invocations; they'll all try to use the same cache directory and conflict with each-other?

Quoted 3 lines

Various test/py tests create data files (e.g. disk images, files for DFU to download/upload, etc.). That directory must be writable. Can we tell pytest to use (a sub-directory of that) directory as the cache?

I don't think it will break anything today at least. We don't use pytest's cache_dir directly for creating our disk images, we put those elsewhere. This is strictly used by pytest itself, afaict.

Quoted 7 lines
Quoted 4 lines

Sure, but does pytest itself have all the required locking in place to support running multiple copies in parallel all set to the same cache directory? I run 3-5 instances of pytest at once on the same system, each managing a different target board.

I hope so. Can you throw this into your setup and see if anything breaks? Thanks!

That will only tell me whether I happen to notice problems, not whether it's guaranteed there will never be problems. I'll try and ask the pytest folk about the latter.

That said, It looks like the cache plugin is intended to run-to-run data passing. We don't currently do that at all (at least, not via the pytest cache plugin); do we plan to? If not, it'd be simpler to just disable the plugin completely (pytest -p no:cacheprovider). Alternatively, I believe option values can be specified on the command-line, and hence can be easily varied per run to avoid conflicts.