k8s.io/kubernetes@v1.29.3/test/utils/image/csi_manifests_test.go (about)

     1  /*
     2  Copyright 2022 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package image
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/stretchr/testify/assert"
    23  	"k8s.io/apimachinery/pkg/util/sets"
    24  )
    25  
    26  func TestCSIImageConfigs(t *testing.T) {
    27  	configs := map[ImageID]Config{}
    28  	appendCSIImageConfigs(configs)
    29  
    30  	// We expect at least one entry for each of these images. There may be
    31  	// more than one entry for the same image when different YAMLs use
    32  	// different versions.
    33  	//
    34  	// The exact versions are not checked here because that would bring
    35  	// back the problem of updating the expected versions. The set of
    36  	// images shouldn't change much.
    37  	expectedImages := []string{
    38  		"csi-attacher",
    39  		"csi-external-health-monitor-controller",
    40  		"csi-node-driver-registrar",
    41  		"csi-provisioner",
    42  		"csi-resizer",
    43  		"csi-snapshotter",
    44  		"hostpathplugin",
    45  		"livenessprobe",
    46  
    47  		// From the GCP deployment.
    48  		"gcp-compute-persistent-disk-csi-driver",
    49  
    50  		// For some hostpath tests.
    51  		"socat",
    52  		"busybox",
    53  
    54  		// For AnyVolumeDataSource feature tests.
    55  		"volume-data-source-validator",
    56  		"hello-populator",
    57  	}
    58  	actualImages := sets.NewString()
    59  	for _, config := range configs {
    60  		assert.NotEmpty(t, config.registry, "registry")
    61  		assert.NotEmpty(t, config.name, "name")
    62  		assert.NotEmpty(t, config.version, "version")
    63  		actualImages.Insert(config.name)
    64  	}
    65  	assert.ElementsMatch(t, expectedImages, actualImages.UnsortedList(), "found these images: %+v", configs)
    66  }