Skip to content

Commit 0b85dff

Browse files
authored
[macOS] Fix indexing timeout on macOS-14; make script verbose (#11982)
1 parent cf96585 commit 0b85dff

File tree

1 file changed

+52
-18
lines changed

1 file changed

+52
-18
lines changed

Diff for: images/macos/scripts/build/configure-system.sh

+52-18
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66

77
source ~/utils/utils.sh
88

9-
# Set solid color wallpaper
9+
echo "Set solid color wallpaper"
1010
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/System/Library/Desktop Pictures/Solid Colors/Black.png"'
1111

12-
# Close all finder windows because they can interfere with UI tests
12+
echo "Close all finder windows because they can interfere with UI tests"
1313
close_finder_window
1414

15-
# Disable Handoff and Continuity
15+
echo "Disable Handoff and Continuity"
1616
defaults write com.apple.coreservices.useractivityd ActivityReceivingEnabled -bool false
1717
defaults write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool false
1818

19-
# Disable graphic effects in System
19+
echo "Disable graphic effects in System"
2020
defaults write com.apple.universalaccess reduceMotion -bool true
2121
defaults write com.apple.universalaccess reduceTransparency -bool true
2222

23-
# Disable analytics daemon (requires SIP to be disabled)
23+
echo "Disable analytics daemon (requires SIP to be disabled)"
2424
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.SubmitDiagInfo.plist
2525

26-
# Disable notification center agent
26+
echo "Disable notification center agent"
2727
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
2828

29-
# Disable Time Machine and it's daemon
29+
echo "Disable Time Machine and it's daemon"
3030
sudo tmutil disable
3131
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.backupd.plist
3232

33-
# Disable Apple Push Notification Service daemon
33+
echo "Disable Apple Push Notification Service daemon"
3434
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist
3535

3636
# Remove Parallels Desktop
@@ -40,32 +40,66 @@ if is_SonomaX64 || is_VenturaX64 || is_SequoiaX64; then
4040
brew uninstall parallels
4141
fi
4242

43-
# Put documentation to $HOME root
43+
echo "Put documentation to $HOME root"
4444
cp $HOME/image-generation/output/software-report/systeminfo.* $HOME/
4545

46-
# Remove fastlane cached cookie
46+
echo "Remove fastlane cached cookie"
4747
rm -rf ~/.fastlane
4848

4949
# Clean up npm cache which collected during image-generation
5050
# we have to do that here because `npm install` is run in a few different places during image-generation
51+
echo "Clean up npm cache"
5152
npm cache clean --force
5253

5354
# Clean yarn cache
5455
yarn cache clean
5556

56-
# Clean up temporary directories
57+
echo "Clean up temporary directories"
5758
sudo rm -rf ~/utils /tmp/*
5859

5960
# Erase all indexes and wait until the rebuilding process ends,
60-
# for now there is no way to get status of indexing process, it takes around 5 minutes to accomplish
61-
sudo mdutil -E /
62-
sudo log stream | grep -q -E 'mds.*Released.*BackgroundTask' || true
63-
echo "Indexing completed"
64-
65-
# delete symlink for tests running
61+
# for now there is no clear way to get status of indexing process on macOS, it takes around 3-6 minutes to accomplish
62+
echo "Erase all MDS indexes and wait until the rebuilding process ends"
63+
sudo mdutil -E / > /dev/null
64+
65+
echo "Wait for 6 minutes or until the indexing process end signal is found in logs"
66+
for _ in {1..12}; do
67+
sleep 30
68+
result=$(sudo log show --last 1m | grep -E 'mds.*Released.*BackgroundTask' || true)
69+
if [[ -n "$result" ]]; then
70+
echo "Sign of indexing completion found:"
71+
echo "$result"
72+
break
73+
fi
74+
done
75+
76+
echo "Check if the indexing process or other CPU intensive process (5% and more) is still running"
77+
78+
cool=0
79+
while true; do
80+
usage=$(top -l 2 | grep "CPU usage" | awk '{print int($3)}' | tr -d '%' | tail -n 1)
81+
echo "Current CPU usage: ${usage}%"
82+
if [ $usage -lt 5 ]; then
83+
cool=$((cool + 1))
84+
else
85+
ps -arcwwwxo ppid,pid,%cpu,%mem,time,command | head -n 2 || true
86+
cool=0
87+
fi
88+
89+
echo "Feeling cool for $cool intervals"
90+
91+
if [ $cool -gt 5 ]; then
92+
echo "Cooled down, exiting..."
93+
break
94+
fi
95+
96+
sleep 1
97+
done
98+
99+
echo "Delete symlink for tests running"
66100
sudo rm -f /usr/local/bin/invoke_tests
67101

68-
# Clean Homebrew downloads
102+
echo "Clean Homebrew downloads"
69103
sudo rm -rf /Users/$USER/Library/Caches/Homebrew/downloads/*
70104

71105
# Uninstall expect used in configure-machine.sh

0 commit comments

Comments
 (0)