thaliproject / Thali_CordovaPlugin

Thali p2p plugin
MIT License
226 stars 44 forks source link

Please change tests to use random SSDP_NT when we are running on desktop #1072

Closed yaronyg closed 7 years ago

yaronyg commented 7 years ago

Please see thaliproject/Thali_CordovaPlugin#1066 for context

Requirements:

When we run 'jx npm test' or 'jx npm run test-meta' we have to make sure that we use a randomly generated SSDP_NT value that will override the value from thaliConfig.js. We want to make sure however that the randomly generated value isn't put into thaliConfig.js since the test is run in our repo clone and we could accidentally check it in!

When we run 'jx npm run test-coordinated' on desktop (meaning inside of the repo clone) we need the node processes spawned by runCoordinatedTests.js to all have the same randomly generated SSDP_NT value or they won't find each other. To make things more complex if we are running both iOS and Android tests (e.g. when @artemjackson fixes thaliproject/Thali_CordovaPlugin#902) simultaneously then all the node processes using the iOS mock layer have to have the same randomly generated SSDP_NT value and all the node processes using the Android mock layer have to also all have the same SSDP_NT value but a different one than the iOS processes so the tests don't interact.

Ways to meet the requirements:

For 'jx npm test' and 'jx npm run test-meta' I suspect the original instructions in this bug probably made the most sense, that is, edit runTests.js to:

But this won't work for 'jx npm run test-coordinated' because it would result in all the spawned Node processes having different SSDP_NT values and so not finding each other. I can see two ways to fix this:

Personally I like passing the argument. It just seems simpler and it doesn't create any artifacts we could ever check in. But that's just my two cents. Pick which ever one you want and please implement! Or do you have a third option?

andrew-aladev commented 7 years ago

I am working on this issue now.

andrew-aladev commented 7 years ago

We can modify thaliConfig to use process.env.SSDP_NT || defaultValue. Our runTests.js will create random SSDP_NT if process.env.SSDP_NT is undefined. Our runCoordinatedTests can provide a fixed SSDP_NT for each spawn runTests.js process.

runCoordinatedTests can create fixed different SSDP_NT for Android and IOS spawns.

andrew-aladev commented 7 years ago

After this task we need to update SSDP_NT replacer a bit. It should replace only defaultValue.

yaronyg commented 7 years ago

Works for me! Environment variables it is.

andrew-aladev commented 7 years ago

I am still working on this issue and merging pull requests.