Ejemplo n.º 1
0
func addToLambda(dir string) error {
	desc, err := util.ReadTestDescription(dir)
	if err != nil {
		return err
	}

	var zipContents []byte
	if desc.Runtime == "java8" {
		zipContents, err = ioutil.ReadFile(filepath.Join(dir, "test-build.jar"))
		if err != nil {
			return err
		}
	} else {
		zipContents, err = makeZip(dir)
		if err != nil {
			return err
		}
	}

	s := session.New(&aws.Config{Region: aws.String("us-east-1"), Credentials: credentials.NewEnvCredentials()})

	l := lambda.New(s)

	err = createLambdaFunction(l, zipContents, desc.Runtime, lambdaRole, desc.Name, desc.Handler, desc.Timeout)
	return err
}
Ejemplo n.º 2
0
func makeLocalDocker(dir string) error {
	desc, err := util.ReadTestDescription(dir)
	if err != nil {
		return err
	}
	imageNameVersion := fmt.Sprintf("%s/%s:%s", imagePrefix, desc.Name, "latest")
	if err != nil {
		return err
	}

	err = util.MakeImage(dir, desc, imageNameVersion)
	if err != nil {
		return err
	}

	return nil
}
Ejemplo n.º 3
0
func loadTests(filter string) ([]*util.TestDescription, error) {
	testsRoot := "./tests"
	// assume test location <testsRoot>/<lang>/<test>/lambda.test
	descs := []*util.TestDescription{}

	langFolders, err := getSubDirs(testsRoot)
	if err != nil {
		return descs, err
	}

	allFolders := make([]string, 0)
	for _, folder := range langFolders {
		testFolders, err := getSubDirs(folder)
		if err != nil {
			return descs, err
		}
		allFolders = append(allFolders, testFolders...)
	}

	testLocations := make(map[string]string)
	for _, folder := range allFolders {

		d, err := util.ReadTestDescription(folder)
		if err != nil {
			return descs, fmt.Errorf("Could not load test: %s error: %s", folder, err)
		}
		key := d.Name
		if otherFolder, ok := testLocations[key]; ok {
			return descs, fmt.Errorf("Duplicate test name detected. Runtime: %s, Name: %s, Location1: %s, Location2: %s ", d.Runtime, d.Name, otherFolder, folder)
		}

		testLocations[key] = folder

		if filter == "" || strings.Contains(folder, filter) {
			descs = append(descs, d)
		}

	}
	return descs, nil
}
Ejemplo n.º 4
0
func addToIron(dir string) error {
	desc, err := util.ReadTestDescription(dir)
	if err != nil {
		return err
	}

	version := uuid.NewV4().String()
	imageNameVersion := fmt.Sprintf("%s/%s:%s", imagePrefix, desc.Name, version)

	err = util.MakeImage(dir, desc, imageNameVersion)
	if err != nil {
		return err
	}

	opts := iron_lambda.PushImageOptions{imageNameVersion, NewDockerJsonWriter(os.Stdout), true}
	err = iron_lambda.PushImage(opts)
	if err != nil {
		return err
	}

	return iron_lambda.RegisterWithIron(imageNameVersion)
}