Skip to content

Commit

Permalink
Merge branch 'release-1.157.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomuri committed Apr 17, 2024
2 parents 401943e + a19d6f1 commit dc8d90c
Show file tree
Hide file tree
Showing 130 changed files with 3,046 additions and 3,625 deletions.
16 changes: 16 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
LC_ALL=C

local_branch="$(git rev-parse --abbrev-ref HEAD)"

valid_branch_regex="^(docs|feature|fix|test|release|improvement|hotfix|chore)\/[a-z0-9._-]+$"

message="There branch name is wrong. Branch names in this project must adhere to this contract: $valid_branch_regex. You should rename your branch to a valid name and try again."

if [[ ! $local_branch =~ $valid_branch_regex ]]
then
echo "$message"
exit 1
fi

exit 0
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# Changelog
## v1.157.0 (15/04/2024)

## v1.156.0 (26/02/2024)
### Bug Fixes:
- [#5632](https://github.com/telstra/open-kilda/pull/5632) GUI hotfix. [**gui**]
- [#5627](https://github.com/telstra/open-kilda/pull/5627) fix switch synchronization when discrepancy doesn't include cookie (Issue: [#5626](https://github.com/telstra/open-kilda/issues/5626))

### Improvements:
- [#5570](https://github.com/telstra/open-kilda/pull/5570) 5560: [TEST]: Add automatic cleanup in functional test (Issue: [#5560](https://github.com/telstra/open-kilda/issues/5560)) [**tests**]
- [#5605](https://github.com/telstra/open-kilda/pull/5605) add git configuration with hook
- [#5542](https://github.com/telstra/open-kilda/pull/5542) [TEST]: Storm topology restarting: Topology readiness HC(ISLs, switches) [**tests**]
- [#5610](https://github.com/telstra/open-kilda/pull/5610) 5560: [TEST]: Add methods to break/restore ISLs in test (Issues: [#5560](https://github.com/telstra/open-kilda/issues/5560) [#5608](https://github.com/telstra/open-kilda/issues/5608)) [**tests**]
- [#5611](https://github.com/telstra/open-kilda/pull/5611) [TEST]: Y-Flow: Adding a new approach for Y-Flow interaction [**tests**]
- [#5587](https://github.com/telstra/open-kilda/pull/5587) [TEST]: Improvement: Path Check: Flaky test [**tests**]
- [#5621](https://github.com/telstra/open-kilda/pull/5621) [TEST]: HA-Flow: Factory [**tests**]
- [#5592](https://github.com/telstra/open-kilda/pull/5592) [TEST]: Improvement: FL: Adding switch recovering logic [**tests**]
- [#5629](https://github.com/telstra/open-kilda/pull/5629) [TEST]: 5390: Flaky: Flow monitoring [**tests**]

---

For the complete list of changes, check out [the commit log](https://github.com/telstra/open-kilda/compare/v1.156.0...v1.157.0).
## v1.156.0 (26/02/2024)

### Improvements:
- [#5584](https://github.com/telstra/open-kilda/pull/5584) Remove "draft" tag from HA-flow API in swagger. (Issue: [#5061](https://github.com/telstra/open-kilda/issues/5061))
Expand Down
8 changes: 8 additions & 0 deletions docs/contrib/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ Bad branch names:
* `my_mega_fix`
* `doc/how_to_contribute_in_kilda_if_you_cant_come_up_with_a_short_name_for_a_git_branch`

To add branch name verification during the commit, please configure git hook for commit (see .hooks directory)

make hook file executable:
chmod 0555 .hooks/pre-commit

add hooks to git configuration (execute from project root):
git config --local core.hooksPath .hooks/

### Commits

The best practice is to have one commit per one branch. If you need to change
Expand Down
12 changes: 6 additions & 6 deletions src-gui/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"angular-datatables": "16.0.1",
"bootstrap": "^4.6.2",
"d3": "^7.8.5",
"datatables.net": "^1.13.7",
"datatables.net-buttons": "^2.4.2",
"datatables.net-buttons-dt": "^2.4.2",
"datatables.net-dt": "^1.13.7",
"datatables.net": "1.13.7",
"datatables.net-buttons": "2.4.2",
"datatables.net-buttons-dt": "2.4.2",
"datatables.net-dt": "1.13.7",
"dt-colresize": "^2.6.0",
"dygraphs": "^2.2.1",
"font-awesome": "^4.7.0",
Expand Down Expand Up @@ -58,8 +58,8 @@
"@angular/compiler-cli": "16.2.12",
"@angular/language-service": "16.2.12",
"@angular/localize": "^16.2.12",
"@types/datatables.net": "^1.10.27",
"@types/datatables.net-buttons": "^1.4.10",
"@types/datatables.net": "1.10.27",
"@types/datatables.net-buttons": "1.4.10",
"@types/jasmine": "^5.1.2",
"@types/jasminewd2": "^2.0.13",
"@types/node": "~20.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ protected void computeMisconfiguredRules(SwitchSyncState from, SwitchSyncState t
SwitchSyncEvent event, Object context) {
reinstalledRulesCookies = new ArrayList<>(validationResult.getValidateRulesResult().getMisconfiguredRules());
if (!reinstalledRulesCookies.isEmpty()) {
log.info("Compute reinstall rules (switch={}, key={})", switchId, key);
log.info("Compute reinstall rules (switch={}, key={}), reinstalledRulesCookies={}", switchId, key,
reinstalledRulesCookies);
try {
List<FlowSpeakerData> misconfiguredRulesToRemove = reinstalledRulesCookies.stream()
.flatMap(this::findActualFlowsByCookie)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public ValidateRulesResult map(ValidateRulesResultV2 report) {
.map(RuleInfoEntryV2::getCookie)
.collect(Collectors.toSet());
Set<Long> misconfigured = report.getMisconfiguredRules().stream()
.map(m -> m.getDiscrepancies().getCookie())
.map(m -> Optional.ofNullable(m.getDiscrepancies().getCookie())
.orElse(m.getExpected().getCookie()))
.collect(Collectors.toSet());

return new ValidateRulesResult(missing, proper, excess, misconfigured);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.openkilda.rulemanager.group.WatchPort;
import org.openkilda.rulemanager.match.FieldMatch;
import org.openkilda.wfm.topology.switchmanager.model.SwitchValidationContext;
import org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult;
import org.openkilda.wfm.topology.switchmanager.model.v2.ValidateGroupsResultV2;
import org.openkilda.wfm.topology.switchmanager.model.v2.ValidateLogicalPortsResultV2;
import org.openkilda.wfm.topology.switchmanager.model.v2.ValidateMetersResultV2;
Expand Down Expand Up @@ -161,7 +162,7 @@ private static GroupSpeakerData initializeGroupSpeakerData(SwitchId uniqueSwitch
public static Set<FieldMatch> matches = new HashSet<>();
public static Instructions instructions;

private static FlowSpeakerData initializeFlowSpeakerData(int uniquePriorityField) {
private static FlowSpeakerData initializeFlowSpeakerData(int uniquePriorityField, Cookie cookie) {

applyActions.add(SET_FIELD_ACTION);
for (Field field : Field.values()) {
Expand All @@ -173,7 +174,7 @@ private static FlowSpeakerData initializeFlowSpeakerData(int uniquePriorityField
OF_METADATA);

return FlowSpeakerData.builder()
.cookie(COOKIE)
.cookie(cookie)
.durationSeconds(DURATION_SECONDS)
.durationNanoSeconds(DURATION_NANOSECONDS)
.table(OF_TABLE_FIELD)
Expand All @@ -189,6 +190,10 @@ private static FlowSpeakerData initializeFlowSpeakerData(int uniquePriorityField
.build();
}

private static FlowSpeakerData initializeFlowSpeakerData(int uniquePriorityField) {
return initializeFlowSpeakerData(uniquePriorityField, COOKIE);
}

public static Set<MeterFlag> meterFlags = new HashSet<>();

private static MeterSpeakerData initializeMeterSpeakerData(MeterId uniqueMeterIdValue) {
Expand Down Expand Up @@ -253,6 +258,12 @@ public static void initializeData() {
.discrepancies(RuleEntryConverter.INSTANCE.toRuleEntry(initializeFlowSpeakerData(5)))
.build());

misconfiguredRules.add(MisconfiguredInfo.<RuleInfoEntryV2>builder()
.id("15")
.expected(RuleEntryConverter.INSTANCE.toRuleEntry(initializeFlowSpeakerData(6, new Cookie(1))))
.discrepancies(RuleEntryConverter.INSTANCE.toRuleEntry(initializeFlowSpeakerData(7, null)))
.build());

missingMeters.add(MeterEntryConverter.INSTANCE.toMeterEntry(initializeMeterSpeakerData(new MeterId(1))));
properMeters.add(MeterEntryConverter.INSTANCE.toMeterEntry(initializeMeterSpeakerData(
new MeterId(2))));
Expand Down Expand Up @@ -320,4 +331,16 @@ public void mapValidationTest() {
Assertions.assertEquals(excessMeters, metersEntry.getExcess());
Assertions.assertEquals(misconfiguredMeters, metersEntry.getMisconfigured());
}

@Test
public void mapValidateRulesResultV2ToValidateRulesResultIncludingNullCookieInDiscrepancy() {
ValidateRulesResultV2 validateRulesResultV2 = new ValidateRulesResultV2(false, missingRules, properRules,
excessRules, misconfiguredRules);

ValidateRulesResult validateRulesResult =
ValidationMapper.INSTANCE.map(validateRulesResultV2);

Assertions.assertEquals(2, validateRulesResult.getMisconfiguredRules().size());
validateRulesResult.getMisconfiguredRules().forEach(Assertions::assertNotNull);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

@Configuration
@ComponentScan(basePackages = ["org.openkilda.functionaltests.helpers", "org.openkilda.functionaltests.model.stats"])
@ComponentScan(basePackages = ["org.openkilda.functionaltests.helpers",
"org.openkilda.functionaltests.model.stats",
"org.openkilda.functionaltests.model.cleanup"
])
class HelpersConfig {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ enum Tag {
ISL_RECOVER_ON_FAIL,
//resetting cost and bandwidth only when an error occurred during test execution
ISL_PROPS_DB_RESET,
//floodlight manipulation: adding/unlock sw
SWITCH_RECOVER_ON_FAIL,

//flow type specific tag
HA_FLOW
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.openkilda.functionaltests.helpers

import org.openkilda.functionaltests.model.cleanup.CleanupAfter
import org.openkilda.functionaltests.model.cleanup.CleanupManager
import org.openkilda.messaging.payload.flow.PathNodePayload
import org.openkilda.messaging.payload.history.FlowHistoryEntry
import org.openkilda.model.SwitchId
Expand Down Expand Up @@ -47,6 +49,10 @@ class FlowHelper {
NorthboundService northbound
@Autowired
Database db
@Autowired
FlowHelperV2 flowHelperV2
@Autowired
CleanupManager cleanupManager

def random = new Random()
def faker = new Faker()
Expand Down Expand Up @@ -131,11 +137,23 @@ class FlowHelper {
*/
FlowPayload addFlow(FlowPayload flow) {
log.debug("Adding flow '${flow.id}'")
def flowId = flow.getId()
cleanupManager.addAction({flowHelperV2.safeDeleteFlow(flowId)}, CleanupAfter.TEST)
def response = northbound.addFlow(flow)
Wrappers.wait(FLOW_CRUD_TIMEOUT) { assert northbound.getFlowStatus(flow.id).status == FlowState.UP }
return response
}

/**
* Sends flow create request but doesn't wait for flow to go up.
*/
FlowPayload attemptToAddFlow(FlowCreatePayload flow) {
def flowId = flow.getId()
cleanupManager.addAction({flowHelperV2.safeDeleteFlow(flowId)}, CleanupAfter.TEST)
return northbound.addFlow(flow)
}


List<Integer> "get ports that flow uses on switch from path" (String flowId, SwitchId switchId) {
def response = northbound.getFlowPath(flowId)
def paths = response.forwardPath + response.reversePath + (response.protectedPath as PathNodePayload)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.openkilda.functionaltests.helpers

import org.openkilda.functionaltests.model.cleanup.CleanupAfter
import org.openkilda.functionaltests.model.cleanup.CleanupManager

import static org.openkilda.functionaltests.helpers.FlowHelper.KILDA_ALLOWED_VLANS
import static FlowHistoryConstants.UPDATE_SUCCESS
import static org.openkilda.functionaltests.helpers.FlowHistoryConstants.CREATE_MIRROR_SUCCESS
import static org.openkilda.functionaltests.helpers.FlowHistoryConstants.CREATE_SUCCESS
import static org.openkilda.functionaltests.helpers.FlowHistoryConstants.DELETE_SUCCESS
import static org.openkilda.functionaltests.helpers.FlowHistoryConstants.PARTIAL_UPDATE_ONLY_IN_DB
import static org.openkilda.functionaltests.model.cleanup.CleanupAfter.TEST
import static org.openkilda.messaging.payload.flow.FlowState.IN_PROGRESS
import static org.openkilda.messaging.payload.flow.FlowState.UP
import static org.openkilda.testing.Constants.FLOW_CRUD_TIMEOUT
Expand Down Expand Up @@ -53,6 +57,8 @@ class FlowHelperV2 {
NorthboundServiceV2 northboundV2
@Autowired @Qualifier("islandNb")
NorthboundService northbound
@Autowired
CleanupManager cleanupManager

def random = new Random()
def faker = new Faker()
Expand Down Expand Up @@ -157,13 +163,15 @@ class FlowHelperV2 {
/**
* Adds flow and waits for it to become in expected state ('Up' by default)
*/
FlowResponseV2 addFlow(FlowRequestV2 flow, FlowState expectedFlowState = UP) {
FlowResponseV2 addFlow(FlowRequestV2 flow, FlowState expectedFlowState = UP, cleanupAfter = TEST) {
log.debug("Adding flow '${flow.flowId}'")
def flowId = flow.getFlowId()
cleanupManager.addAction({safeDeleteFlow(flowId)}, cleanupAfter)
def response = northboundV2.addFlow(flow)
Wrappers.wait(FLOW_CRUD_TIMEOUT) {
assert northboundV2.getFlowStatus(flow.flowId).status == expectedFlowState
assert northboundV2.getFlowStatus(flowId).status == expectedFlowState
if (expectedFlowState != IN_PROGRESS) {
assert northbound.getFlowHistory(flow.flowId).any {it.payload.last().action == CREATE_SUCCESS}
assert northbound.getFlowHistory(flowId).any {it.payload.last().action == CREATE_SUCCESS}
}
}
return response
Expand All @@ -180,6 +188,8 @@ class FlowHelperV2 {
* Sends flow create request but doesn't wait for flow to go up.
*/
FlowResponseV2 attemptToAddFlow(FlowRequestV2 flow) {
def flowId = flow.getFlowId()
cleanupManager.addAction({safeDeleteFlow(flowId)}, TEST)
return northboundV2.addFlow(flow)
}

Expand All @@ -197,6 +207,12 @@ class FlowHelperV2 {
return response
}

def safeDeleteFlow(String flowId) {
if (flowId in northboundV2.getAllFlows()*.getFlowId()) {
deleteFlow(flowId)
}
}

/**
* Updates flow and waits for it to become UP
*/
Expand Down Expand Up @@ -251,6 +267,10 @@ class FlowHelperV2 {
return (KILDA_ALLOWED_VLANS - exclusions).shuffled().first()
}

static List<Integer> availableVlanList(List<Integer> exclusions) {
return (KILDA_ALLOWED_VLANS - exclusions).shuffled()
}

/**
* Check whether given potential flow is conflicting with any of flows in the given list.
* Usually used to ensure that some new flow is by accident is not conflicting with any of existing flows.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.openkilda.functionaltests.helpers


import static org.openkilda.testing.Constants.FLOW_CRUD_TIMEOUT
import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE

import org.openkilda.functionaltests.helpers.builder.HaFlowBuilder
import org.openkilda.functionaltests.helpers.model.HaFlowExtended
import org.openkilda.functionaltests.helpers.model.SwitchPortVlan
import org.openkilda.functionaltests.helpers.model.SwitchTriplet
import org.openkilda.messaging.payload.flow.FlowState
import org.openkilda.northbound.dto.v2.haflows.HaFlow
import org.openkilda.testing.model.topology.TopologyDefinition
import org.openkilda.testing.service.northbound.NorthboundServiceV2

import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component

@Slf4j
@Component
@Scope(SCOPE_PROTOTYPE)
class HaFlowFactory {

@Autowired
TopologyDefinition topology

@Autowired @Qualifier("islandNbV2")
NorthboundServiceV2 northboundV2

/*
This method allows customization of the HA-Flow with desired parameters for further creation
*/
HaFlowBuilder getBuilder(SwitchTriplet swT, boolean useTraffgenPorts = true, List<SwitchPortVlan> busyEndpoints = []) {
return new HaFlowBuilder(swT, northboundV2, topology, useTraffgenPorts, busyEndpoints)
}

/*
This method allows random HA-Flow creation on specified switches
and waits for it to become UP.
*/

HaFlowExtended getRandom(SwitchTriplet swT, boolean useTraffgenPorts = true, List<SwitchPortVlan> busyEndpoints = []) {
HaFlowBuilder haFlowBuilder = getBuilder(swT, useTraffgenPorts, busyEndpoints)
def response = haFlowBuilder.build()
assert response.haFlowId
HaFlow haFlow = null
Wrappers.wait(FLOW_CRUD_TIMEOUT) {
haFlow = northboundV2.getHaFlow(response.haFlowId)
assert haFlow.status == FlowState.UP.toString()
&& haFlow.getSubFlows().status.unique() == [FlowState.UP.toString()], "Flow: ${haFlow}"
}
return new HaFlowExtended(haFlow, northboundV2, topology)
}
}
Loading

0 comments on commit dc8d90c

Please sign in to comment.