Skip to content

Verify that no non deprecated SPI is removed#11722

Merged
findepi merged 2 commits intotrinodb:masterfrom
kokosing:origin/master/301_bc
Apr 15, 2022
Merged

Verify that no non deprecated SPI is removed#11722
findepi merged 2 commits intotrinodb:masterfrom
kokosing:origin/master/301_bc

Conversation

@kokosing
Copy link
Member

Verify that no non deprecated SPI is removed

This test verifies that SPI cannot be changed without a deprecation
period.

This partially solves the single version backward compatibility, the
other part is to ensure that engine still calls the deprecated API.

@cla-bot cla-bot bot added the cla-signed label Mar 30, 2022
@kokosing
Copy link
Member Author

Partially fixes #11667, the other part is not easily doable via tests. As we would need to have a plugins in previous version. I guess it requires the code review process to make sure that the old API is still used.

Comment on lines 61 to 62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause tests to fail in offline mode, or in any environment that doesn't have direct access to maven central. In some organizations, all access is performed through a proxy or a local maven repository.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like I need to download artifacts via maven, so it should use local maven repository in most of the cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable to require internet access during tests.
For example, docker-based tests won't pass if it is not possible to download the container images.

cc @nineinchnick

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree using local maven repo would be better though. Eg it would cover for retries required to cope with central's instability.

This can help

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>io.trino</groupId>
                                    <artifactId>trino-cli</artifactId>
                                    <version>${dep.trino.version}</version>
                                    <classifier>executable</classifier>
                                    <type>jar</type>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-based tests won't pass if it is not possible to download the container images.

You can always pre-download them and run the tests offline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be specific which file(s) should be filtered

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPI has more deps than just slice. Why is the Slice special? Document

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slice is special as loading SPI classes was loading Slice classes. Others were not loaded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url1 -> inputStream

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we need an scape hatch here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we assuming that Slice version doesn't change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can change, however I assume that loading slice classes for SPI for previous version will still work. Otherwise it sounds like yet another backward incompatible change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure i agree, but please capture your reasoning as a code comment

@martint
Copy link
Member

martint commented Mar 31, 2022

This test verifies that SPI cannot be changed without a deprecation
period.

Sometimes that is not possible, and we have to break backward compatibility. This change will entirely prevent that and remove that ability.

@kokosing kokosing force-pushed the origin/master/301_bc branch from 0bcc8bb to 40c0d98 Compare April 1, 2022 20:18
Copy link
Member Author

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AC

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slice is special as loading SPI classes was loading Slice classes. Others were not loaded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can change, however I assume that loading slice classes for SPI for previous version will still work. Otherwise it sounds like yet another backward incompatible change.

@kokosing
Copy link
Member Author

kokosing commented Apr 1, 2022

Sometimes that is not possible, and we have to break backward compatibility. This change will entirely prevent that and remove that ability.

@martint Notice that this test captured backward incompatibilities that were introduced in current ongoing version. So test does not prevent them, it makes them visible. Now we could potentially add them to release notes.

@kokosing kokosing force-pushed the origin/master/301_bc branch from 40c0d98 to 0d2171b Compare April 2, 2022 19:06
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exclusions (BACKWARD_INCOMPATIBLE_CHANGES) should be verified for being part of previous SPI

eg a test should fail when i add public void foo() to BACKWARD_INCOMPATIBLE_CHANGES, unless such method existed in the previous SPI AND it no longer exists in the new SPI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem with this. If we do this, then surely the very next commit after the release will have red CI due to this (when we had BACKWARD_INCOMPATIBLE_CHANGES in previous release).

I thought that maybe it is ok, to have BACKWARD_INCOMPATIBLE_CHANGES allow for things that got removed few releases ago.

Another thought is to print a warning, so it does not break the build, but it is noticed whenever somebody runs this test.
WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could eg have BACKWARD_INCOMPATIBLE_CHANGES as a map version -> changes
and we would just look at the entry for current version.
Of course, the point is not to keep track of all the breaking changes ever, but rather not to fail right after a release.
Then next person adding something new to the list would remove old (obsolete) entries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I no longer get a version from the pom to java. So in tests I have no notion of a version. Bringing back the version in the test just for this sounds like an overkill to me.

Maybe I can simply add a comment that:

// when updating  BACKWARD_INCOMPATIBLE_CHANGES please check if you can remove obsolete entries

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bringing back the version in the test just for this sounds like an overkill to me.

It's not

BTW i am making Java aware of SPI version in #11774

@kokosing kokosing force-pushed the origin/master/301_bc branch from 0d2171b to 788d031 Compare April 7, 2022 15:03
@kokosing
Copy link
Member Author

kokosing commented Apr 7, 2022

@findepi AC

@martint PTAL, I hope I have addressed your concerns.

@kokosing kokosing force-pushed the origin/master/301_bc branch from 788d031 to bdc5180 Compare April 7, 2022 18:54
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally the case, but might not always be. For instance, if something happens during the release process, we might need to "burn" a release (e.g., https://trino.io/docs/current/release/release-349.html)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will have to change this code line when doing that. perhaps add an if.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note also that we would have same problem with JDBC and server compatibility testing.
A rare case of a burned release would need to be handled explicitly.

@kokosing kokosing force-pushed the origin/master/301_bc branch from bdc5180 to 31cc5cc Compare April 8, 2022 12:47
@kokosing
Copy link
Member Author

kokosing commented Apr 8, 2022

@martint AC, PTAL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be auto-derived IMO. Why hard-coded? it adds maintenance overhead.

Note that when the test fails people will be steered first towards maintaining compatibility with an old version, rather than fix the version number here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about addressing this comment: #11722 (comment)

Note that when the test fails people will be steered first towards maintaining compatibility with an old version, rather than fix the version number here.

Maybe it is a good thing. Also I can add some comment here to make it more clear what is the goal here. Like We try to be backward compatible with at least last released version. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is a good thing.

This isn't what was intended and is more than we wanted.

add some comment here to make it more clear

the problem is -- the comment here won't be visible; the test failure will

This is about addressing this comment: #11722 (comment)

i replied there

Comment on lines 125 to 127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is recursive (higher up in class hierarchy), maybe worth commenting about this.

Also, you returning Object-defined methods

public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public boolean java.lang.Object.equals(java.lang.Object)
public java.lang.String java.lang.Object.toString()
public native int java.lang.Object.hashCode()
public final native java.lang.Class<?> java.lang.Object.getClass()
public final native void java.lang.Object.notify()
public final native void java.lang.Object.notifyAll()

they will not cause a change (unless last SPI classes is removed), but still maybe worth documenting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to return only declared entities and skip object and enum methods. Thanks.

Previously, used getMethods and getFields as it returns only public things. However it is easier public things than hierarchical ones (or maybe it as same level of complexity...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example entry which makes adding new entries easier, but this example entry should be removed already (per comment above + 376 is out). Let's make adding new entries easier in some more durable manner, perhaps as a commented-out copy-paste-ready example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. 375-SNAPSHOT is almost compatible with 375 which is a good thing.

Also since now version is hardcoded, I no longer think that the key ("375") is needed here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of key-ing on version was to enforce that backwards incompatible change declaration is not implicitly carried over to the next release.

Let's imagine

  • v 100: we have a public method foo
  • v 101: we remove the method foo and declare this as a backward incompatible change
  • v 102: we reintroduce method foo
  • v 103-SNAPSHOT: we remove method foo -- we want the test to fail, as this is a new backward incompatible change; for it to fail, we need to ensure the 101's suppression is not carried forwards implicitly

@kokosing kokosing force-pushed the origin/master/301_bc branch from 31cc5cc to 4ff5948 Compare April 10, 2022 19:54
Copy link
Member Author

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AC

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about addressing this comment: #11722 (comment)

Note that when the test fails people will be steered first towards maintaining compatibility with an old version, rather than fix the version number here.

Maybe it is a good thing. Also I can add some comment here to make it more clear what is the goal here. Like We try to be backward compatible with at least last released version. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. 375-SNAPSHOT is almost compatible with 375 which is a good thing.

Also since now version is hardcoded, I no longer think that the key ("375") is needed here.

Comment on lines 125 to 127
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to return only declared entities and skip object and enum methods. Thanks.

Previously, used getMethods and getFields as it returns only public things. However it is easier public things than hierarchical ones (or maybe it as same level of complexity...)

@kokosing kokosing force-pushed the origin/master/301_bc branch from 4ff5948 to 7911830 Compare April 10, 2022 19:58
@kokosing kokosing force-pushed the origin/master/301_bc branch from 7911830 to 49e882f Compare April 11, 2022 12:50
@kokosing
Copy link
Member Author

AC

This test verifies that SPI cannot be changed without a deprecation
period.

This partially solves the SPI backward compatibility, the
other part is to ensure that engine still calls the deprecated API.
@kokosing kokosing force-pushed the origin/master/301_bc branch from 49e882f to ec54986 Compare April 11, 2022 14:19
@kokosing
Copy link
Member Author

AC

@findepi Thank you for the review! ❤️

@findepi
Copy link
Member

findepi commented Apr 13, 2022

@kokosing thank you for your patience with my review comments.
This is an awesome addition!

I am gonna merge this tomorrow, unless anyone has any more comments.

cc @trinodb/maintainers

@kokosing
Copy link
Member Author

thank you for your patience with my review comments.

@findepi This was a pleasure. Always! I appreciate all your comments, they improved this change a lot!

@findepi findepi merged commit 3c2c63e into trinodb:master Apr 15, 2022
@github-actions github-actions bot added this to the 378 milestone Apr 15, 2022
@kokosing kokosing deleted the origin/master/301_bc branch April 15, 2022 11:38
@kokosing
Copy link
Member Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants