Skip to content

Commit

Permalink
FAB-7635 optimize unit-test execution
Browse files Browse the repository at this point in the history
Optimize te execution of unit tests to a) exclude some
long running tests with -short flag and remove coverprofile
from mainline path. Add new make target 'profile' for that.

Note that bccsp/factory package needs to be mocked before
adding it back. Must be tested separtely.

Change-Id: Icf9990f300eef39052bed7fd43807b9e6f7107a9
Signed-off-by: Christopher Ferris <chrisfer@us.ibm.com>
  • Loading branch information
christo4ferris committed Jan 7, 2018
1 parent 872dcb5 commit 6a4b44f
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 72 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# - release-all - builds release packages for all target platforms
# - unit-test - runs the go-test based unit tests
# - verify - runs unit tests for only the changed package tree
# - profile - runs unit tests for all packages in coverprofile mode (slow)
# - test-cmd - generates a "go test" string suitable for manual customization
# - behave - runs the behave test
# - behave-deps - ensures pre-requisites are available for running behave manually
Expand Down Expand Up @@ -180,6 +181,9 @@ unit-tests: unit-test
verify: unit-test-clean peer-docker testenv
cd unit-test && JOB_TYPE=VERIFY docker-compose up --abort-on-container-exit --force-recreate && docker-compose down

profile: unit-test-clean peer-docker testenv
cd unit-test && JOB_TYPE=PROFILE docker-compose up --abort-on-container-exit --force-recreate && docker-compose down

# Generates a string to the terminal suitable for manual augmentation / re-issue, useful for running tests by hand
test-cmd:
@echo "go test -tags \"$(GO_TAGS)\" -ldflags \"$(GO_LDFLAGS)\""
Expand Down
12 changes: 12 additions & 0 deletions bccsp/pkcs11/ecdsakey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (
)

func TestECDSAPKIXPublicKeyImportOptsKeyImporter(t *testing.T) {
if testing.Short() {
t.Skip("Skipping TestECDSAPKIXPublicKeyImportOptsKeyImporter")
}
ki := currentBCCSP

_, err := ki.KeyImport("Hello World", &bccsp.ECDSAPKIXPublicKeyImportOpts{})
Expand Down Expand Up @@ -60,6 +63,9 @@ func TestECDSAPKIXPublicKeyImportOptsKeyImporter(t *testing.T) {
}

func TestECDSAPrivateKeyImportOptsKeyImporter(t *testing.T) {
if testing.Short() {
t.Skip("Skipping TestECDSAPrivateKeyImportOptsKeyImporter")
}
if currentBCCSP.(*impl).noPrivImport {
t.Skip("Key import turned off. Skipping Private Key Importer tests as they currently require Key Import.")
}
Expand Down Expand Up @@ -91,6 +97,9 @@ func TestECDSAPrivateKeyImportOptsKeyImporter(t *testing.T) {
}

func TestECDSAGoPublicKeyImportOptsKeyImporter(t *testing.T) {
if testing.Short() {
t.Skip("Skipping TestECDSAGoPublicKeyImportOptsKeyImporter")
}
ki := currentBCCSP

_, err := ki.KeyImport("Hello World", &bccsp.ECDSAGoPublicKeyImportOpts{})
Expand All @@ -103,6 +112,9 @@ func TestECDSAGoPublicKeyImportOptsKeyImporter(t *testing.T) {
}

func TestX509PublicKeyImportOptsKeyImporter(t *testing.T) {
if testing.Short() {
t.Skip("Skipping TestX509PublicKeyImportOptsKeyImporter")
}
ki := currentBCCSP

_, err := ki.KeyImport("Hello World", &bccsp.X509PublicKeyImportOpts{})
Expand Down
Loading

0 comments on commit 6a4b44f

Please sign in to comment.