Unverified Commit 3984ca15 authored by Yoav Tock's avatar Yoav Tock Committed by Artem Barger
Browse files

FAB-12983 capability V2_0 for Kafka2RaftMigration



Add orderer capability V2_0 for Kafka2RaftMigration

This capability defines whether the orderer supports a kafka to
raft migration. A kafka-based Ordering Service Node requires
this in order to receive and process a config update with
consensus-type migration commands. Migration is supported from
Kafka to Raft only. If not present, these config updates will
be rejected.

Change-Id: I3b56dec21f0893d0b1df5db30973b4762aab5575
Signed-off-by: default avatarYoav Tock <tock@il.ibm.com>
parent 0da0ecee
......@@ -13,14 +13,23 @@ import (
const (
ordererTypeName = "Orderer"
// OrdererV1_1 is the capabilties string for standard new non-backwards compatible fabric v1.1 orderer capabilities.
// OrdererV1_1 is the capabilities string for standard new non-backwards compatible Fabric v1.1 orderer capabilities.
OrdererV1_1 = "V1_1"
// OrdererV2_0 is the capabilities string that defines new Fabric v2.0 orderer capabilities.
//
// In particular, it defines whether the orderer supports a Kafka to Raft migration.
// A Kafka-based Ordering Service Node requires this in order to receive and process a config update with
// consensus-type migration commands. Migration is supported from Kafka to Raft only.
// If not present, these config updates will be rejected.
OrdererV2_0 = "V2_0"
)
// OrdererProvider provides capabilities information for orderer level config.
type OrdererProvider struct {
*registry
v11BugFixes bool
v11BugFixes bool
kafka2RaftMig bool
}
// NewOrdererProvider creates an orderer capabilities provider.
......@@ -28,6 +37,7 @@ func NewOrdererProvider(capabilities map[string]*cb.Capability) *OrdererProvider
cp := &OrdererProvider{}
cp.registry = newRegistry(cp, capabilities)
_, cp.v11BugFixes = capabilities[OrdererV1_1]
_, cp.kafka2RaftMig = capabilities[OrdererV2_0]
return cp
}
......@@ -42,6 +52,8 @@ func (cp *OrdererProvider) HasCapability(capability string) bool {
// Add new capability names here
case OrdererV1_1:
return true
case OrdererV2_0:
return true
default:
return false
}
......@@ -64,3 +76,8 @@ func (cp *OrdererProvider) Resubmission() bool {
func (cp *OrdererProvider) ExpirationCheck() bool {
return cp.v11BugFixes
}
// Kafka2RaftMigration checks whether the orderer permits a Kafka to Raft migration.
func (cp *OrdererProvider) Kafka2RaftMigration() bool {
return cp.kafka2RaftMig
}
......@@ -16,9 +16,11 @@ import (
func TestOrdererV10(t *testing.T) {
op := NewOrdererProvider(map[string]*cb.Capability{})
assert.NoError(t, op.Supported())
assert.Equal(t, ordererTypeName, op.Type())
assert.False(t, op.PredictableChannelTemplate())
assert.False(t, op.Resubmission())
assert.False(t, op.ExpirationCheck())
assert.False(t, op.Kafka2RaftMigration())
}
func TestOrdererV11(t *testing.T) {
......@@ -29,4 +31,23 @@ func TestOrdererV11(t *testing.T) {
assert.True(t, op.PredictableChannelTemplate())
assert.True(t, op.Resubmission())
assert.True(t, op.ExpirationCheck())
assert.False(t, op.Kafka2RaftMigration())
}
func TestOrdererV20(t *testing.T) {
op := NewOrdererProvider(map[string]*cb.Capability{
OrdererV1_1: {}, OrdererV2_0: {},
})
assert.NoError(t, op.Supported())
assert.True(t, op.PredictableChannelTemplate())
assert.True(t, op.Resubmission())
assert.True(t, op.ExpirationCheck())
assert.True(t, op.Kafka2RaftMigration())
}
func TestNotSuported(t *testing.T) {
op := NewOrdererProvider(map[string]*cb.Capability{
OrdererV1_1: {}, OrdererV2_0: {}, "Bogus_Not_suported": {},
})
assert.EqualError(t, op.Supported(), "Orderer capability Bogus_Not_suported is required but not supported")
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment