-
Notifications
You must be signed in to change notification settings - Fork 171
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
Js/device testing #6964
Js/device testing #6964
Conversation
6ee55b9
to
caef080
Compare
caef080
to
d6d1726
Compare
@@ -127,6 +127,7 @@ ClientHistory& get_history(DBRef db) | |||
return get_replication(db).get_history(); | |||
} | |||
|
|||
#if !REALM_MOBILE // the server is not implemented on devices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no functional changes to the code in this file, just moving tests under the !REALM_MOBILE flag if they used the server fixtures.
c_api/c_api.cpp | ||
c_api/c_api.c | ||
c_api/c_api_file_tests.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linking with cmake's OBJECT library exposed a bug that did not support two files of the same name because the system is looking for c_api.o and getting confused because it wasn't there (cmake generates two c_api_<id>.o
files to differentiate the two)
Why do we need all of the tests combined into a single app? We can't just run each of the separate apps in parallel? |
I'm not sure, that might be possible. @fealebenpae asked for this to help unblock him because it would simplify connecting to the device farm. |
test/CMakeLists.txt
Outdated
|
||
add_executable(CoreTests main.cpp test_all.cpp ${REQUIRED_TEST_FILES}) | ||
target_sources(CoreTests PUBLIC $<TARGET_OBJECTS:CoreTestLib>) | ||
target_sources(CoreTests PUBLIC $<TARGET_OBJECTS:TestUtil>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we link against TestUtil
as a normal library instead of just including the object files directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my understanding is that object libraries are just a build time optimization for when the archive file is large enough that creating it takes a meaningful amount of time and space, but TestUtil hopefully is very small. If we're having to work around any of the object library quirks then we should probably just use a static library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted TestUtil back to a static library.
test/CMakeLists.txt
Outdated
|
||
if(MSVC) | ||
# increase the number of sections supported in an obj file for the heavily templated tests | ||
target_compile_options(CombinedTests PRIVATE /bigobj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make sense on the CombinedTests
target? It's not actually compiling the source files where /bigobj
is needed, aren't those part of the *TestLib
targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed 👍
test/CMakeLists.txt
Outdated
target_sources(CombinedTests PUBLIC $<TARGET_OBJECTS:ObjectStoreTestLib>) | ||
if(REALM_ENABLE_SYNC) | ||
target_sources(CombinedTests PUBLIC $<TARGET_OBJECTS:SyncTestLib>) | ||
target_link_libraries(CombinedTests ObjectStoreTestLib CoreTestLib SyncTestLib Sync SyncServer Storage TestUtil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_sources
with the $<TARGET_OBJECTS:myTgt>
generator expression explicitly includes the object files in the link phase, target_link_libraries
where one of the targets is an OBJECT
library implies it. Only one should be necessary, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It turns out that target_sources
just links the source files while target_link_libraries
will do that as well as linking any transitively linked dependencies from the targets. The latter is what we want as it simplifies everything.
test/util/CMakeLists.txt
Outdated
@@ -50,7 +50,7 @@ if(REALM_ENABLE_SYNC) | |||
) | |||
endif() | |||
|
|||
add_library(TestUtil STATIC ${TEST_UTIL_SOURCES} ${TEST_UTIL_HEADERS}) | |||
add_library(TestUtil OBJECT ${TEST_UTIL_SOURCES} ${TEST_UTIL_HEADERS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think TestUtil
has to be an OBJECT
library, it can stay as static.
In order to run this on an actual device on iOS we need to set up a proper app machinery with an entrypoint ViewController, I think, which only needs to call into |
@tgoyne we're gearing up for running tests on AWS Device Farm devices and it's gonna save us a lot of time per run if we run all the tests in a combined package, instead of in parallel, and it will save on boilerplate in CI to set the runs up as well. This additional overhead is why we never bothered to run sync tests on iOS or Android simulator/emulators until now, for example. |
Why would it save any time per run? The only reason we weren't running sync tests on iOS was because they needed the changes here to be able to compile on iOS, not because there was anything difficult about executing them. I had actually set everything up to run the sync tests in the ios simulator on Jenkins and then commented it out when I discovered that the tests didn't compile. |
This is strictly for AWS Device Farm. When running the .NET tests on an Android device there the actual tests run in ~4 minutes, but the total step is ~9 minutes. I have seen similar overhead when doing manual tests with iOS devices on Device Farm. AWS just has some overhead for setting up and winding down tests on devices that we can avoid if we group tests together instead of in distinct executables. |
Ah, that makes sense then. |
Pull Request Test Coverage Report for Build james.stone_439
💛 - Coveralls |
@fealebenpae I believe we can change |
I tried to run this locally on a device. It initially failed because the "Bundle name" field in Info.plist was empty. After manually setting that (and the development team) I was able to run the tests on device and it all passed. I'm not sure offhand how to set that field in cmake. |
acebf36
to
613a898
Compare
@tgoyne @fealebenpae how about we merge these build changes in as a first step. Then the final work to hook up devices can be done in a smaller PR when we get time for it? That would save this branch from going stale. |
First steps towards #6923
In order to run all the tests on a device, they need to be combined into a single application. This means invoking the core, sync and object-store tests all from the same runner. This new target is called CombinedTests. I have done this in a way that makes object libraries from all the sources, so that a developer can switch between the CombinedTests and an individual runner without having to recompile everything. The restructuring surfaced a cross project compile dependency in the TestUtil library which I solved in the code by replacing the outdated sync::PrimaryKey concept with Mixed.
To prove that this works, I changed the iOS simulator check on Jenkins to run the combined test app. This showed where we have sync tests relying on unimplemented code for the sync server on device, so I added guards on those sync tests to only compile them if we are not on a mobile platform. This allows the rest of the sync tests to run on.
☑️ ToDos