fix language:default runtime setting (#1039)
diff --git a/parsers/manifest_parser_test.go b/parsers/manifest_parser_test.go
index e97207a..e7358f8 100644
--- a/parsers/manifest_parser_test.go
+++ b/parsers/manifest_parser_test.go
@@ -498,7 +498,7 @@
}
}
-// Test 9: validate manifest_parser.ComposeActions() method for implicit runtimes
+// Test 9(1): validate manifest_parser.ComposeActions() method for implicit runtimes
// when a runtime of an action is not provided, manifest_parser determines the runtime
// based on the file extension of an action file
func TestComposeActionsForImplicitRuntimes(t *testing.T) {
@@ -522,6 +522,30 @@
}
}
+// Test 9(2): validate manifest_parser.ComposeActions() method for default runtimes
+// when a runtime of an action is set to default, manifest_parser determines
+// the runtime based on the default runtimes
+func TestComposeActionsForDefaultRuntimes(t *testing.T) {
+ file := "../tests/dat/manifest_data_compose_runtimes_default.yaml"
+ p, m, _ := testLoadParseManifest(t, file)
+ actions, err := p.ComposeActionsFromAllPackages(m, m.Filepath, whisk.KeyValue{}, map[string]PackageInputs{})
+ assert.Nil(t, err, fmt.Sprintf(TEST_ERROR_COMPOSE_ACTION_FAILURE, file))
+ var expectedResult string
+ for i := 0; i < len(actions); i++ {
+ if actions[i].Action.Name == "helloNodejs" {
+ expectedResult = "nodejs:default"
+ } else if actions[i].Action.Name == "helloJava" {
+ expectedResult = "java:default"
+ } else if actions[i].Action.Name == "helloPython" {
+ expectedResult = "python:default"
+ } else if actions[i].Action.Name == "helloSwift" {
+ expectedResult = "swift:default"
+ }
+ actualResult := actions[i].Action.Exec.Kind
+ assert.Equal(t, expectedResult, actualResult, TEST_MSG_ACTION_FUNCTION_RUNTIME_MISMATCH)
+ }
+}
+
// Test 10(1): validate manifest_parser.ComposeActions() method for invalid runtimes
// when the action has a source file written in unsupported runtimes, manifest_parser should
// report an error for that action
diff --git a/runtimes/runtimes.go b/runtimes/runtimes.go
index d91546e..24236ee 100644
--- a/runtimes/runtimes.go
+++ b/runtimes/runtimes.go
@@ -167,6 +167,9 @@
if !v[i].Deprecated {
rt[k] = append(rt[k], v[i].Kind)
}
+ if v[i].Default {
+ rt[k] = append(rt[k], strings.Split(v[i].Kind, ":")[0]+":default")
+ }
}
}
return
diff --git a/runtimes/runtimes_test.go b/runtimes/runtimes_test.go
index 84d6665..cdca181 100644
--- a/runtimes/runtimes_test.go
+++ b/runtimes/runtimes_test.go
@@ -32,11 +32,12 @@
println(converted["nodejs"])
println(converted["python"])
println(converted["go"])
- assert.Equal(t, 3, len(converted["nodejs"]), "not expected length")
- assert.Equal(t, 3, len(converted["php"]), "not expected length")
- assert.Equal(t, 1, len(converted["java"]), "not expected length")
- assert.Equal(t, 6, len(converted["python"]), "not expected length")
- assert.Equal(t, 1, len(converted["ruby"]), "not expected length")
- assert.Equal(t, 3, len(converted["swift"]), "not expected length")
- assert.Equal(t, 1, len(converted["go"]), "not expected length")
+ //one larger than in api response because of explicit :default
+ assert.Equal(t, 4, len(converted["nodejs"]), "not expected length")
+ assert.Equal(t, 4, len(converted["php"]), "not expected length")
+ assert.Equal(t, 2, len(converted["java"]), "not expected length")
+ assert.Equal(t, 7, len(converted["python"]), "not expected length")
+ assert.Equal(t, 2, len(converted["ruby"]), "not expected length")
+ assert.Equal(t, 4, len(converted["swift"]), "not expected length")
+ assert.Equal(t, 2, len(converted["go"]), "not expected length")
}
diff --git a/tests/dat/manifest_data_compose_runtimes_default.yaml b/tests/dat/manifest_data_compose_runtimes_default.yaml
new file mode 100644
index 0000000..5c642a4
--- /dev/null
+++ b/tests/dat/manifest_data_compose_runtimes_default.yaml
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements; and to You under the Apache License, Version 2.0.
+
+packages:
+ helloworld:
+ actions:
+ helloNodejs:
+ location: ../src/integration/helloworld/actions/hello.zip
+ runtime: nodejs:default
+ helloJava:
+ location: ../src/integration/helloworld/actions/hello.zip
+ runtime: java:default
+ helloPython:
+ location: ../src/integration/helloworld/actions/hello.zip
+ runtime: python:default
+ helloSwift:
+ location: ../src/integration/helloworld/actions/hello.zip
+ runtime: swift:default
diff --git a/tests/src/integration/helloworld/actions/hello.zip b/tests/src/integration/helloworld/actions/hello.zip
new file mode 100644
index 0000000..c5553e7
--- /dev/null
+++ b/tests/src/integration/helloworld/actions/hello.zip
Binary files differ