How do I define the default cache and cache settings programmically in a Kernel test? A user provided a set of site caching configuration settings that cause some errors. For example:

$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
$settings['cache']['bins']['discovery'] = 'cache.backend.memcache';


On top of that, the memcache module states that users must include the following in their site configuration:

$settings['cache']['default'] = 'cache.backend.memcache';


I would like to extend some core Kernel tests to run with the memcache module configured the way the user described. I can easily enable the module by adding it to the $modules array in the MyTest class. What else do I need to add to ensure the “site configuration settings” are the way the user recommends. I was hoping I could add something to the MyTest::setUp() function to change the settings, or better yet, have a dataProvider to supply a variety of settings to the test function to test against. I thought there would be something obvious in the system.performance configuration item, but it looks like cache.default is a service. Do I need to redefine this service programmically? How do I do that? The memcache module does not automatically override the cache.default service in its services.yml file.
Take a look the Memcache module.
The module has tests, and seems you need write

  protected function setUp() {
    $this-&gt;config = [
      'memcache' =&gt; [
        'servers' =&gt; ['127.0.0.2:12345' =&gt; 'default'],
        'bin' =&gt; ['default' =&gt; 'default'],
      ],
      'hash_salt' =&gt; $this-&gt;randomMachineName(),
    ];
    $settings = new Settings($this-&gt;config);
    $this-&gt;settings = new MemcacheSettings($settings);
  }