@@ -220,6 +220,116 @@ jobs:
220220 mlc rm repo mlcommons@mlperf-automations -f
221221 mlcr detect,cpu -j
222222
223+ - name : Test 26 - Test reindex command and verify index files are updated
224+ run : |
225+ INDEX_SCRIPT="${HOME}/MLC/repos/index_script.json"
226+ INDEX_CACHE="${HOME}/MLC/repos/index_cache.json"
227+ INDEX_EXPERIMENT="${HOME}/MLC/repos/index_experiment.json"
228+
229+ # Store initial modification times
230+ if [ -f "$INDEX_SCRIPT" ]; then
231+ BEFORE_SCRIPT=$(stat -c %Y "$INDEX_SCRIPT" 2>/dev/null || stat -f %m "$INDEX_SCRIPT" 2>/dev/null)
232+ fi
233+ if [ -f "$INDEX_CACHE" ]; then
234+ BEFORE_CACHE=$(stat -c %Y "$INDEX_CACHE" 2>/dev/null || stat -f %m "$INDEX_CACHE" 2>/dev/null)
235+ fi
236+ if [ -f "$INDEX_EXPERIMENT" ]; then
237+ BEFORE_EXPERIMENT=$(stat -c %Y "$INDEX_EXPERIMENT" 2>/dev/null || stat -f %m "$INDEX_EXPERIMENT" 2>/dev/null)
238+ fi
239+
240+ sleep 1
241+
242+ # Test reindex all
243+ mlc reindex
244+
245+ # Verify all index files were updated
246+ if [ -f "$INDEX_SCRIPT" ]; then
247+ AFTER_SCRIPT=$(stat -c %Y "$INDEX_SCRIPT" 2>/dev/null || stat -f %m "$INDEX_SCRIPT" 2>/dev/null)
248+ if [ "$BEFORE_SCRIPT" = "$AFTER_SCRIPT" ]; then
249+ echo "index_script.json was not updated after 'mlc reindex'. Exiting with failure."
250+ exit 1
251+ fi
252+ fi
253+
254+ sleep 1
255+ BEFORE_SCRIPT=$(stat -c %Y "$INDEX_SCRIPT" 2>/dev/null || stat -f %m "$INDEX_SCRIPT" 2>/dev/null)
256+
257+ # Test reindex specific target
258+ mlc reindex script
259+
260+ AFTER_SCRIPT=$(stat -c %Y "$INDEX_SCRIPT" 2>/dev/null || stat -f %m "$INDEX_SCRIPT" 2>/dev/null)
261+ if [ "$BEFORE_SCRIPT" = "$AFTER_SCRIPT" ]; then
262+ echo "index_script.json was not updated after 'mlc reindex script'. Exiting with failure."
263+ exit 1
264+ fi
265+
266+ # Test other reindex commands
267+ mlc reindex all
268+ mlc reindex cache
269+ mlc reindex experiment
270+
271+ - name : Test 27 - Test index handling when script/cache/repo is manually deleted
272+ run : |
273+ # Add a test script
274+ mlc add script test-delete-script --tags=test,delete,temp
275+
276+ # Get the actual script path from find command
277+ SCRIPT_PATH=$(mlc find script test-delete-script -p 2>&1)
278+ echo "Script path: $SCRIPT_PATH"
279+
280+ if [ -z "$SCRIPT_PATH" ]; then
281+ echo "Script was not found after adding. Exiting with failure."
282+ exit 1
283+ fi
284+
285+ # Manually delete the script
286+ if [ -d "$SCRIPT_PATH" ]; then
287+ rm -rf "$SCRIPT_PATH"
288+ echo "Manually deleted script at $SCRIPT_PATH"
289+ else
290+ echo "Script directory not found at $SCRIPT_PATH. Exiting with failure."
291+ exit 1
292+ fi
293+
294+ # Verify the deleted script is no longer in the index
295+ # The find command will automatically trigger index rebuild and detect the deletion
296+ FIND_RESULT=$(mlc find script test-delete-script -p 2>/dev/null)
297+ if [ -n "$FIND_RESULT" ]; then
298+ echo "ERROR: Deleted script still found in index. Found: $FIND_RESULT"
299+ exit 1
300+ fi
301+
302+ echo "Script deletion test passed successfully"
303+
304+ # Test with cache: run a script to create cache, then delete it manually
305+ mlc run script --tags=detect,os --quiet
306+
307+ # Find and delete a cache entry
308+ CACHE_PATH=$(mlc find cache --tags=detect,os -p 2>/dev/null | head -1)
309+ if [ -n "$CACHE_PATH" ] && [ -d "$CACHE_PATH" ]; then
310+ echo "Found cache at: $CACHE_PATH"
311+
312+ # Get the cache directory name for later verification
313+ CACHE_DIR_NAME=$(basename "$CACHE_PATH")
314+
315+ rm -rf "$CACHE_PATH"
316+ echo "Manually deleted cache at $CACHE_PATH"
317+
318+ # Verify the deleted cache is no longer in the index
319+ # Check if the cache directory name appears in any found caches
320+ if mlc find cache --tags=detect,os -p 2>/dev/null | grep -q "$CACHE_DIR_NAME"; then
321+ echo "ERROR: Deleted cache directory still found in index."
322+ echo "Deleted cache: $CACHE_PATH"
323+ echo "Found caches:"
324+ mlc find cache --tags=detect,os -p 2>/dev/null
325+ exit 1
326+ fi
327+
328+ echo "Cache deletion test passed successfully"
329+ else
330+ echo "No cache found to test deletion"
331+ fi
332+
223333 test_mlc_access_core_actions :
224334
225335 runs-on : ${{ matrix.os }}
0 commit comments