2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.pcep.pcc.mock;
10 import io.netty.channel.Channel;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.Optional;
15 import org.junit.Test;
16 import org.opendaylight.protocol.pcep.PCEPCapability;
17 import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
18 import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCServerPeerProposal;
19 import org.opendaylight.protocol.util.InetSocketAddressUtil;
20 import org.opendaylight.yangtools.yang.common.Uint64;
22 public class PCCIncrementalSyncTest extends PCCMockCommon {
24 private final BigInteger lsp = BigInteger.valueOf(8);
26 * Test Incremental Synchronization
27 * Create 8 lsp, then it disconnects after 5 sec and then after 5 sec reconnects with Pcc DBVersion 10
28 * After reconnection PCE has DBVersion 10, therefore there is 9 changes missed. 9 Pcrt + 1 Pcrt-Sync
30 private final String[] mainInputIncrementalSync = new String[]{"--local-address", this.localAddress.getHostString(),
31 "--remote-address", InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1", "--lsp",
32 this.lsp.toString(), "--log-level", "DEBUG", "-ka", "30", "-d", "120", "--reconnect", "-1",
33 "--redelegation-timeout", "0", "--state-timeout", "-1", "--incremental-sync-procedure", "10", "5", "5"};
36 public void testSessionIncrementalSyncEstablishment() throws Exception {
37 final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
38 final Uint64 numberOflspAndDBv = Uint64.valueOf(8);
39 final Channel channel = createServer(factory, this.remoteAddress, new PCCServerPeerProposal(numberOflspAndDBv));
40 Main.main(this.mainInputIncrementalSync);
41 final TestingSessionListener pceSessionListener = getListener(factory);
42 checkSynchronizedSession(8, pceSessionListener, numberOflspAndDBv);
44 final int expetecdNumberOfLspAndEndOfSync = 3;
45 final Uint64 expectedFinalDBVersion = Uint64.TEN;
46 final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
47 checkResyncSession(Optional.empty(), expetecdNumberOfLspAndEndOfSync, 3, numberOflspAndDBv,
48 expectedFinalDBVersion, sessionListenerAfterReconnect);
49 channel.close().get();
53 protected List<PCEPCapability> getCapabilities() {
54 final List<PCEPCapability> caps = new ArrayList<>();
55 caps.add(new PCEPStatefulCapability(true, true, true, false, false, true, true));