Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Jenkins soak tests #2028

Merged
merged 24 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/e2e/azure/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,15 @@ func (a *Account) CreateGroup(name, location string) error {
return nil
}

// DeleteGroup delets a given resource group by name
func (a *Account) DeleteGroup(name string) error {
out, err := exec.Command("az", "group", "delete", "--name", name, "--no-wait", "--yes").CombinedOutput()
// DeleteGroup deletes a given resource group by name
func (a *Account) DeleteGroup(name string, wait bool) error {
var out []byte
var err error
if !wait {
out, err = exec.Command("az", "group", "delete", "--name", name, "--no-wait", "--yes").CombinedOutput()
} else {
out, err = exec.Command("az", "group", "delete", "--name", name, "--yes").CombinedOutput()
}
if err != nil {
log.Printf("Error while trying to delete resource group (%s):%s", name, out)
return err
Expand Down
1 change: 1 addition & 0 deletions test/e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Config struct {
CleanUpOnExit bool `envconfig:"CLEANUP_ON_EXIT" default:"true"` // if set the tests will not clean up rgs when tests finish
Timeout time.Duration `envconfig:"TIMEOUT" default:"10m"`
CurrentWorkingDir string
SoakClusterName string `envconfig:"SOAK_CLUSTER_NAME"`
}

const (
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func main() {

// Only provision a cluster if there isnt a name present
if cfg.Name == "" {
if cfg.SoakClusterName != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this belong to some cleanup step (maybe the teardown function at the bottom of this file)? The comments on this section of code says it is for provisioning a cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I put this here is that when generating a new soak cluster it is necessary to delete the previously existing soak cluster before deploying a new one since they use the same resource group (and we want to make sure we don't keep them after we're done testing on them).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the explanation.

rg := cfg.SoakClusterName
log.Printf("Deleting Group:%s\n", rg)
acct.DeleteGroup(rg, true)
}
cliProvisioner, err := runner.BuildCLIProvisioner(cfg, acct, pt)
if err != nil {
log.Fatalf("Error while trying to build CLI Provisioner:%s", err)
Expand Down Expand Up @@ -118,7 +123,7 @@ func teardown() {
if cfg.CleanUpOnExit {
for _, rg := range rgs {
log.Printf("Deleting Group:%s\n", rg)
acct.DeleteGroup(rg)
acct.DeleteGroup(rg, false)
}
}
}
15 changes: 10 additions & 5 deletions test/e2e/runner/cli_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (cli *CLIProvisioner) Run() error {
cli.Point.RecordProvisionError()
} else if i == cli.ProvisionRetries {
cli.Point.RecordProvisionError()
return fmt.Errorf("Exceeded provision retry count")
return fmt.Errorf("Exceeded provision retry count: %s", err)
}
} else {
cli.Point.RecordProvisionSuccess()
Expand All @@ -76,17 +76,22 @@ func (cli *CLIProvisioner) Run() error {

func (cli *CLIProvisioner) provision() error {
cli.Config.Name = cli.generateName()
if cli.Config.SoakClusterName != "" {
cli.Config.Name = cli.Config.SoakClusterName
}
os.Setenv("NAME", cli.Config.Name)
log.Printf("Cluster name:%s\n", cli.Config.Name)

outputPath := filepath.Join(cli.Config.CurrentWorkingDir, "_output")
os.Mkdir(outputPath, 0755)

out, err := exec.Command("ssh-keygen", "-f", cli.Config.GetSSHKeyPath(), "-q", "-N", "", "-b", "2048", "-t", "rsa").CombinedOutput()
if err != nil {
return fmt.Errorf("Error while trying to generate ssh key:%s\nOutput:%s", err, out)
if cli.Config.SoakClusterName == "" {
out, err := exec.Command("ssh-keygen", "-f", cli.Config.GetSSHKeyPath(), "-q", "-N", "", "-b", "2048", "-t", "rsa").CombinedOutput()
if err != nil {
return fmt.Errorf("Error while trying to generate ssh key:%s\nOutput:%s", err, out)
}
exec.Command("chmod", "0600", cli.Config.GetSSHKeyPath()+"*")
}
exec.Command("chmod", "0600", cli.Config.GetSSHKeyPath()+"*")

publicSSHKey, err := cli.Config.ReadPublicSSHKey()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the above keygen is skipped when soak cluster name is provided, should the publicSSHKey part be skipped too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keygen is skipped because for Jenkins soak test the tests use the Jenkins key so it is not necessary to generate a new key. However, the cli provisioner still needs to read the public key that was provided.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, so the public key is not the one generated by keygen, right?

Copy link
Contributor Author

@CecileRobertMichon CecileRobertMichon Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's the one in _output/cluster-name-ssh which is created before the test is started

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.

if err != nil {
Expand Down