Commit Graph
444 Commits
Author SHA1 Message Date
Konstantin Varlamov 2311c36dbc Integrate Firestore with Firebase platform logging (#6507)
The sample user agent string I'm getting in XCode is `apple-platform/ios apple-sdk/17E8258 fire-fst/1.17.1 fire-ios/6.10.2 swift/true xcode/11E503a`.
2020-09-25 15:47:20 -04:00
Sebastian Schmidt 24a77d04c8 Import Spec tests (#6525)
* Import Spec tests

* Init

* Add recovery specs

* Update FSTSyncEngineTestDriver.mm
2020-09-22 18:48:04 -07:00
Brian Chen 21921e9851 Add != and notIn support (#6418) 2020-09-15 16:12:44 -05:00
Paul Beusterien a22b425377 Firestore - new public header structure (#6197) 2020-08-04 06:50:55 -07:00
Denver Coneybeare 69c3e4b9e5 Add an integration test for callbacks on the main thread (#6054) 2020-07-16 15:06:22 -04:00
Denver Coneybeare ffe23884da Add #include for config.h to get the value for HAVE_LIBDISPATCH (#6041) 2020-07-14 15:38:18 -04:00
Gil 59c8c95501 Have ListenerRegistration::Remove block until callbacks are complete (#5961)
* Add the ability to await a single expectation

* Await individual expectations in test helpers

This prevents tests from accidentally awaiting unrelated expectations
when using the helpers.

* Fix tests that implicitly relied on test helpers to await all

* Add a test that verifies ListenerRegistration::Remove blocks

* Block ListenerRegistration::Remove when there are outstanding callbacks.

* Test that remove does not block when called from the callback.
2020-07-06 13:06:36 -07:00
Gil 6f12f3871b Make snapshots in sync listener registration removal idempotent (#5945) 2020-06-30 09:32:37 -07:00
Gil eb6d343677 Fix TSAN errors in FIRListenerRegistrationTests (#5943) 2020-06-30 08:20:27 -07:00
Gil 7ef9914ff9 Fix TSAN violations in FSTTransactionTests (#5922)
TSAN uncovered cases where we were reading values in the transaction
thread that were set on the main thread and were unprotected by lock. In
practice this is unlikely to cause an harm, but it's good to keep TSAN
clean for when there are real issues.
2020-06-25 17:28:24 -07:00
Sebastian Schmidt 296a1ea1da Reset backoff when connectivity status changes (#5857) 2020-06-22 15:49:12 -07:00
Paul Beusterien d4621a636f Use preserve_paths instead of CocoaPods private (#5758) 2020-06-09 05:21:28 -07:00
Denver Coneybeare df3679275c Add an integration test for calling clearPersistence() on a newly-created Firestore instance. (#5515) 2020-05-04 14:55:17 -04:00
Gil 1df5574c4f Upgrade gRPC-C++ to 1.28.0 (#4312)
This unblocks nanopb changes proposed in #4264.

This upgrades everything in the gRPC constellation of dependencies to match gRPC at 1.28:

  * gRPC to 1.28.0 (note that gRPC 1.28.1, while released, is a fix for just the python binding and there's no gRPC-C++ CocoaPod at that version)
  * Abseil to 20200225 (as of gRPC 1.27 this is now a gRPC dependency too; there's a later patch but gRPC doesn't use it yet)
  * Protobuf C++ to 3.11.4 (only used for testing in Firestore)
  * C-Ares to 1.15.0
  * BoringSSL to match (no change between gRPC 1.27.0 and 1.28.0)

Also, this disables CFStream-based transport on Apple platforms. This works around b/133182964, wherein CFStream will occasionally fail to raise a has-bytes-available events, causing Firestore to appear to hang.
2020-04-22 14:03:34 -07:00
Gil 7a58eba2e5 Remove firebase/firestore from paths in Firestore/core (#5374)
* Manual Xcode project fixups

* Remove `firebase/firestore` from paths in Firestore/core

This renames all Firestore files under `Firestore/core` to remove the
interior `firebase/firestore` directory structure. This is motivated by
build failures under Windows where the filenames of intermediates were
too long.

Concretely:

  * `Firebase/core/src/firebase/firestore` becomes `Firebase/core/src`
  * `Firebase/core/test/firebase/firestore` becomes
    `Firebase/core/test/unit`

Moving the tests into a `unit` subdirectory aligns Firestore with the
directory structure in
[AddNewPod](https://github.com/firebase/firebase-ios-sdk/blob/master/AddNewPod.md),
modified for C++ (see discussion in #3224).
2020-04-20 14:57:34 -07:00
Gil 74f4ceb4c9 Fix unused variable warnings (#5389)
* Fix unused variable warnings

These are now exposed because libprotobuf is no longer polluting the
compiler command-line with -Wno-unused-parameter.

* Convert (void)var to __unused where possible
2020-04-20 14:23:36 -07:00
Gil 314f137bd5 Shorten CMake Objective-C targets (#5323)
* Shorten firebase_firestore_example_app

... and:
  * Migrate to firebase_ios_add_executable
  * Use globs for specifying sources

* Migrate Example/Tests/API to new CMake primitives

* Migrate Example/Tests/Integration to new CMake primitives

* Migrate Example/Tests/SpecTests to new CMake primitives

* Migrate Example/Tests/Util to new CMake primitives

Rename firebase_firestore_objc_test_util to firestore_objc_testing.

* Migrate fuzzing to new CMake primitives

Rewrite firebase_ios_cc_fuzz_test to match the other primitives.

* Add firebase_ios_add_objc_test

* Migrate Example/Benchmarks to new CMake primitives
2020-04-20 10:28:36 -07:00
Brian Chen 26430a9086 Check for error code matches in Transaction tests (#5391) 2020-04-16 09:12:42 -07:00
Brian Chen 0a352472a8 Fix flaky transaction tests (#5334) 2020-04-15 14:51:11 -07:00
Gil c873af8038 Shorten CMake test targets/begin firebase_core consolidation (#5321)
* Add new, simpler CMake helper functions

... making them more like built-in functions. This makes it possible to
combine other CMake functions in ways that weren't possible with the
original all-in-one approach.

This includes:
  * firebase_ios_add_executable
  * firebase_ios_add_test
  * firebase_ios_add_library

All of which can be combined with target_link_libraries, etc.

* Shorten CMake test targets, e.g. firebase_firestore_util_test => firestore_util_test

* Remove CMake file inclusion check

Now that we're committed to using globs for finding sources, this check
is incompatible and no longer useful.
2020-04-15 11:02:56 -07:00
Denver Coneybeare cd6d0f1c1d Implement limbo resolution listen throttling (#5310) 2020-04-15 12:01:09 -04:00
Gil 77f92cd2c6 Stop using built-in CMake Framework support (#5316)
* Fix previously unknown warnings

These become visible once flags are handled uniformly across all
Firestore targets in an upcoming build change.

* Stop using built-in CMake Framework support

CMake has built-in support for building Framework bundles (briefly:
bundles of libraries, associated headers, and resources) but this
doesn't work well for our needs.

1. In CMake 3.5.1 (our earliest supported CMake version) it doesn't copy
headers properly at build time.

2. Even up to CMake 3.15.5, CMake doesn't handle link-line multiplicity
correctly. CMake passes the static library location within the framework
and this seems to cause the linker to mishandle Objective-C metaclass
information resulting in duplicate symbols. Building with `-framework`
flags works correctly.

Previously we partially worked around the latter problem by building
some frameworks as shared instead of static frameworks, but this is
problematic because this mode of operation isn't actually intended and
is unsupported as far as the rest of Firebase is concerned. This turned
out to be fragile though and while refactoring libraries this workaround
broke.

Rather than piling on additional workarounds, this change converts the
frameworks to simple library targets and emulates framework imports
through include paths.

Additionally, this starts refactoring our cmake helper functions to make
them more like built-in functions. This makes it possible to freely use
different CMake features that were made difficult by trying to wrap
everything up in a single CMake command.

* style.sh generated changes

* Review feedback

* More review feedback
2020-04-14 08:40:33 -07:00
Denver Coneybeare b05e9eb68d Update spec tests from changes in the firebase-js-sdk respository (#5278) 2020-04-07 10:10:26 -04:00
Gil af7898c01e Merge remote_test_util and remote_testing libraries (#5254)
These two libraries duplicate each other in purpose:

  * firebase_firestore_remote_test_util
  * firebase_firestore_remote_testing

Additionally, several of the testing utilities in remote_test_util are
really only applicable to tests in the remote library anyway. These have
been put directly into firebase_firestore_remote_test.
2020-04-03 15:57:07 -07:00
Paul BeusterienandMarek Gilbert 4ea4340285 Upgrade clang-format (#5265)
Co-authored-by: Marek Gilbert <mcg@google.com>
2020-04-03 11:38:31 -07:00
Denver Coneybeare cb80ee63eb Log the total pass and skip count after running all spec tests (#5202) 2020-03-27 11:56:24 -04:00
Denver Coneybeare 4ae6f30c4d Add ability to selectively run spec tests via an environment variable. (#5203) 2020-03-27 08:24:14 -04:00
Gil a568a96f7e Add iOS build support to the CMake build (#5052)
* Use early exit in objc_framework CMakeLists.txt

* Clean up objc_framework CMakeLists.txt

  * Use `version` consistently
  * Use `firebase_ios_version` for the repo-level version
  * Remove INCLUDE directories that are no longer needed
  * Sort dependencies

* Simplify Example/App/CMakeLists.txt

  * Add `OBJC_FLAGS` directly, avoiding a separate `sources` variable.
  * Add resources directly

* Rename test host app to firebase_firestore_example_app

* Add a firebase_ios prefix to functions and variables

This reduces the chance of collision with other projects.

* Simplify compiler_setup

Now that compiler_setup.cmake no longer has side-effects, fold
compiler_id.cmake and archive_options.cmake into it and move
the include of compiler_setup up to the top of the main build.

* Add support for building for iOS

* Make building benchmarks optional

* Disable protoc-based source generators when cross-compiling

* Make downloading googletest optional

* Add DISABLE_STRICT_WARNINGS mode to cc_rules

This makes it possible to build non-Firestore components in the CMake
build to a lower standard than that to which we hold ourselves without
sacrificing the utility of the various build rules that we have.
2020-03-13 08:22:11 -07:00
Gil e404054a9f Refactor and clean up the CMake build ahead of CMake/iOS support (#5051)
* Use early exit in objc_framework CMakeLists.txt

* Clean up objc_framework CMakeLists.txt

  * Use `version` consistently
  * Use `firebase_ios_version` for the repo-level version
  * Remove INCLUDE directories that are no longer needed
  * Sort dependencies

* Simplify Example/App/CMakeLists.txt

  * Add `OBJC_FLAGS` directly, avoiding a separate `sources` variable.
  * Add resources directly

* Rename test host app to firebase_firestore_example_app

* Add a firebase_ios prefix to functions and variables

This reduces the chance of collision with other projects.

* Simplify compiler_setup

Now that compiler_setup.cmake no longer has side-effects, fold
compiler_id.cmake and archive_options.cmake into it and move
the include of compiler_setup up to the top of the main build.
2020-03-10 20:50:13 -07:00
Gil d9b7a33f0c Use forward declarations instead of IWYU (#4868)
* Remove rarely used template argumnets from SortedMap/SortedSet

* Remove unused STATUS_CHECK_OK

* Rename QuerySnapshot::Listener to QuerySnapshotListener

This makes the type something that can be forward declared.

* Rename DocumentSnapshot::Listener to DocumentSnapshotListener

This makes the type something that can be forward declared.

* Rename ViewSnapshot::Listener to ViewSnapshotListener

This makes the type something that can be forward declared.

* Put most QueryListener implementation in .cc

* Actually use sync_engine_callback.h

* Add forward declaration headers for api, core, and model

These centralize forward declarations, including declarations for some
hard-to-forward-declare types.

* Move includes of hard_assert.h out of other headers

* Make testutil definitions out of line

* Move definitions out-of-line

* Move DocumentKey definitions out-of-line

* Move definitions out-of-line

* Shorten unnecessarily long namespace usages

* Use default destructors where possible

* Delete unused MutationBatch::kUnknown constant

* Use forward declarations instead of IWYU

* Misc fixups from Linux/GCC 9.2.1

* Fix testutil under VS 2017

Forward declarations of functions local to a function body end up
generating unresolved externals. Reduce most of these back to just
calling FieldValue::FromX methods.
2020-02-15 14:34:38 -08:00
Sebastian Schmidt d80ccb03e8 Update Spec test protos (#4814) 2020-02-04 13:38:13 -08:00
Gil bff0d44be9 Add Firestore pod-lib-lint (#4797) 2020-02-03 09:23:39 -08:00
Gil 968da25ca8 Fix the Linux build under GCC 7.4.0 (#4761)
* Don't bother searching for XCTest on non-Apple platforms

* Force working directory to be in the project root

This makes the spec tests work when cmake is invoked with a relative filename.

* Fix build error on Linux/GCC 7.4.0
2020-01-29 10:23:42 -08:00
Gil ecb26bf438 Migrate LevelDB data out of ~/Documents (#4609)
This moves iOS and macOS user data from `NSDocumentDirectory` to `NSApplicationSupportDirectory`, adding a pre-open migration step that:

  * Moves old data into the new location
  * Cleans up any resulting empty directories in the old Documents folder
  * Stops before removing the Documents folder itself (see tests)

Note that other platforms don't need a migration:

  * tvOS was already storing documents in `NSCachesDirectory`
  * Linux, Windows, and other UNIX haven't been publicly released or aren't changing.

See individual commits for details. Most notably this adds some additional filesystem manipulation routines to our (sadly) growing library.

Fixes #843.
2020-01-16 17:36:23 -08:00
Brian Chen 9313d61a21 Add verify support (#4658) 2020-01-16 09:57:38 -08:00
wu-hui 51e17ac8c5 Rename QueryData|Cache to TargetData|Cache (#4670)
* Rename done by CLion

QueryCache -> TargetCache
QueryData -> TargetData

* Fix cmake list indention

* Fixing ordering.
2020-01-15 13:47:26 -05:00
Gil ff21f1ecb3 Make a Filesystem class that can be subclassed for testing (#4647)
This change does not yet change all the classes that use the filesystem
to take Filesystem as a dependency. Those changes will come in follow-up
PRs.

This change is motivated by feedback in #4609. There I had created a
complicated interface to LevelDbOpener just so that different migration
scenarios could be tested, when in reality, I just needed to be able to
plumb through different values for the result of AppDataDir and related
functions.
2020-01-10 06:58:01 -08:00
Sebastian Schmidt 423a62f874 Enable Index-Free queries (#4618) 2020-01-09 16:40:47 -08:00
Gil 6cc1a449ea Clean up Objective-C interop and other dead code (#4601)
* Remove unused -[FIRFirestore isLoggingEnabled]

Use util::LogIsLoggable(util::kLogLevelDebug) directly.

* Remove objc_compatibility.h

* Remove/cleanup unused #if __OBJC__ blocks

* Remove dead code

* Remove MakeNSStringNoCopy

* Remove worthless include

* Tidy up FIRFirestore

* Remove dead code and use forward declarations in FSTHelpers

* Minor fixes for LevelDbTransaction:

  * Make methods const where possible
  * Make key() and value() return const std::string&, allowing callers
    to create their own const references

* Remove Comparator<NSString*>
2020-01-08 18:40:29 -08:00
wu-hui 14e28121e2 Release LimitToLast (#4616)
* [1/4] Split Query and Target, and make LocalStore/RemoteStore work with Target. (#4413)

* [2/4]LimitToLast: Make SyncEngine work with Target (#4491)

* [3/4] Implement LimitToLast (#4505)
2020-01-08 09:04:28 -08:00
Gil 9a4f4e73c7 Miscellaneous fixes (#4584)
* Fix use after move in LevelDbPersistenceForTesting

* Fix size-related errors when compiling in 32-bit mode

* Fix test-only memory leaks

* Fix test-only memory leaks

* Prevent spec tests from appearing to leak

The spec tests aren't actually leaking, but they accumulate enough
garbage without clearing the autorelease pool that Instruments
complains.

* Avoid temporaries in methods that @throw

ARC does not release temporaries when an Objective-C exception is
thrown. Use C++ equivalents directly to avoid leaks as detected by
Instruments.

* Fix memory leak in acknowledge mutation

Any previous value must be freed before the next one is assigned.

* Manually implement assignment operators in ByteString

The single by-value implementation wasn't preventing the compiler
generated standard versions from being generated which was causing
leaks.

* Prevent leaking GrpcCompletions that complete after Shutdown

After shutdown, the AsyncQueue silently drops Enqueue requests which
prevents these blocks from being deleted.

* Avoid racing with enqueued operations

It's possible for the Executor to immediately execute the given block,
at which point the block might observe the async queue in a
not-shutting-down state.
2020-01-08 07:11:05 -08:00
Sebastian Schmidt d261cdeb9b Finish Index-Free queries (still disabled) (#4484) 2020-01-07 13:29:20 -08:00
Gil df3989b8a2 Fix lint warnings spotted by google3's linter (#4538) 2019-12-31 11:35:51 -06:00
Gil 16447a5e2b Restrict use of Abseil types in public C++ accessible APIs (#4503)
* Change string parameters from absl::string_view to std::string

No abseil types can be used as parameters in this package.

This fixes an issue where Unity builds fail due to missing symbols.

The underlying issue is that Abseil in CocoaPods is an LTS release and
LTS releases contain an inline namespace, making types like
absl::string_view link as absl::lts_2019_08_08::string_view. When
compiling Firestore in google3 it uses the abseil in //third_party/absl,
which is not an LTS release and does not include the inline namespace.
This disagreement causes issues for the public C++ API which is compiled
in google3 and consumes code in the API package.

* Avoid absl::any in interfaces shared with public C++

* Make resource-related methods class members

This gives them access to private methods of friends of Serializer.

* Access control FieldPath/ResourcePath construction

* Access control Document construction

* Access control FieldValue construction

* Access control TransformOperation methods

* Remove DocumentSnapshot constructor that takes metadata pieces individually

* Restrict access to DocumentSnapshot from optional<Document>

* Add comments indicating how Abseil types are restricted

* Make DocumentKey::FromPathString take std::string
2019-12-17 11:32:48 -08:00
Sebastian Schmidt 656b9c0889 Remove unused test helpers (#4473) 2019-12-10 13:07:52 -08:00
Gil e7172d5f09 Post-migration cleanups (#4451)
* Fix naming violations.

* Remove xcgmock

* Remove FSTTypes.h

* Remove FSTClasses.h
2019-12-07 18:33:18 -08:00
Gil 85365cb089 Get the remainder of Objective-C tests running under CMake (#4430)
* Add Objective-C API tests to the CMake build

* Fix signedness warnings under the CMake build

* Get the remainder of Objective-C tests running under CMake

Also:
  * Add a Path::HasExtension check
  * Change spec tests to pick up json without NSBundle
2019-12-06 10:11:05 -08:00
Gil c2fa88e3b0 Rewrite local store tests in C++ (#4421)
* Move FSTLocalStoreTests to core/test

* Add testutils for constructing TransformMutations

* Rewrite local store tests in C++
2019-12-05 08:37:15 -08:00
Sebastian Schmidt bd9d9d8b3c Index-Free Queries (disabled, some code + tests missing) (#4418) 2019-12-03 12:24:41 -08:00
wu-hui 2a8d069b77 Run integration tests from CMake on mac (#4276) 2019-11-19 13:40:43 -05:00