jstests/core/timeseries/timeseries_special_indexes_metadata.js
/**
     * Runs the find cmd on the time-series and buckets collections using 'bucketsIndexSpec' as an
     * index hint. Tests that hide() and unhide() of the index allows find to use or fail to use the
     * index, respectively. Tests that the listIndexes cmd returns the expected results from the
     * time-series and buckets collections.
     *
     * Some indexes (e.g. wildcard) need queries specified to use an index: the
     * 'timeseriesFindQuery' and 'bucketsFindQuery' can be used for this purpose.
     */
Runs the find cmd on the time-series and buckets collections using 'bucketsIndexSpec' as an
index hint. Tests that hide() and unhide() of the index allows find to use or fail to use the
index, respectively. Tests that the listIndexes cmd returns the expected results from the
time-series and buckets collections.

Some indexes  need queries specified to use an index: the
'timeseriesFindQuery' and 'bucketsFindQuery' can be used for this purpose.
Runs the find cmd on the time - series and buckets collections using ' bucketsIndexSpec ' as an index hint . Tests that hide () and unhide () of the index allows find to use or fail to use the index respectively . Tests that the listIndexes cmd returns the expected results from the time - series and buckets collections . Some indexes need queries specified to use an index : the ' timeseriesFindQuery ' and ' bucketsFindQuery ' can be used for this purpose .
function hideUnhideListIndexes(
        timeseriesIndexSpec, bucketsIndexSpec, timeseriesFindQuery = {}, bucketsFindQuery = {}) {
        jsTestLog("Testing index spec, time-series: " + tojson(timeseriesIndexSpec) +
                  ", buckets: " + tojson(bucketsIndexSpec));
        assert.gt(
            timeseriescoll.find(timeseriesFindQuery).hint(timeseriesIndexSpec).toArray().length, 0);
        assert.gt(bucketscoll.find(bucketsFindQuery).hint(bucketsIndexSpec).toArray().length, 0);
        listIndexesHasIndex(timeseriesIndexSpec);
        assert.commandWorked(timeseriescoll.hideIndex(timeseriesIndexSpec));
        assert.commandFailedWithCode(
            assert.throws(() => timeseriescoll.find().hint(timeseriesIndexSpec).toArray()),
                         ErrorCodes.BadValue);
        assert.commandFailedWithCode(
            assert.throws(() => bucketscoll.find().hint(bucketsIndexSpec).toArray()),
                         ErrorCodes.BadValue);
        listIndexesHasIndex(timeseriesIndexSpec);
        assert.commandWorked(timeseriescoll.unhideIndex(timeseriesIndexSpec));
        assert.gt(
            timeseriescoll.find(timeseriesFindQuery).hint(timeseriesIndexSpec).toArray().length, 0);
        assert.gt(bucketscoll.find(bucketsFindQuery).hint(bucketsIndexSpec).toArray().length, 0);
    }
function hideUnhideListIndexes ( timeseriesIndexSpec , bucketsIndexSpec , timeseriesFindQuery = { } , bucketsFindQuery = { } ) { jsTestLog ( "Testing index spec, time-series: " + tojson ( timeseriesIndexSpec ) + ", buckets: " + tojson ( bucketsIndexSpec ) ) ; assert . gt ( timeseriescoll . find ( timeseriesFindQuery ) . hint ( timeseriesIndexSpec ) . toArray ( ) . length , 0 ) ; assert . gt ( bucketscoll . find ( bucketsFindQuery ) . hint ( bucketsIndexSpec ) . toArray ( ) . length , 0 ) ; listIndexesHasIndex ( timeseriesIndexSpec ) ; assert . commandWorked ( timeseriescoll . hideIndex ( timeseriesIndexSpec ) ) ; assert . commandFailedWithCode ( assert . throws ( ( ) => timeseriescoll . find ( ) . hint ( timeseriesIndexSpec ) . toArray ( ) ) , ErrorCodes . BadValue ) ; assert . commandFailedWithCode ( assert . throws ( ( ) => bucketscoll . find ( ) . hint ( bucketsIndexSpec ) . toArray ( ) ) , ErrorCodes . BadValue ) ; listIndexesHasIndex ( timeseriesIndexSpec ) ; assert . commandWorked ( timeseriescoll . unhideIndex ( timeseriesIndexSpec ) ) ; assert . gt ( timeseriescoll . find ( timeseriesFindQuery ) . hint ( timeseriesIndexSpec ) . toArray ( ) . length , 0 ) ; assert . gt ( bucketscoll . find ( bucketsFindQuery ) . hint ( bucketsIndexSpec ) . toArray ( ) . length , 0 ) ; }
Runs the find cmd on the time-series and buckets collections using 'bucketsIndexSpec' as an
 index hint.
Runs the find cmd on the time - series and buckets collections using ' bucketsIndexSpec ' as an index hint .
// Check that the index is usable. // Check that listIndexes returns expected results. // Hide the index and check that the find cmd no longer works with the 'bucketsIndexSpec' // hint. // Check that the index can still be found via listIndexes even if hidden. // Unhide the index and check that the find cmd with 'bucketsIndexSpec' works again.