You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2017/09/14 21:33:59 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Add sequence
validation tests (#483)
This is an automated email from the ASF dual-hosted git repository.
mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git
The following commit(s) were added to refs/heads/master by this push:
new 2a5fe55 Add sequence validation tests (#483)
2a5fe55 is described below
commit 2a5fe551e35f2e299a18f1b6ea07c74789ec96a9
Author: Ying Chun Guo <gu...@cn.ibm.com>
AuthorDate: Fri Sep 15 05:33:57 2017 +0800
Add sequence validation tests (#483)
* add sequence tests
* Update function.js
* Update validateSequencesCreation_test.go
* Update validateSequencesCreation_test.go
---
.../validateSequencesCreation/actions/function.js | 15 +++
.../validateSequencesCreation_test.go | 110 +++++++++++++++++++++
2 files changed, 125 insertions(+)
diff --git a/tests/src/integration/validateSequencesCreation/actions/function.js b/tests/src/integration/validateSequencesCreation/actions/function.js
new file mode 100644
index 0000000..7a61159
--- /dev/null
+++ b/tests/src/integration/validateSequencesCreation/actions/function.js
@@ -0,0 +1,15 @@
+/**
+ * Return a simple string to
+ * confirm this function has been visited.
+ *
+ * @param visited the visited function list
+ */
+function main(params) {
+ functionID = params.functionID || 'X'
+ if (params.visited == null) {
+ params.visited = 'function'+functionID;
+ } else {
+ params.visited = params.visited + ', function'+functionID;
+ }
+ return {"visited":params.visited};
+}
diff --git a/tests/src/integration/validateSequencesCreation/validateSequencesCreation_test.go b/tests/src/integration/validateSequencesCreation/validateSequencesCreation_test.go
new file mode 100644
index 0000000..0bc6679
--- /dev/null
+++ b/tests/src/integration/validateSequencesCreation/validateSequencesCreation_test.go
@@ -0,0 +1,110 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests
+
+import (
+ "github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "io/ioutil"
+ "strconv"
+ "fmt"
+ "strings"
+ "testing"
+)
+
+var wskprops = common.GetWskprops()
+
+func composeDeployFiles(count int) (manifestStr string, deploymentStr string) {
+ manifestStr = `package:
+ name: TestSequencesCreation
+ actions:
+`
+ deploymentStr = `application:
+ name: TestSequencesCreationApp
+ packages:
+ TestSequencesCreation:
+ actions:
+`
+ sequenceStr :=` sequences:
+ validate-sequence:
+ actions: `
+
+ for i := 1; i < count+1; i++ {
+ manifestStr = manifestStr + " func"+strconv.Itoa(i)+":"+
+`
+ function: actions/function.js
+ runtime: nodejs:6
+ inputs:
+ functionID: string
+ visited: string
+ outputs:
+ visited: string
+`
+ sequenceStr = sequenceStr + "func"+strconv.Itoa(i)+","
+ deploymentStr = deploymentStr + " func"+strconv.Itoa(i)+":"+
+`
+ inputs:
+ functionID: `+strconv.Itoa(i)+
+`
+ visited:
+`
+ }
+ manifestStr = manifestStr + strings.TrimRight(sequenceStr,",")
+ return
+}
+
+func _createTmpfile(data string, filename string) (f *os.File, err error) {
+ dir, _ := os.Getwd()
+ tmpfile, err := ioutil.TempFile(dir, filename)
+ if err != nil {
+ return nil, err
+ }
+ _, err = tmpfile.Write([]byte(data))
+ if err != nil {
+ return tmpfile, err
+ }
+ return tmpfile, nil
+}
+
+func TestValidateSequenceCreation(t *testing.T) {
+ count := 10
+ wskdeploy := common.NewWskdeploy()
+ for i := 1; i < count+1; i++ {
+ maniData,deplyData := composeDeployFiles(i+1)
+ tmpManifile, err := _createTmpfile(maniData, "sequence_test_mani_")
+ tmpDeplyfile, err := _createTmpfile(deplyData, "sequence_test_deply_")
+ if err != nil {
+ assert.Fail(t, "Failed to create temp file")
+ }
+
+ fmt.Printf("Deploying sequence %d\n:",i)
+ _, err = wskdeploy.Deploy(tmpManifile.Name(), tmpDeplyfile.Name())
+ assert.Equal(t, nil, err, "Failed to deploy sequence.")
+ _, err = wskdeploy.Undeploy(tmpManifile.Name(), tmpDeplyfile.Name())
+ assert.Equal(t, nil, err, "Failed to undeploy sequence.")
+
+ tmpManifile.Close()
+ tmpDeplyfile.Close()
+ os.Remove(tmpManifile.Name())
+ os.Remove(tmpDeplyfile.Name())
+ }
+}
+
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].