aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/go/cmd/prod.go3
-rw-r--r--client/go/cmd/prod_test.go25
-rw-r--r--client/go/vespa/application.go2
-rw-r--r--client/go/vespa/deploy.go14
4 files changed, 32 insertions, 12 deletions
diff --git a/client/go/cmd/prod.go b/client/go/cmd/prod.go
index 46b7a673215..6b5470aaa6c 100644
--- a/client/go/cmd/prod.go
+++ b/client/go/cmd/prod.go
@@ -363,6 +363,9 @@ func prompt(cli *CLI, stdin *bufio.Reader, question, defaultAnswer string, valid
}
func verifyTests(cli *CLI, app vespa.ApplicationPackage) error {
+ if !app.HasTests() {
+ return nil
+ }
// TODO: system-test, staging-setup and staging-test should be required if the application
// does not have any Java tests.
suites := map[string]bool{
diff --git a/client/go/cmd/prod_test.go b/client/go/cmd/prod_test.go
index eff06cf860e..c9584511203 100644
--- a/client/go/cmd/prod_test.go
+++ b/client/go/cmd/prod_test.go
@@ -17,7 +17,7 @@ import (
func TestProdInit(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, false)
+ createApplication(t, pkgDir, false, false)
answers := []string{
// Regions
@@ -85,7 +85,7 @@ func readFileString(t *testing.T, filename string) string {
return string(content)
}
-func createApplication(t *testing.T, pkgDir string, java bool) {
+func createApplication(t *testing.T, pkgDir string, java bool, skipTests bool) {
appDir := filepath.Join(pkgDir, "src", "main", "application")
targetDir := filepath.Join(pkgDir, "target")
if err := os.MkdirAll(appDir, 0755); err != nil {
@@ -125,10 +125,13 @@ func createApplication(t *testing.T, pkgDir string, java bool) {
t.Fatal(err)
}
if java {
+ if skipTests {
+ t.Fatalf("skipTests=%t has no effect when java=%t", skipTests, java)
+ }
if err := os.WriteFile(filepath.Join(pkgDir, "pom.xml"), []byte(""), 0644); err != nil {
t.Fatal(err)
}
- } else {
+ } else if !skipTests {
testsDir := filepath.Join(pkgDir, "src", "test", "application", "tests")
testBytes, _ := io.ReadAll(strings.NewReader("{\"steps\":[{}]}"))
writeTest(filepath.Join(testsDir, "system-test", "test.json"), testBytes, t)
@@ -148,8 +151,18 @@ func writeTest(path string, content []byte, t *testing.T) {
func TestProdSubmit(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, false)
+ createApplication(t, pkgDir, false, false)
+ prodSubmit(pkgDir, t)
+}
+
+func TestProdSubmitWithoutTests(t *testing.T) {
+ pkgDir := filepath.Join(t.TempDir(), "app")
+ createApplication(t, pkgDir, false, true)
+ prodSubmit(pkgDir, t)
+}
+func prodSubmit(pkgDir string, t *testing.T) {
+ t.Helper()
httpClient := &mock.HTTPClient{}
httpClient.NextResponseString(200, `ok`)
@@ -192,7 +205,7 @@ func TestProdSubmit(t *testing.T) {
func TestProdSubmitWithJava(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, true)
+ createApplication(t, pkgDir, true, false)
httpClient := &mock.HTTPClient{}
httpClient.NextResponseString(200, `ok`)
@@ -219,7 +232,7 @@ func TestProdSubmitWithJava(t *testing.T) {
func TestProdSubmitInvalidZip(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, true)
+ createApplication(t, pkgDir, true, false)
httpClient := &mock.HTTPClient{}
httpClient.NextResponseString(200, `ok`)
diff --git a/client/go/vespa/application.go b/client/go/vespa/application.go
index 2f19c00b3f2..d382b0998bf 100644
--- a/client/go/vespa/application.go
+++ b/client/go/vespa/application.go
@@ -184,6 +184,8 @@ func (ap *ApplicationPackage) Unzip(test bool) (string, error) {
return tmp, nil
}
+func (ap *ApplicationPackage) HasTests() bool { return ap.TestPath != "" }
+
func validPath(path string) bool {
path = strings.TrimSuffix(path, "/")
if filepath.Clean(path) != path {
diff --git a/client/go/vespa/deploy.go b/client/go/vespa/deploy.go
index b98679aadd8..c257ff4cd7d 100644
--- a/client/go/vespa/deploy.go
+++ b/client/go/vespa/deploy.go
@@ -243,12 +243,14 @@ func Submit(opts DeploymentOptions) error {
if err := copyToPart(writer, applicationZip, "applicationZip", "application.zip"); err != nil {
return err
}
- testApplicationZip, err := opts.ApplicationPackage.zipReader(true)
- if err != nil {
- return err
- }
- if err := copyToPart(writer, testApplicationZip, "applicationTestZip", "application-test.zip"); err != nil {
- return err
+ if opts.ApplicationPackage.HasTests() {
+ testApplicationZip, err := opts.ApplicationPackage.zipReader(true)
+ if err != nil {
+ return err
+ }
+ if err := copyToPart(writer, testApplicationZip, "applicationTestZip", "application-test.zip"); err != nil {
+ return err
+ }
}
if err := writer.Close(); err != nil {
return err