markap14 commented on code in PR #11677: URL: https://github.com/apache/nifi/pull/11677#discussion_r4047192845
########## nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/connectors/ConnectorChangeVersionIT.java: ########## @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.tests.system.connectors; + +import org.apache.nifi.components.connector.ConnectorState; +import org.apache.nifi.nar.NarState; +import org.apache.nifi.tests.system.NiFiSystemIT; +import org.apache.nifi.tests.system.nar.NarUploadUtil; +import org.apache.nifi.toolkit.cli.impl.command.CommandOption; +import org.apache.nifi.toolkit.cli.impl.command.nifi.connectors.ChangeVersionConnector; +import org.apache.nifi.web.api.dto.ConfigurationStepConfigurationDTO; +import org.apache.nifi.web.api.dto.ConnectorConfigurationDTO; +import org.apache.nifi.web.api.dto.ConnectorValueReferenceDTO; +import org.apache.nifi.web.api.dto.NarSummaryDTO; +import org.apache.nifi.web.api.dto.PropertyGroupConfigurationDTO; +import org.apache.nifi.web.api.entity.ConnectorEntity; +import org.apache.nifi.web.api.entity.ProcessGroupFlowEntity; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.Map; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ConnectorChangeVersionIT extends NiFiSystemIT { + + private static final String NARS_LOCATION = "target/nifi-connector-change-version-nars"; + private static final String VERSION_ONE_NAR_ID = "nifi-connector-change-version-v1-nar"; + private static final String VERSION_TWO_NAR_ID = "nifi-connector-change-version-v2-nar"; + private static final String CONNECTOR_TYPE = "org.apache.nifi.connectors.tests.system.changeversion.ChangeVersionTestConnector"; + private static final String BUNDLE_GROUP = "org.apache.nifi"; + private static final String BUNDLE_ARTIFACT = "nifi-connector-change-version-nar"; + private static final String VERSION_ONE = "1.0.0"; + private static final String VERSION_TWO = "2.0.0"; + private static final String SETTINGS_STEP = "Settings"; + private static final String SHARED_PROPERTY = "Shared Property"; + private static final String NEW_PROPERTY = "New Property"; + private static final String CUSTOM_SHARED_VALUE = "kept-across-reload"; + private static final String VERSION_ONE_FLOW_NAME = "Change Version Flow v1"; + private static final String VERSION_TWO_DEFAULT = "version-two-default"; + + @Override + protected boolean isDestroyEnvironmentAfterEachTest() { + return true; + } + + @Test + public void testChangeConnectorNarVersionPreservesManagedFlowAndOverlappingConfiguration() throws Exception { Review Comment: [grok-4.6] @bobpaulin Thanks for the pointer. I extended the existing change-version system test so it now also changes back from Version 2 to Version 1. After that revert: - the managed Process Group id is unchanged - the flow name stays `Change Version Flow v1` (it is not swapped to the Version 2 name) - `Shared Property` is still `kept-across-reload` - Version 2's `New Property` is dropped from the stored configuration. Leaving it in place made the Connector invalid (`Property 'New Property' is not defined`), so the framework now drops properties and configuration steps that the current Connector version does not declare after `migrateProperties`. If a Connector does not support a given version change, it can still fail the swap by throwing from `migrateProperties`, `initialize`, or `onStepConfigured`. We did not add a separate "unsupported" flag for that. The same test then enters Troubleshooting, adds a processor, and exits. The extra processor is removed, the Version 1 configuration remains, and the Connector can be started again. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
