-
Couldn't load subscription status.
- Fork 128
Check logs from elastic-agent in system tests #1256
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
f491083
Use profile in tests
mrodm 74d0851
Add method to check errors in logs
mrodm 7a565a6
Do no run check errors if there are no patterns
mrodm a392d52
Update README
mrodm 3434fa1
Add service name into reason
mrodm 889473c
Add stack parse logs
mrodm b1c8d3f
Add comments
mrodm 7e44426
Use regex
mrodm 9e6d45e
Comments from code review
mrodm 49069bd
Move helpers to internal/cobraext
mrodm 2c8e538
Add missing license header
mrodm 8d20ebf
Remove debug messages
mrodm a580527
Fix errors related to helpers
mrodm 64513fb
Make public the helpers
mrodm 65784c7
Use logs file path instead of service name
mrodm 039d672
Comment panic/runtime errors
mrodm 58fb1bd
Support check logs from several services
mrodm 4d48fd9
Use just errorPatterns to check services
mrodm 1ffcafa
Remove debug patterns
mrodm d5f338b
Add a new regex for elastic-agent
mrodm 4e8b885
Add includes and excludes regex
mrodm 5e91558
Rename function
mrodm acfe286
Add test for checkAgentLogs
mrodm e483b4f
Change struct to ensure same order for logs found
mrodm 1167bcd
Remove debug regexes
mrodm f2dca7a
Add test using excludes
mrodm 57b2764
Merge remote-tracking branch 'upstream/main' into check_logs_from_age…
mrodm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License; | ||
| // you may not use this file except in compliance with the Elastic License. | ||
|
|
||
| package cobraext | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "github.com/pkg/errors" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/elastic/elastic-package/internal/configuration/locations" | ||
| "github.com/elastic/elastic-package/internal/install" | ||
| "github.com/elastic/elastic-package/internal/profile" | ||
| "github.com/elastic/elastic-package/internal/stack" | ||
| ) | ||
|
|
||
| // GetProfileFlag returns the profile information | ||
| func GetProfileFlag(cmd *cobra.Command) (*profile.Profile, error) { | ||
| profileName, err := cmd.Flags().GetString(ProfileFlagName) | ||
| if err != nil { | ||
| return nil, FlagParsingError(err, ProfileFlagName) | ||
| } | ||
| if profileName == "" { | ||
| config, err := install.Configuration() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("cannot read configuration: %w", err) | ||
| } | ||
| profileName = config.CurrentProfile() | ||
| } | ||
|
|
||
| p, err := profile.LoadProfile(profileName) | ||
| if errors.Is(err, profile.ErrNotAProfile) { | ||
| list, err := availableProfilesAsAList() | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "error listing known profiles") | ||
| } | ||
| if len(list) == 0 { | ||
| return nil, fmt.Errorf("%s is not a valid profile", profileName) | ||
| } | ||
| return nil, fmt.Errorf("%s is not a valid profile, known profiles are: %s", profileName, strings.Join(list, ", ")) | ||
| } | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "error loading profile") | ||
| } | ||
|
|
||
| return p, nil | ||
| } | ||
|
|
||
| func availableProfilesAsAList() ([]string, error) { | ||
| loc, err := locations.NewLocationManager() | ||
| if err != nil { | ||
| return []string{}, errors.Wrap(err, "error fetching profile path") | ||
| } | ||
|
|
||
| profileNames := []string{} | ||
| profileList, err := profile.FetchAllProfiles(loc.ProfileDir()) | ||
| if err != nil { | ||
| return profileNames, errors.Wrap(err, "error fetching all profiles") | ||
| } | ||
| for _, prof := range profileList { | ||
| profileNames = append(profileNames, prof.Name) | ||
| } | ||
|
|
||
| return profileNames, nil | ||
| } | ||
|
|
||
| // GetStackProviderFromProfile returns the provider related to the given profile | ||
| func GetStackProviderFromProfile(cmd *cobra.Command, profile *profile.Profile, checkFlag bool) (stack.Provider, error) { | ||
| var providerName = stack.DefaultProvider | ||
| stackConfig, err := stack.LoadConfig(profile) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if stackConfig.Provider != "" { | ||
| providerName = stackConfig.Provider | ||
| } | ||
|
|
||
| if checkFlag { | ||
| providerFlag, err := cmd.Flags().GetString(StackProviderFlagName) | ||
| if err != nil { | ||
| return nil, FlagParsingError(err, StackProviderFlagName) | ||
| } | ||
| if providerFlag != "" { | ||
| providerName = providerFlag | ||
| } | ||
| } | ||
|
|
||
| return stack.BuildProvider(providerName, profile) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Added profile parameter into
elastic-package testcommand