Skip to content

Commit

Permalink
[FAB-10051] Pluggable endorsement and validation e2e
Browse files Browse the repository at this point in the history
This change set adds integration tests for pluggable endorsement
and validation.

This is actually the e2e but with a slight twist:
The endorsement and validation plugins that are used are actually
not the builtin, compiled ones - but .so plugins that are compiled
at the start of the test.

To ensure that the plugins are run and not the builtin version,
the plugin implementation writes to the file system a file
and the test checks that the file exists after the peers joined the channel.

Change-Id: I69027566f78560ffe9afc03aa9f3f1ac7bdbc6e5
Signed-off-by: yacovm <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed May 20, 2018
1 parent c6d0e6c commit 58ad85b
Showing 13 changed files with 1,713 additions and 0 deletions.
70 changes: 70 additions & 0 deletions integration/pluggable/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package e2e

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/hyperledger/fabric/integration/world"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestEndToEnd(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Pluggable endorsement and validation EndToEnd Suite")
}

var (
components *world.Components
testDir string
endorsementPluginFilePath string
validationPluginFilePath string
)

var _ = SynchronizedBeforeSuite(func() []byte {
components = &world.Components{}
components.Build()

payload, err := json.Marshal(components)
Expect(err).NotTo(HaveOccurred())

return payload
}, func(payload []byte) {
err := json.Unmarshal(payload, &components)
Expect(err).NotTo(HaveOccurred())

testDir, err = ioutil.TempDir("", "e2e-suite")
Expect(err).NotTo(HaveOccurred())

// Compile plugins
endorsementPluginFilePath = compilePlugin("endorsement")
validationPluginFilePath = compilePlugin("validation")

// Create directories for endorsement and validation activation
dir := filepath.Join(testDir, "endorsement")
err = os.Mkdir(dir, 0700)
Expect(err).NotTo(HaveOccurred())
SetEndorsementPluginActivationFolder(dir)

dir = filepath.Join(testDir, "validation")
err = os.Mkdir(dir, 0700)
Expect(err).NotTo(HaveOccurred())
SetValidationPluginActivationFolder(dir)
})

var _ = SynchronizedAfterSuite(func() {
os.RemoveAll(testDir)
os.Remove(endorsementPluginFilePath)
os.RemoveAll(validationPluginFilePath)
}, func() {
components.Cleanup()
})
Loading

0 comments on commit 58ad85b

Please sign in to comment.