Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Include old PR's tests in submit_builder_test
Browse files Browse the repository at this point in the history
Delete cli_test.go and port over this PR's tests so that we are in
a good state.
  • Loading branch information
samvantran committed Jun 27, 2018
1 parent 66b2cbc commit e4c0a42
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 78 deletions.
76 changes: 0 additions & 76 deletions cli/dcos-spark/cli_test.go

This file was deleted.

36 changes: 34 additions & 2 deletions cli/dcos-spark/submit_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/mesosphere/dcos-commons/cli/config"
"github.com/stretchr/testify/suite"
"os"
"strings"
"testing"
)

Expand Down Expand Up @@ -74,6 +75,39 @@ func (suite *CliTestSuite) TestScoptAppArgs() {
}
}

func (suite *CliTestSuite) testLongArgInternal(inputArgs string, expectedArgs []string) {
_, args := sparkSubmitArgSetup() // setup
submitargs, _ := cleanUpSubmitArgs(inputArgs, args.boolVals)
if len(submitargs) != 2 { // should have 1 arg that's all the java options and one that's the spark cores config
suite.T().Errorf("Failed to parse %s, should have 2 args, got %d", inputArgs, len(submitargs))
}
java_options_arg := submitargs[0]
for i, a := range expectedArgs {
if !strings.Contains(java_options_arg, a) {
suite.T().Errorf("Expected to find %s at index %d", a, i)
}
}
}

// test long args
func (suite *CliTestSuite) TestStringLongArgs() {
java_options := []string{"-Djava.firstConfig=firstSetting", "-Djava.secondConfig=secondSetting"}
inputArgs := "--driver-java-options '-Djava.firstConfig=firstSetting -Djava.secondConfig=secondSetting' --conf spark.cores.max=8"
suite.testLongArgInternal(inputArgs, java_options)
inputArgs = "--driver-java-options='-Djava.firstConfig=firstSetting -Djava.secondConfig=secondSetting' --conf spark.cores.max=8"
suite.testLongArgInternal(inputArgs, java_options)
inputArgs = "--conf spark.driver.extraJavaOptions='-Djava.firstConfig=firstSetting -Djava.secondConfig=secondSetting' --conf spark.cores.max=8"
suite.testLongArgInternal(inputArgs, java_options)
inputArgs = "--executor-java-options '-Djava.firstConfig=firstSetting -Djava.secondConfig=secondSetting' --conf spark.cores.max=8"
suite.testLongArgInternal(inputArgs, java_options)
inputArgs = "--conf spark.executor.extraJavaOptions='-Djava.firstConfig=firstSetting -Djava.secondConfig=secondSetting' --conf spark.cores.max=8"
suite.testLongArgInternal(inputArgs, java_options)

java_options = append(java_options, "-Djava.thirdConfig=thirdSetting")
inputArgs = "--driver-java-option='-Djava.firstConfig=firstSetting -Djava.secondConfig=secondSetting -Djava.thirdConfig=thirdSetting' --conf spark.cores.max=8"
suite.testLongArgInternal(inputArgs, java_options)
}

func createCommand(inputArgs, dockerImage string) SparkCommand {
return SparkCommand{
"subId",
Expand All @@ -94,8 +128,6 @@ func createCommand(inputArgs, dockerImage string) SparkCommand {
}
}

No newline at end of file

func (suite *CliTestSuite) TestPayloadSimple() {
inputArgs := fmt.Sprintf(
"--driver-cores %s "+
Expand Down

0 comments on commit e4c0a42

Please sign in to comment.