Conversation
59dada3 to
80448d9
Compare
| @@ -0,0 +1,366 @@ | |||
| /* | |||
| Copyright IBM Corp. All Rights Reserved. | |||
| SPDX-License-Identifier: Apache-2.0 | |||
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| Copyright IBM Corp. All Rights Reserved. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package test |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
|
|
||
| const ( | ||
| // Number of shards in the test | ||
| numOfShards = 4 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
| // Number of parties in the test | ||
| numOfParties = 4 | ||
| // Placeholder for a value that doesn't matter in the test | ||
| doesntMatter = -1 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/utils_test.go
Outdated
| require.ErrorContains(t, err, errString) | ||
| require.Equal(t, uint64(transactions), totalTxs) | ||
| require.Equal(t, uint64(blocks), totalBlocks) | ||
| require.LessOrEqual(t, uint64(transactions), totalTxs) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
testutil/utils.go
Outdated
| } | ||
| } | ||
|
|
||
| func WaitForAssemblersGotAtLeast(t *testing.T, armaNetwork *ArmaNetwork, parties []types.PartyID, waitFor int, duration time.Duration) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| doesntMatter = -1 | ||
| ) | ||
|
|
||
| func TestPrimaryBatcherRestartRecover(t *testing.T) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| PullFromAssemblers(t, uc, parties, 0, math.MaxUint64, totalTxSent, doesntMatter, "cancelled pull from assembler: %d") | ||
| } | ||
|
|
||
| func TestSecondaryBatcherRestartRecover(t *testing.T) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| "github.com/hyperledger/fabric-x-orderer/node/comm" | ||
| ) | ||
|
|
||
| type StreamInfo struct { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
| // Pull from Assemblers | ||
| PullFromAssemblers(t, uc, parties, 0, math.MaxUint64, totalTxSent, doesntMatter, "cancelled pull from assembler: %d") | ||
|
|
||
| partyToRestart := types.PartyID(3) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
| // make sure clients of correct parties continue to get transactions (expect 2000 TXs). | ||
| PullFromAssemblers(t, uc, correctParties, 0, math.MaxUint64, totalTxSent, doesntMatter, "cancelled pull from assembler: %d") | ||
|
|
||
| // for shardId := 2; shardId <= 2; shardId++ { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
7ab097c to
b16e475
Compare
| func PullFromAssembler(t *testing.T, userConfig *armageddon.UserConfig, partyID types.PartyID, startBlock uint64, endBlock uint64, transactions int, blocks int) (uint64, uint64, []types.BatchID, error) { | ||
| require.NotNil(t, userConfig) | ||
| dc := client.NewDeliverClient(userConfig) | ||
| toCtx, toCancel := context.WithTimeout(context.Background(), 30*time.Second) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/utils_test.go
Outdated
| require.Equal(t, uint64(transactions), totalTxs) | ||
| require.Equal(t, uint64(blocks), totalBlocks) | ||
| // TODO: check that we get all of the submitted transactions | ||
| require.LessOrEqual(t, uint64(transactions), totalTxs) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/utils_test.go
Outdated
| // TODO: check that we get all of the submitted transactions | ||
| require.LessOrEqual(t, uint64(transactions), totalTxs) | ||
| if blocks > 0 { | ||
| require.LessOrEqual(t, uint64(blocks), totalBlocks) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
|
|
||
| const ( | ||
| // Number of shards in the test | ||
| numOfShards = 1 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
| partyBlockInfos := blockInfos[types.PartyID(1)] | ||
| primaryBatcherId := partyBlockInfos[len(partyBlockInfos)-1].Primary() | ||
| primaryBatcher := armaNetwork.GeBatcher(t, primaryBatcherId, types.ShardID(1)) | ||
| correctParties := []types.PartyID{} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
| } | ||
| } | ||
|
|
||
| // test that the router of party get stalled in the some point |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
test/batcher_test.go
Outdated
| totalTxSent += totalTxNumber | ||
|
|
||
| // 5. | ||
| // make sure clients of correct parties continue to get transactions (expect 2000 TXs). |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| txContent := prepareTx(i, 64, []byte("sessionNumber")) | ||
| err = broadcastClient.SendTx(txContent) | ||
| if err != nil { | ||
| require.ErrorContains(t, err, fmt.Sprintf("received error response from %s: INTERNAL_SERVER_ERROR", routerToStall.Listener.Addr().String())) // only such errors are permitted |
There was a problem hiding this comment.
should this still happen? maybe check there is no error
There was a problem hiding this comment.
Yes, it may happen since it takes time to renew faulty streams.
test/batcher_test.go
Outdated
| totalTxSent += totalTxNumber | ||
|
|
||
| // Pull from Assemblers | ||
| // make sure clients of all the parties get transactions (expect 3000 TXs). |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
713b820 to
7518f22
Compare
test/utils_test.go
Outdated
| require.Equal(t, uint64(blocks), totalBlocks) | ||
| // TODO: check that we get all of the submitted transactions | ||
| require.GreaterOrEqual(t, pullInfo.TotalTxs, uint64(transactions)) | ||
| if blocks > 0 { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| if shardID != types.ShardIDConsensus { | ||
| pID := PrimaryID{ShardID: shardID} | ||
| primaryIDBytes := block.GetMetadata().GetMetadata()[common.BlockMetadataIndex_ORDERER][0:2] |
There was a problem hiding this comment.
why are you using this and not the AssemblerBatchIdOrderingInfoAndTxCountFromBlock func?
There was a problem hiding this comment.
we don't need all the stuff that returns it
test/utils_test.go
Outdated
| return errors.New("nil block header") | ||
| } | ||
|
|
||
| atomic.AddUint64(&totalBlocks, uint64(1)) |
There was a problem hiding this comment.
how come this needs to be atomic but there is no lock over the map?
I guess you can remove this atomic add?
test/utils_test.go
Outdated
| ShardID types.ShardID | ||
| } | ||
|
|
||
| func (p *PrimaryID) Digest() types.ShardID { |
There was a problem hiding this comment.
No need, shardID is a comparable
test/utils_test.go
Outdated
| } | ||
|
|
||
| func PullFromAssemblers(t *testing.T, userConfig *armageddon.UserConfig, parties []types.PartyID, startBlock uint64, endBlock uint64, transactions int, blocks int, errString string) { | ||
| type PrimaryID struct { |
There was a problem hiding this comment.
why create a type for this? just use shardID
There was a problem hiding this comment.
You are right, shardID is comparable Fixed
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
7518f22 to
133fd3c
Compare
|
@gengur you still have a TODO for next PR to check that all transactions actually got in |
Integration tests - Batcher restart and recover
issue #84