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
9 package org.opendaylight.protocol.pcep.pcc.mock;
11 import static org.junit.Assert.assertFalse;
13 import com.google.common.base.Optional;
14 import io.netty.channel.Channel;
15 import java.math.BigInteger;
16 import java.net.UnknownHostException;
17 import java.util.ArrayList;
18 import java.util.List;
19 import java.util.concurrent.ExecutionException;
20 import org.junit.Test;
21 import org.opendaylight.protocol.pcep.PCEPCapability;
22 import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
23 import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCServerPeerProposal;
24 import org.opendaylight.protocol.util.InetSocketAddressUtil;
26 public class PCCIncrementalSyncTest extends PCCMockCommon {
28 private BigInteger lsp = BigInteger.valueOf(8);
30 * Test Incremental Synchronization
31 * Create 8 lsp, then it disconnects after 5 sec and then after 5 sec reconnects with Pcc DBVersion 10
32 * After reconnection PCE has DBVersion 10, therefore there is 9 changes missed. 9 Pcrt + 1 Pcrt-Sync
34 private final String[] mainInputIncrementalSync = new String[]{"--local-address", this.localAddress.getHostString(), "--remote-address",
35 InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1", "--lsp", lsp.toString(), "--log-level", "DEBUG", "-ka", "40", "-d", "120",
36 "--reconnect", "-1", "--redelegation-timeout", "0", "--state-timeout", "-1", "--incremental-sync-procedure", "10", "5", "5"};
39 public void testSessionIncrementalSyncEstablishment() throws UnknownHostException, InterruptedException, ExecutionException {
40 final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
41 final BigInteger numberOflspAndDBv = BigInteger.valueOf(8);
42 final Channel channel = createServer(factory, this.remoteAddress, new PCCServerPeerProposal(numberOflspAndDBv));
43 Main.main(mainInputIncrementalSync);
45 final TestingSessionListener pceSessionListener = getListener(factory);
46 checkSynchronizedSession(8, pceSessionListener, numberOflspAndDBv);
48 assertFalse(pceSessionListener.isUp());
49 final int expetedNumberOfLspAndEndOfSync = 3;
50 final BigInteger expectedFinalDBVersion = BigInteger.valueOf(10);
51 final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
52 checkResyncSession(Optional.absent(), expetedNumberOfLspAndEndOfSync, numberOflspAndDBv, expectedFinalDBVersion, sessionListenerAfterReconnect);
53 channel.close().get();
57 protected List<PCEPCapability> getCapabilities() {
58 final List<PCEPCapability> caps = new ArrayList<>();
59 caps.add(new PCEPStatefulCapability(true, true, true, false, false, true, true));