Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csi-sanity binary #234

Merged
merged 1 commit into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/csi-sanity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ PACKAGE :=$(DIR)/dist/$(APP_NAME)-$(RELEASEVER).$(GOOS).$(ARCH).tar.gz

all: $(APP_NAME)

$(APP_NAME): Makefile sanity_test.go
go test $(LDFLAGS) -c -o $(APP_NAME)
.PHONY: $(APP_NAME)
$(APP_NAME): Makefile
go build $(LDFLAGS) -o $(APP_NAME)

install: $(APP_NAME)
cp $(APP_NAME) $(GOPATH)/bin
Expand Down
24 changes: 16 additions & 8 deletions cmd/csi-sanity/sanity_test.go → cmd/csi-sanity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ 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 sanity
package main

import (
"flag"
"fmt"
"os"
"testing"
"time"

"github.com/kubernetes-csi/csi-test/v3/pkg/sanity"
Expand All @@ -31,7 +30,6 @@ const (

var (
VERSION = "(dev)"
config = sanity.NewTestConfig()
)

func stringVar(p *string, name string, usage string) {
Expand All @@ -54,9 +52,20 @@ func durationVar(p *time.Duration, name string, usage string) {
flag.DurationVar(p, prefix+name, *p, usage)
}

func TestMain(m *testing.M) {
type testing struct {
result int
}

func (t *testing) Fail() {
t.result = 1
}

func main() {
version := flag.Bool("version", false, "print version of this program")

// Get configuration with defaults.
config := sanity.NewTestConfig()

// Support overriding the default configuration via flags.
stringVar(&config.Address, "endpoint", "CSI endpoint")
stringVar(&config.ControllerAddress, "controllerendpoint", "CSI controller endpoint")
Expand Down Expand Up @@ -85,9 +94,8 @@ func TestMain(m *testing.M) {
fmt.Printf("--%sendpoint must be provided with an CSI endpoint\n", prefix)
os.Exit(1)
}
os.Exit(m.Run())
}

func TestSanity(t *testing.T) {
sanity.Test(t, config)
t := testing{}
sanity.Test(&t, config)
os.Exit(t.result)
}
3 changes: 1 addition & 2 deletions pkg/sanity/sanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"os"
"os/exec"
"strings"
"testing"
"time"

"github.com/kubernetes-csi/csi-test/v3/utils"
Expand Down Expand Up @@ -189,7 +188,7 @@ func newTestContext(config *TestConfig) *TestContext {

// Test will test the CSI driver at the specified address by
// setting up a Ginkgo suite and running it.
func Test(t *testing.T, config TestConfig) {
func Test(t GinkgoTestingT, config TestConfig) {
sc := GinkgoTest(&config)
RegisterFailHandler(Fail)

Expand Down