Skip to content

Commit

Permalink
login: Change LoginToCentOS to LoginToCentOSAsRoot
Browse files Browse the repository at this point in the history
Since we only log in as `root` - simply `LoginToCentOS`
and rename it to match its abilities.

Signed-off-by: Orel Misan <omisan@redhat.com>
  • Loading branch information
orelmisan committed Jan 28, 2024
1 parent 85a5b09 commit 6b627dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions pkg/internal/checkup/executor/console/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"google.golang.org/grpc/codes"
)

func (e Expecter) LoginToCentOS(username, password string) error {
func (e Expecter) LoginToCentOSAsRoot(password string) error {
const (
connectionTimeout = 10 * time.Second
promptTimeout = 5 * time.Second
Expand All @@ -47,9 +47,7 @@ func (e Expecter) LoginToCentOS(username, password string) error {
}

// Do not login, if we already logged in
loggedInPromptRegex := fmt.Sprintf(
`(\[%s@(localhost|centos|%s) ~\]\$ |\[root@(localhost|centos|%s) ~\]\# )`, username, e.vmiName, e.vmiName,
)
loggedInPromptRegex := fmt.Sprintf(`(\[root@(localhost|centos|%s) ~\]\# )`, e.vmiName)
b := []expect.Batcher{
&expect.BSnd{S: "\n"},
&expect.BExp{R: loggedInPromptRegex},
Expand All @@ -67,7 +65,7 @@ func (e Expecter) LoginToCentOS(username, password string) error {
// Using only "login: " would match things like "Last failed login: Tue Jun 9 22:25:30 UTC 2020 on ttyS0"
// and in case the VM's did not get hostname form DHCP server try the default hostname
R: regexp.MustCompile(fmt.Sprintf(`(localhost|centos|%s) login: `, e.vmiName)),
S: fmt.Sprintf("%s\n", username),
S: "root\n",
T: expect.Next(),
Rt: 10,
},
Expand Down
6 changes: 2 additions & 4 deletions pkg/internal/checkup/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type vmiSerialConsoleClient interface {
type Executor struct {
vmiSerialClient vmiSerialConsoleClient
namespace string
vmiUsername string
vmiPassword string
vmiUnderTestEastNICPCIAddress string
trafficGenEastMACAddress string
Expand All @@ -58,7 +57,6 @@ func New(client vmiSerialConsoleClient, namespace string, cfg config.Config) Exe
return Executor{
vmiSerialClient: client,
namespace: namespace,
vmiUsername: config.VMIUsername,
vmiPassword: config.VMIPassword,
vmiUnderTestEastNICPCIAddress: config.VMIEastNICPCIAddress,
trafficGenEastMACAddress: cfg.TrafficGenEastMacAddress.String(),
Expand All @@ -73,13 +71,13 @@ func New(client vmiSerialConsoleClient, namespace string, cfg config.Config) Exe
func (e Executor) Execute(ctx context.Context, vmiUnderTestName, trafficGenVMIName string) (status.Results, error) {
log.Printf("Login to VMI under test...")
vmiUnderTestConsoleExpecter := console.NewExpecter(e.vmiSerialClient, e.namespace, vmiUnderTestName)
if err := vmiUnderTestConsoleExpecter.LoginToCentOS(e.vmiUsername, e.vmiPassword); err != nil {
if err := vmiUnderTestConsoleExpecter.LoginToCentOSAsRoot(e.vmiPassword); err != nil {
return status.Results{}, fmt.Errorf("failed to login to VMI \"%s/%s\": %w", e.namespace, vmiUnderTestName, err)
}

log.Printf("Login to traffic generator...")
trafficGenConsoleExpecter := console.NewExpecter(e.vmiSerialClient, e.namespace, trafficGenVMIName)
if err := trafficGenConsoleExpecter.LoginToCentOS(e.vmiUsername, e.vmiPassword); err != nil {
if err := trafficGenConsoleExpecter.LoginToCentOSAsRoot(e.vmiPassword); err != nil {
return status.Results{}, fmt.Errorf("failed to login to VMI \"%s/%s\": %w", e.namespace, trafficGenVMIName, err)
}

Expand Down
1 change: 0 additions & 1 deletion pkg/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const (
)

const (
VMIUsername = "root"
VMIPassword = "redhat" // #nosec

VMIEastNICPCIAddress = "0000:06:00.0"
Expand Down

0 comments on commit 6b627dc

Please sign in to comment.