summaryrefslogtreecommitdiff
path: root/cmds/statsd/tests/shell/ShellSubscriber_test.cpp
AgeCommit message (Collapse)Author
2020-12-03Migrate frameworks/base/cmds/statsd to packages/modules/StatsD/binBaligh Uddin
Add statsd protos to platform_protos rule BUG: 167962588 TEST: TH TEST: Local build [ crosshatch-userdebug ] Change-Id: I053f2a211ea28c2f181937af3d58ad16b235d096
2020-11-24Revert^2 "Delete atoms.proto from statsd"Jeffrey Huang
217301c36f7ffd500441cb879a4fa88b770092db Change-Id: I81a8287ed5b055e7b6547794d01e7ac897f0f022
2020-11-24Revert "Delete atoms.proto from statsd"Alex Light
Revert "Add android bp to proto_logging" Revert submission 13070789-atomsproto Reason for revert: Breaks multiple git_master-without-vendor targets ``` out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp error: frameworks/base/tools/stats_log_api_gen/Android.bp:49:1: "stats-log-api-gen-test" depends on undefined module "libstats_proto_host" ninja: build stopped: subcommand failed. ``` Reverted Changes: I184cf8bf8:Add android bp to proto_logging I36ec354d2:Delete atoms.proto from statsd Bug: 167962588 Change-Id: Idce97c5cf020473744eb7f96dcfbdc7677c094da
2020-11-23Delete atoms.proto from statsdJeffrey Huang
Use the atoms.proto in proto_logging as the source of truth. Also migrates statsd log api gen to use the new atoms.proto Bug: 167962588 Test: m -j && m CtsStatsdAtomHostTestCases Change-Id: I36ec354d273dceace5245d7634c68ac63dc5a8cd
2020-07-01Remove old puller code from uid sandboxingTej Singh
Uid sandboxing has been enabled for months now. Remove the old code that ran before we flipped the flag. Test: atest statsd_test Bug: 152544281 Change-Id: Ib7cb79f368ef112774a278a2cf57fffc907a1099
2020-05-13Statsd: pull once per event timeTej Singh
If a pull happens at the same event time, we should reuse the existing data, regardless of whether or not the cool down has been met. For example, if an app upgrade happens at time t, and two metrics need to pull atom a, if metric one pulls at time t, but metric two initiates the pull at time t+2, we should still reuse the pull from time t since that is when the app upgrade happened. Bug: 156294650 Test: atest statsd_test Change-Id: I4efc49545093f6683bf6dd89ed68c5dfa5b44d8f
2020-05-06Fix ShellSubscriber concurrency issuesRuchir Rastogi
This CL creates a sendHeartbeat thread that ocassionally sends heartbeats, consisting of a dataSize of 0, to perfd. perfd will discard those heartbeats, recheck if the user has canceled the subscription, and if not, wait for more data from statsd. Sending heartbeats solves two big problems: (1) Allows statsd to robustly check if writes to the socket fail because the read end of the pipe has closed. Previously, if no atoms were pushed or pulled, statsd never attempted to write to perfd, so statsd could never detect the end of the subscription. However, now, writes are regularly made regardless of if statsd receives data. Note that even if atoms were pushed or pulled, there is no guarantee that they would have matched the atom matchers sent in perfd's config. (2) Allows perfd to escape a blocking read call and recheck whether the user has canceled the subscription. If no data is sent to perfd, perfd will block in this read call and the AndroidStudio UI will freeze up. Heartbeats are only sent if statsd has not sent any data to perfd within the last second, so we do not spam perfd with writes. + decomposes the startNewSubscription function + prevents startPull from holding the lock while sleeping Test: atest stastd_test Test: atest CtsStatsdHostTestCases Test: manually confirm that AndroidStudio is not freezing Bug: 153595161 Change-Id: I78f0818e8ed29bdadd02c151444ee7c9555623a4
2020-04-08statsd unit test and benchmark refactortsaichristine
Abstract test utilities into two new functions: writeAttribution and parseStatsEventToLogEvent Bug: 149590301 Test: bit statsd_test:* && bit statsd_benchmark:* Change-Id: I5f77646b6d2d828344b8b6de8777a60d98f96d58
2020-03-27Uid Sandboxing of PullersTej Singh
Overall flow of implementation: 1. parsing the config in MetricsManager to store the uids per atom. It follows the mAllowedLogSources logic very closely 2. MetricsManager register itself as a PullUidProvider with the PullerManager. 3. Metrics pass the config key when pulling (for both registering receivers and normal pulls) , and the puller manager gets the allowed uids from the PullUidProvider for that config. 4. PullerManager keys receivers by <atomId, configKey> so that it can look up the uids for that atom using the PullUidProvider as well. 5. Added shell subscriber support. Hardcode a default of AID_SYSTEM for them and also allow packages per atom. This involved adding a second interface to Pull that simply accepts the uids, since I didnt want to make the ShellSubscriber a PullUidProvider as well. 6. Change adb shell cmd stats pull-source to allow users to specify a package. Default to AID_SYSTEM as well. Notes: The feature is flagged off right now, since configs do not pass in the desired package. Another approach could be to hardcode in the current mapping, but that doesn't work for OEM pulled atoms. Test: m statsd Test: bit statsd_test:* with useUids = false Test: bit statsd_test:* with useUids = true Bug: 144099783 Bug: 151978258 Change-Id: I4a7481d7402a52b9beb4ea28b102803f9e50e79f
2020-03-23(Part 3) Use new socket schema with statsd teststsaichristine
Update last set of statsd tests to use new socket schema Test: bit statsd_test:* Bug: 149590301 Change-Id: I0fe2c219ad75813db54ff0cfbad50f55e29cb626
2020-03-19Implement new perfd<->statsd ShellSubscriber comm.Ruchir Rastogi
Because we no longer linkToDeath against a binder object to detect if the cmd process has died, we detect deaths by checking if writes fail. ag/10476582 proves that writes fail if the cmd process dies. Test: m statsd Test: bit statsd_test:ShellSubscriberTest.testPushedSubscription Test: bit statsd_test:ShellSubscriberTest.testPulledSubscription Bug: 150619687 Change-Id: I44a777ffff11e5b9298912b2906063c65e9009eb
2020-02-18Comment out Statsd testsJeffrey Huang
Added todos to make them ues the new schema. Bug: 145923087 Test: m -j && bit statsd_test:* Change-Id: I0749760eb3123407b78b9ace9a93967bac727bf5
2020-02-14Move statsd (and tests) to libbinder_ndkRuchir Rastogi
Major changes include: - Removing unused permission checks within StatsService. These include ENFORCE_DUMP_AND_USAGE_STATS, checkDumpAndUsageStats, kOpUsage, and kPermissionUsage. - Converting from sp to shared_ptr - Using libbinder_ndk functions instead of libbinder functions (e.g. for installing death recipients, getting calling uids, etc.) - New death recipients were added in StatsService, ConfigManager, and SubscriberReporter. - Using a unique token (timestamp) to identify shell subscribers instead of IResultReceiver because IResultReceiver is not exposed by libbinder_ndk. Currently, statsd cannot detect if perfd dies; we will fix that later. Bug: 145232107 Bug: 148609603 Test: m statsd Test: m statsd_test Test: bit stastd_test:* Test: atest GtsStatsdHostTestCases Change-Id: Ia1fda7280c22320bc4ebc8371acaadbe8eabcbd2
2019-01-03Add a timeout option in shell subscriber.Yao Chen
Test: cts added Change-Id: I0fe854fcfd5535ed03e502a4cad3f57079b45381
2018-12-21Puller refactorChenjie Yu
1) Refactor pullers and add tests. 2) Add timeout to a puller. mPullTimeoutNs is intrinsic to puller. A pull taking longer than this is deemed failed and the data discarded. A metric or StatsPullerManager requesting a pull should monitor the pull and have deadlineNs. A successful pull may come later than desired due to statsd processing delays. 3) Add unit tests to puller now that the base puller is more complicated. Bug: 118756964 Test: unit test Change-Id: I0e5d47e2527391f7beef4b2d06bfd5c2f82f1179
2018-10-12Add pulled atom subscription for shell.Yao Chen
+ Changed the output format from Atom to ShellData, which is a wrapper for repeated Atom This is useful because pulled atoms are usually a list of atoms. Test: statsd_test added Bug: 110536553 Change-Id: I0e2f55bdd9015c9bc95b87a630297c6f13e39636
2018-10-01Add unit tests for ShellSubscriber and fix a bugYao Chen
Test: statsd_test Change-Id: Iaf0558ec2a2dc190bedb240da8019868266ec8f5