Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
59 changes: 59 additions & 0 deletions cmd/example-tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ROOT_DIR := $(realpath ../..)
BUILD_DIR := $(ROOT_DIR)/build
BINARY_NAME := example-tests

GO_MODULE := github.com/openshift/router
GO_PKG_NAME := $(GO_MODULE)/cmd/example-tests

GIT_COMMIT := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)

LDFLAGS := -X '$(GO_PKG_NAME)/pkg/version.CommitFromGit=$(GIT_COMMIT)' \
-X '$(GO_PKG_NAME)/pkg/version.BuildDate=$(BUILD_DATE)' \
-X '$(GO_PKG_NAME)/pkg/version.GitTreeState=$(GIT_TREE_STATE)'

#.PHONY: verify test lint clean unit integration example-tests framework-tests
.PHONY: verify test lint clean unit integration example-tests
all: unit build integration

verify: lint

#build: example-tests framework-tests
build: $(BUILD_DIR)/$(BINARY_NAME)
#build:
# cd $(ROOT_DIR) && go build -mod=vendor -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/example-tests

#example-tests:
# # GO_COMPLIANCE_POLICY="exempt_all" must only be used for test related binaries.
# # It prevents various FIPS compliance policies from being applied to this compilation.
# # Do not set globally.
# GO_COMPLIANCE_POLICY="exempt_all" go build -ldflags "$(LDFLAGS)" ./cmd/example-tests/...
$(BUILD_DIR)/$(BINARY_NAME):
@echo "Building statically linked example-tests binary..."
@mkdir -p $(BUILD_DIR)
GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="$(LDFLAGS) -s -w" \
-o $(BUILD_DIR)/$(BINARY_NAME) "./main.go"

#framework-tests:
# # GO_COMPLIANCE_POLICY="exempt_all" must only be used for test related binaries.
# # It prevents various FIPS compliance policies from being applied to this compilation.
# # Do not set globally.
# GO_COMPLIANCE_POLICY="exempt_all" go build -ldflags "$(LDFLAGS)" ./cmd/framework-tests/...

test: unit
#test: unit integration

unit:
go test ./...

#integration: build
# ./framework-tests run-suite framework

lint:
./hack/go-lint.sh run ./...

clean:
rm -f $(BUILD_DIR)
# rm -f example-tests framework-tests
78 changes: 78 additions & 0 deletions cmd/example-tests/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package main

import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
"github.com/openshift-eng/openshift-tests-extension/pkg/extension"
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"
_ "github.com/openshift/router/test/example"

exutil "github.com/openshift/router/test/util"
e2e "k8s.io/kubernetes/test/e2e/framework"
)

func main() {
registry := extension.NewRegistry()
ext := extension.NewExtension("openshift", "payload", "openshit-router")

ext.AddSuite(extension.Suite{
Name: "openshit-router",
Qualifiers: []string{
`name.contains("[router-testing]")`,
},
})

ext.AddSuite(extension.Suite{
Name: "openshit-router-level0",
Parents: []string{
"openshift/openshit-router",
},
Qualifiers: []string{
`name.contains("LEVEL0")`,
},
})

ext.AddSuite(extension.Suite{
Name: "openshit-router-connectedOnly",
Parents: []string{
"openshift/openshit-router",
},
Qualifiers: []string{
`name.contains("ConnectedOnly")`,
},
})

specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
if err != nil {
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
}

ext.AddSpecs(specs)
registry.Register(ext)

root := &cobra.Command{
Long: "OpenShift Tests Extension for Cluster Version Operator",
}

//exutil.InitStandardFlags()
specs.AddBeforeAll(func() {
if err := exutil.InitTest(false); err != nil {
panic(err)
}
e2e.AfterReadingAllFlags(exutil.TestContext)
// e2e.TestContext.DumpLogsOnFailure = true
// exutil.TestContext.DumpLogsOnFailure = true
})

root.AddCommand(cmd.DefaultExtensionCommands(registry)...)

if err := func() error {
return root.Execute()
}(); err != nil {
os.Exit(1)
}
}
Loading