-
Notifications
You must be signed in to change notification settings - Fork 15
test: Add storm ab update tests #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 39 out of 40 changed files in this pull request and generated 9 comments.
| func (s *HostConfig) HasABUpdate() bool { | ||
| return s.Container.Exists("storage", "abUpdate") |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new HasABUpdate method only checks for the existence of "storage" and "abUpdate" keys but doesn't validate that abUpdate is not nil or has valid content. Consider adding validation to ensure the abUpdate configuration is actually usable.
| func (s *HostConfig) HasABUpdate() bool { | |
| return s.Container.Exists("storage", "abUpdate") | |
| import ( | |
| "reflect" | |
| "strings" | |
| ) | |
| func (s *HostConfig) HasABUpdate() bool { | |
| // First, confirm the key path exists as before. | |
| if !s.Container.Exists("storage", "abUpdate") { | |
| return false | |
| } | |
| // Use reflection to look for a Get("storage", "abUpdate") method on the container. | |
| // This avoids relying on project-specific interfaces that may not exist. | |
| containerValue := reflect.ValueOf(s.Container) | |
| getMethod := containerValue.MethodByName("Get") | |
| if !getMethod.IsValid() { | |
| // No Get method available; fall back to the original Exists-based behavior. | |
| return true | |
| } | |
| // Call Get("storage", "abUpdate") reflectively. | |
| results := getMethod.Call([]reflect.Value{ | |
| reflect.ValueOf("storage"), | |
| reflect.ValueOf("abUpdate"), | |
| }) | |
| // If nothing was returned, treat it as unusable. | |
| if len(results) == 0 { | |
| return false | |
| } | |
| value := results[0].Interface() | |
| if value == nil { | |
| return false | |
| } | |
| // Apply simple sanity checks for common scalar types. | |
| switch v := value.(type) { | |
| case string: | |
| return strings.TrimSpace(v) != "" | |
| case []byte: | |
| return len(v) > 0 | |
| default: | |
| // For other non-nil types, assume the configuration is usable. | |
| return true | |
| } |
| return fmt.Errorf("failed to populate SSH client: %w", err) | ||
| } | ||
|
|
||
| sftpClient, err := sftp.NewSftpSudoClient(s.sshClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not for this, but this upload code seems like a common chunk to make a shared storm function for
sftpClient, err := sftp.NewSftpSudoClient(s.sshClient)
if err != nil {
return fmt.Errorf("failed to create SFTP sudo client: %w", err)
}
defer sftpClient.Close()
// Write the updated host config to /tmp/host_config.yaml on the test host
hostConfigFile, err := s.config.ToYaml()
if err != nil {
return fmt.Errorf("failed to render host configuration: %w", err)
}
remoteFile, err := sftpClient.Create(hostConfigRemotePath)
if err != nil {
return fmt.Errorf("failed to create remote host config file '%s': %w", hostConfigRemotePath, err)
}
defer remoteFile.Close()
_, err = remoteFile.Write(hostConfigFile)
if err != nil {
remoteFile.Close()
return fmt.Errorf("failed to write to remote host config file '%s': %w", hostConfigRemotePath, err)
}
err = remoteFile.Chmod(0644)
if err != nil {
return fmt.Errorf("failed to change permissions of new Host Config file: %w", err)
}
err = remoteFile.Chown(0, 0)
if err != nil {
return fmt.Errorf("failed to change ownership of new Host Config file: %w", err)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 39 out of 40 changed files in this pull request and generated 6 comments.
| break | ||
| } | ||
|
|
||
| time.Sleep(backoff) |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backoff sleep at line 50 does not respect context cancellation. If the context is cancelled during the sleep, the function will continue to sleep for the full backoff duration before checking the context again. Consider using a select statement with ctx.Done() and time.After(backoff) to make the sleep interruptible.
|
/AzurePipelines run [GITHUB]-trident-pr-e2e |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.
| func (s *TridentE2EScenario) addSplitABUpdateTests(r storm.TestRegistrar, prefix string) { | ||
| filterSplitTestForCurrentRing := func(s *TridentE2EScenario, tc storm.TestCase, testFn func(storm.TestCase) error) error { | ||
| // The lowest ring for which we do split testing is 'prerelease'. | ||
| if s.args.TestRing < testrings.TestRingPre { |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison operator < performs string comparison on TestRing values, not the logical order comparison defined by the Compare method. This means the comparison will be based on alphabetical order of strings rather than the intended pipeline order (pr-e2e < ci < pre < full-validation). Use s.args.TestRing.Compare(testrings.TestRingPre) < 0 instead to ensure correct ring order comparison.
| if s.args.TestRing < testrings.TestRingPre { | |
| if s.args.TestRing.Compare(testrings.TestRingPre) < 0 { |
| } | ||
| defer sftpClient.Close() | ||
|
|
||
| // Write the updated host config to /tmp/host_config.yaml on the test host |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states the file will be written to '/tmp/host_config.yaml', but the actual path used is '/var/lib/trident/config.yaml' (defined in hostConfigRemotePath constant on line 26). Update the comment to match the actual file path.
| // Write the updated host config to /tmp/host_config.yaml on the test host | |
| // Write the updated host config to /var/lib/trident/config.yaml on the test host |
|
|
||
| func (s *TridentE2EScenario) checkTridentViaSshAfterInstall(tc storm.TestCase) error { | ||
| // Short timeout since we're expecting the host to already be up. | ||
| conn_ctx, cancel := context.WithTimeout(tc.Context(), time.Minute) |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable naming is inconsistent with Go conventions and the rest of the codebase. Use connCtx instead of conn_ctx to follow the camelCase convention used elsewhere (e.g., timeoutCtx on line 65).
🔍 Description
Depends on:
Changes: