From 1ee69b1f0a3fde8d77393f541b12ff6daee11600 Mon Sep 17 00:00:00 2001 From: Enbo Wang Date: Wed, 4 Dec 2019 21:14:48 +0800 Subject: Add LCM APIs for DownloadNeSw and ActivateNeSw actions Add two LCM APIs of DownloadNeSw and ActivateNeSw for PNF Software Upgrade. Change-Id: I5a8f143c2d7d54fd96772eeb1d31b2d2e8bfb523 Issue-ID: SDNC-856 Signed-off-by: Enbo Wang --- .../onap/ccsdk/sli/northbound/TestLcmProvider.java | 72 ++++++++++++++++++++++ .../resources/graphs/lcm/LCM_activate-ne-sw.xml | 30 +++++++++ .../resources/graphs/lcm/LCM_download-ne-sw.xml | 30 +++++++++ .../src/test/resources/graphs/lcm/graph.versions | 2 + 4 files changed, 134 insertions(+) create mode 100644 lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml create mode 100644 lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml (limited to 'lcm/provider/src/test') diff --git a/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java b/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java index 8e82ccad..e0d8e577 100644 --- a/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java +++ b/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java @@ -106,6 +106,10 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329. import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.UpgradePreCheckOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.UpgradeSoftwareInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.UpgradeSoftwareOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DownloadNeSwInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DownloadNeSwOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ActivateNeSwInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ActivateNeSwOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ZULU; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.action.identifiers.ActionIdentifiersBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.common.header.CommonHeaderBuilder; @@ -1150,6 +1154,74 @@ public class TestLcmProvider { } } + @Test + public void testDownloadNeSw() { + DownloadNeSwInputBuilder builder = new DownloadNeSwInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + ActionIdentifiersBuilder aBuilder = new ActionIdentifiersBuilder(); + aBuilder.setServiceInstanceId("SVCID-123"); + aBuilder.setVfModuleId("vf-module-1"); + aBuilder.setVnfcName("my-vnfc"); + aBuilder.setVnfId("123"); + aBuilder.setVserverId("123"); + builder.setActionIdentifiers(aBuilder.build()); + + builder.setAction(Action.DownloadNeSw); + builder.setPayload(mock(Payload.class)); + + + try { + DownloadNeSwOutput results = provider.downloadNeSw(builder.build()).get().getResult(); + LOG.info("DownloadNeSw returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("DownloadNeSw threw exception"); + } + } + + @Test + public void testActivateNeSw() { + ActivateNeSwInputBuilder builder = new ActivateNeSwInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + ActionIdentifiersBuilder aBuilder = new ActionIdentifiersBuilder(); + aBuilder.setServiceInstanceId("SVCID-123"); + aBuilder.setVfModuleId("vf-module-1"); + aBuilder.setVnfcName("my-vnfc"); + aBuilder.setVnfId("123"); + aBuilder.setVserverId("123"); + builder.setActionIdentifiers(aBuilder.build()); + + builder.setAction(Action.ActivateNeSw); + builder.setPayload(mock(Payload.class)); + + + try { + ActivateNeSwOutput results = provider.activateNeSw(builder.build()).get().getResult(); + LOG.info("ActivateNeSw returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("ActivateNeSw threw exception"); + } + } + @Test public void testStop() { StopInputBuilder builder = new StopInputBuilder(); diff --git a/lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml b/lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml new file mode 100644 index 00000000..99f74b6e --- /dev/null +++ b/lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml b/lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml new file mode 100644 index 00000000..fd586cce --- /dev/null +++ b/lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/lcm/provider/src/test/resources/graphs/lcm/graph.versions b/lcm/provider/src/test/resources/graphs/lcm/graph.versions index 233aa459..466be55b 100644 --- a/lcm/provider/src/test/resources/graphs/lcm/graph.versions +++ b/lcm/provider/src/test/resources/graphs/lcm/graph.versions @@ -30,6 +30,8 @@ LCM resume-traffic 1.0.0 sync LCM distribute-traffic 1.0.0 sync LCM upgrade-pre-check 1.0.0 sync LCM upgrade-software 1.0.0 sync +LCM download-ne-sw 1.0.0 sync +LCM activate-ne-sw 1.0.0 sync LCM upgrade-post-check 1.0.0 sync LCM upgrade-backup 1.0.0 sync LCM upgrade-backout 1.0.0 sync -- cgit 1.2.3-korg