wip: add bsu plugin acc testing

This commit is contained in:
Marin Salinas 2019-02-11 16:43:16 -06:00 committed by Megan Marsh
parent 4779b028f1
commit c4e69d3169
3 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,55 @@
/*
Deregister the test image with
aws oapi deregister-image --image-id $(aws oapi describe-images --output text --filters "Name=name,Values=packer-test-packer-test-dereg" --query 'Images[*].{ID:ImageId}')
*/
package bsu
import (
"crypto/tls"
"net/http"
"testing"
"github.com/hashicorp/packer/builder/osc/common"
builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/outscale/osc-go/oapi"
)
func TestBuilderAcc_basic(t *testing.T) {
builderT.Test(t, builderT.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Builder: &Builder{},
Template: testBuilderAccBasic,
})
}
func testAccPreCheck(t *testing.T) {
}
func testOAPIConn() (*oapi.Client, error) {
access := &common.AccessConfig{RawRegion: "us-east-1"}
clientConfig, err := access.Config()
if err != nil {
return nil, err
}
skipClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
return oapi.NewClient(clientConfig, skipClient), nil
}
const testBuilderAccBasic = `
{
"builders": [{
"type": "test",
"region": "eu-west-2",
"vm_type": "m3.medium",
"source_omi": "omi-76b2a71e",
"ssh_username": "ubuntu",
"omi_name": "packer-test {{timestamp}}"
}]
}
`

View File

@ -63,7 +63,7 @@ func (s *StepSourceOMIInfo) Run(_ context.Context, state multistep.StateBag) mul
params.Filters.AccountIds = s.OmiFilters.Owners
}
log.Printf("Using OMI Filters %v", params)
log.Printf("Using OMI Filters %#v", params)
imageResp, err := oapiconn.POST_ReadImages(params)
if err != nil {
err := fmt.Errorf("Error querying OMI: %s", err)
@ -73,7 +73,7 @@ func (s *StepSourceOMIInfo) Run(_ context.Context, state multistep.StateBag) mul
}
if len(imageResp.OK.Images) == 0 {
err := fmt.Errorf("No OMI was found matching filters: %v", params)
err := fmt.Errorf("No OMI was found matching filters: %#v", params)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt

View File

@ -38,6 +38,7 @@ import (
openstackbuilder "github.com/hashicorp/packer/builder/openstack"
oracleclassicbuilder "github.com/hashicorp/packer/builder/oracle/classic"
oracleocibuilder "github.com/hashicorp/packer/builder/oracle/oci"
oscbsubuilder "github.com/hashicorp/packer/builder/osc/bsu"
oscbsusurrogatebuilder "github.com/hashicorp/packer/builder/osc/bsusurrogate"
parallelsisobuilder "github.com/hashicorp/packer/builder/parallels/iso"
parallelspvmbuilder "github.com/hashicorp/packer/builder/parallels/pvm"
@ -122,6 +123,7 @@ var Builders = map[string]packer.Builder{
"openstack": new(openstackbuilder.Builder),
"oracle-classic": new(oracleclassicbuilder.Builder),
"oracle-oci": new(oracleocibuilder.Builder),
"osc-bsu": new(oscbsubuilder.Builder),
"osc-bsusurrogate": new(oscbsusurrogatebuilder.Builder),
"parallels-iso": new(parallelsisobuilder.Builder),
"parallels-pvm": new(parallelspvmbuilder.Builder),