|
1 | 1 | package integration
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "fmt" |
4 | 5 | "regexp"
|
5 |
| - "strings" |
6 | 6 | "testing"
|
7 | 7 | "time"
|
8 | 8 |
|
@@ -145,49 +145,60 @@ func TestUnreachableHost(t *testing.T) {
|
145 | 145 | t.Log(errDegraded)
|
146 | 146 | }
|
147 | 147 |
|
148 |
| -//https://bugzilla.redhat.com/show_bug.cgi?id=1838973 |
149 |
| -func latestArchiveContainsPodLogs(t *testing.T) { |
150 |
| - logCount, err := latestArchiveContainsFiles(t, `^config/pod/openshift-monitoring/logs/.*\.log$`) |
151 |
| - e(t, err, "Checking for log files failed") |
152 |
| - t.Log(logCount, "log files found") |
153 |
| - if logCount == 0 { |
154 |
| - t.Error("no log files in archive") |
| 148 | +func genLatestArchiveCheckPattern(prettyName string, check func(*testing.T, string, []string, *regexp.Regexp) error, pattern string) func(t *testing.T) { |
| 149 | + return func(t * testing.T){ |
| 150 | + err := latestArchiveCheckFiles(t, prettyName, check, pattern) |
| 151 | + if err!=nil{ |
| 152 | + t.Fatal(err) |
| 153 | + } |
155 | 154 | }
|
156 | 155 | }
|
157 | 156 |
|
158 |
| -//https://bugzilla.redhat.com/show_bug.cgi?id=1767719 |
159 |
| -func latestArchiveContainsEvent(t *testing.T) { |
160 |
| - logCount, err := latestArchiveContainsFiles(t, `^events/openshift-monitoring.json$`) |
161 |
| - e(t, err, "Checking for event failed") |
162 |
| - t.Log(logCount, "event files found") |
163 |
| - if logCount == 0 { |
164 |
| - t.Error("no event file in archive") |
| 157 | +func latestArchiveContainsConfigMaps(t *testing.T) { |
| 158 | + configMaps, _ := clientset.CoreV1().ConfigMaps("openshift-config").List(metav1.ListOptions{}) |
| 159 | + if len(configMaps.Items) == 0 { |
| 160 | + t.Fatal("Nothing to test: no config maps in openshift-config namespace") |
165 | 161 | }
|
166 |
| -} |
167 |
| - |
168 |
| -//https://bugzilla.redhat.com/show_bug.cgi?id=1840012 |
169 |
| -func latestArchiveFilesContainExtensions(t *testing.T) { |
170 |
| - regex, err := regexp.Compile(knownFileSuffixesInsideArchiveRegex) |
171 |
| - e(t, err, "failed to compile pattern") |
172 |
| - archiveFiles := latestArchiveFiles(t) |
173 |
| - t.Log(strings.Join(archiveFiles, "\n")) |
174 |
| - if len(archiveFiles) == 0 { |
175 |
| - t.Fatal("No files in archive to check") |
176 |
| - } |
177 |
| - for _, fileName := range archiveFiles { |
178 |
| - if !regex.MatchString(fileName) { |
179 |
| - t.Errorf(`file "%s" does not match pattern "%s"`, fileName, knownFileSuffixesInsideArchiveRegex) |
| 162 | + for _, configMap := range configMaps.Items { |
| 163 | + configMapPath := fmt.Sprintf("^config/configmaps/%s/.*$", configMap.Name) |
| 164 | + err := latestArchiveCheckFiles(t, "config map", matchingFileExists, configMapPath) |
| 165 | + if err != nil { |
| 166 | + t.Error(err) |
180 | 167 | }
|
181 | 168 | }
|
182 | 169 | }
|
183 | 170 |
|
184 |
| -func TestCollectingAfterDegradingOperator(t *testing.T) { |
| 171 | +func TestArchiveContains(t *testing.T) { |
| 172 | + //https://bugzilla.redhat.com/show_bug.cgi?id=1825756 |
| 173 | + t.Run("ConfigMaps", latestArchiveContainsConfigMaps) |
| 174 | + |
| 175 | + //https://bugzilla.redhat.com/show_bug.cgi?id=1834677 |
| 176 | + t.Run("ImageRegistry", |
| 177 | + genLatestArchiveCheckPattern( |
| 178 | + "image registry", matchingFileExists, |
| 179 | + `^config/imageregistry.json$`)) |
| 180 | + |
185 | 181 | defer ChangeReportTimeInterval(t, 1)()
|
186 | 182 | defer degradeOperatorMonitoring(t)()
|
187 | 183 | checkPodsLogs(t, clientset, `Wrote \d+ records to disk in \d+`, true)
|
188 |
| - t.Run("Logs", latestArchiveContainsPodLogs) |
189 |
| - t.Run("Event", latestArchiveContainsEvent) |
190 |
| - t.Run("FileExtensions", latestArchiveFilesContainExtensions) |
| 184 | + |
| 185 | + //https://bugzilla.redhat.com/show_bug.cgi?id=1838973 |
| 186 | + t.Run("Logs", |
| 187 | + genLatestArchiveCheckPattern( |
| 188 | + "log", matchingFileExists, |
| 189 | + `^config/pod/openshift-monitoring/logs/.*\.log$`)) |
| 190 | + |
| 191 | + //https://bugzilla.redhat.com/show_bug.cgi?id=1767719 |
| 192 | + t.Run("Event", |
| 193 | + genLatestArchiveCheckPattern( |
| 194 | + "event", matchingFileExists, |
| 195 | + `^events/openshift-monitoring.json$`)) |
| 196 | + |
| 197 | + //https://bugzilla.redhat.com/show_bug.cgi?id=1840012 |
| 198 | + t.Run("FileExtensions", |
| 199 | + genLatestArchiveCheckPattern( |
| 200 | + "extension of", allFilesMatch, |
| 201 | + knownFileSuffixesInsideArchiveRegex)) |
191 | 202 | }
|
192 | 203 |
|
193 | 204 | // https://bugzilla.redhat.com/show_bug.cgi?id=1782151
|
|
0 commit comments