Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTT BE Testing #1

Open
wants to merge 858 commits into
base: master
Choose a base branch
from
Open

Conversation

alonbasin-kaltura
Copy link
Contributor

@alonbasin-kaltura alonbasin-kaltura commented Apr 25, 2018

@tan-tan-kanarek

  1. "All service impl classes can be auto-generated, I will do it for you when I have the time."
    That will be great as it will save us a lot of maintenance time. Also wanted to ask you if in each impl function we need AtomicBoolean for parallel execution?

  2. "Try to delete any created object after the test is done, with success or error, that will enable us to run these tests also in production without trashing the DB too much."
    Will do, but only in case there's API for it. (I've been asked not to delete directly from the DB).

  3. "All service specific utils could be implemented in a parent class of all tests of that service, would be much more elegant."
    If you like I can do so, but we calling those utils from different services tests. For example createHousehold() being called almost in each test (not only in HouseholdTests). Let me know what you think.

@tan-tan-kanarek
Copy link

tan-tan-kanarek commented Apr 25, 2018

All service impl classes can be auto-generated, I will do it for you when I have the time.

In a second thought, you better remove all these classes and implement one executeSync method in TestAPIOkRequestsExecutor and use it directly.

@tan-tan-kanarek
Copy link

Try to delete any created object after the test is done, with success or error, that will enable us to run these tests also in production without trashing the DB too much.

@tan-tan-kanarek
Copy link

All service speific utils could be implemented in a parent class of all tests of that service, would be much more elegant.

@@ -0,0 +1,100 @@
package com.kaltura.client.test;

Choose a reason for hiding this comment

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

We don't want these properties to be hard-coded, please load them from properties file and create both template file similar to https://github.com/kaltura/KalturaOttGeneratedAPIClientsJava/blob/master/src/test/java/resources/ott.test.template.properties and real configuration for QA env.

Copy link
Contributor Author

@alonbasin-kaltura alonbasin-kaltura Apr 25, 2018

Choose a reason for hiding this comment

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

@tan-tan-kanarek What do you mean "both template file"? we already have test.properties file but it is git ignored because of sensitive data.

Choose a reason for hiding this comment

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

If you have properties file, why I see all the values here hard-coded?
Also, you can commit the properties file that contain all the QA inaccessible URLs.
Third, please supply a template file for the properties file with place holders for all values.

private static ILogger logger = Logger.getLogger(TAG);
protected static TestAPIOkRequestsExecutor self;

public static TestAPIOkRequestsExecutor getExecutor() {

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

done


@SuppressWarnings("rawtypes")
@Override
protected ResponseElement onGotResponse(Response response, RequestElement action) {

Choose a reason for hiding this comment

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

Reimplementing onGotResponse will cause that you won't get any change that done on the parent class that is the one that used in real life.
I suggest to call the super.onGotResponse to get the response object and then assert it in case of erroneous response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

done

// set configuration
config = new Configuration();
config.setEndpoint(API_BASE_URL + "/" + API_URL_VERSION);
config.setAcceptGzipEncoding(false);

Choose a reason for hiding this comment

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

I believe that at least some tests should run with gzip enabled, both for JSON and XML and other serve actions in other response formats, it should be tested as well.


public static Client getClient(String ks) {
Client client = new Client(config);
client.setApiVersion(API_REQUEST_VERSION);

Choose a reason for hiding this comment

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

This should never be set, the hard-coded generated API version should be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tan-tan-kanarek Not sure what do you mean? can you please elaborate?

Choose a reason for hiding this comment

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

The API version is already part of the generated client and contains the exact version of the server that this client was generated from, if you change it to older version you miss all the new features that this lib offers, if you change it to higher version some features in the lib won't be supported by the server.
You better not touch it.

Client client = getClient(null);

if (sharedHousehold == null) {
sharedHousehold = createHouseHold(2, 2, true);

Choose a reason for hiding this comment

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

Please try to avoid hard-coded numbers.

return sharedHousehold;
}

public static String getsharedMasterUserKs() {

Choose a reason for hiding this comment

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

Please note to coding standard, the S must be capitalized.
Also, would be nice to have a comment that explain the meaning of shared user vs. non-shared one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Regarding the shared parameters they are used as global resources which needed in multiple scenarios. Also:

// shared ks's
private static String administratorKs, operatorKs, managerKs, anonymousKs;

// shared VOD
private static MediaAsset mediaAsset;

Choose a reason for hiding this comment

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

Please add a comment in the code when and what they're used for.

public class Sandbox extends BaseTest {

@Test(enabled = false)
private void test() {

Choose a reason for hiding this comment

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

Inline explanation should describe the purpose of this class and its methods, it's not clear when or why it's used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just sandbox place for debug purposes. No functionality. I can add it to git ignore if you would like.

Choose a reason for hiding this comment

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

If it serves the tests, keep it in git and add comment that explains it, otherwise, remove it.


import static com.kaltura.client.test.Properties.*;

public class DBUtils extends BaseUtils {

Choose a reason for hiding this comment

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

I believe that this class may grow into gigantic size with time, please consider to split it to class per object type, e.g. EpgChannelDbUtils.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

alonbasin-kaltura and others added 30 commits September 26, 2018 14:42
# Conflicts:
#	src/main/java/com/kaltura/client/Client.java
added more tests for inheritance checking
# Conflicts:
#	src/test/java/com/kaltura/client/test/tests/featuresTests/versions/five_zero_two/IngestVodOpcTests.java
# Conflicts:
#	src/main/java/com/kaltura/client/Client.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants