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

sequencer tests for sample rate #518

Merged
merged 30 commits into from
Jan 16, 2023
Merged

Conversation

noursaidi
Copy link
Collaborator

@noursaidi noursaidi commented Nov 23, 2022

Sequence test for changable sample rate (sample_rate_sec) and changable publish interval (change both sample_rate and sample_limit)

Status for invalid sample rates will follow in a new PR

@noursaidi noursaidi marked this pull request as ready for review December 1, 2022 15:53
@noursaidi noursaidi requested review from grafnu and removed request for grafnu December 1, 2022 15:53
@@ -14,6 +14,11 @@ GOLDEN_FILE=etc/test_itemized.out
rm -f $RESULTS_OUT $SEQUENCER_OUT $PUBBER_OUT
touch $RESULTS_OUT $SEQUENCER_OUT $PUBBER_OUT

#pubber/bin/build
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't leave dead code

Copy link
Collaborator Author

@noursaidi noursaidi Dec 1, 2022

Choose a reason for hiding this comment

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

Accidental, was meant to be uncommented, thanks

updateDiscoveryConfig(config.discovery);
extractEndpointBlobConfig();
} else {
info(getTimestamp() + " defaulting empty config");
actualInterval = DEFAULT_REPORT_SEC * 1000;
}
if (configuration.options.fixedSampleRate != null) {
actualInterval = configuration.options.fixedSampleRate * 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

a better coding style is to avoid mutable variables, and instead intoruce a new variable with the new maning, eith.

useInterval = configuration.options.fixedSampleRate == null ? actualInterval : configuration.options.fixedSampleRate * 1000

In the big picture it makes the code more readable because you don't need to keep track of when a variable might change. Mutable variables are only really necessary in loops, etc... (and this is why the variable was initially indicated as final, which forces that it's written ones, and exactly once)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the feedback, changed as recommended

@@ -82,7 +82,7 @@ public abstract class SequenceBase {
public static final String EVENT_PREFIX = "event_";
public static final String SYSTEM_EVENT_MESSAGE_BASE = "event_system";
public static final int CONFIG_UPDATE_DELAY_MS = 2000;
public static final int NORM_TIMEOUT_MS = 120 * 1000;
public static final int NORM_TIMEOUT_MS = 300 * 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change still necessary? I'm worried about this because it starts to drastically increase the overall time. Is this because the new tests that you added have longer times to them but there's no way to individually specify an increased timeout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test needed a longer time to run, but the global timeout overrides the test level timeout. So I increased the overall time, then put a timeout on every test to keep the time low

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, I hate this logic but it's not your fault! It should be the other way around... default is shorter and then if you want longer it's a special case!

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Nothing needs to change here, I'm just ranting)

@@ -32,7 +40,7 @@ public void system_last_update() {
});
}

@Test
@Test(timeout = 120000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why special-case the shorter time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As above, increased the global timeout so I can have a longer test, and then reinstated the shorter timeout on all the other tests

* Tests both sample_rate_sec and sample_limit_sec by defining two non-intersecting narrow
* ranges of both parameters, and ensuring telemetry is within this range.
*/
@Test(timeout = 240000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to make the 240000 a NAMED_CONSTANT_MS? I'm not sure syntactically if it's allowed, but would help readability overall!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it works, added a class of constants e.g. FOUR_MINUTES_MS. Let me know that needs changing

@noursaidi noursaidi requested a review from grafnu December 2, 2022 14:24
@@ -859,19 +859,22 @@ private void configHandler(Config config) {

private void processConfigUpdate(Config config) {
final int actualInterval;
final int useInterval;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can declare at point of use in this case since there is no branch involved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed

final int actualInterval;
boolean hasSampleRate = pointsetConfig != null && pointsetConfig.sample_rate_sec != null;
boolean hasSampleLimit = pointsetConfig != null && pointsetConfig.sample_limit_sec != null;
//if(hasSampleRate && hasSampleLimit && pointsetConfig.sample_rate_sec < )
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

accidentally committed, removed

@@ -82,7 +82,7 @@ public abstract class SequenceBase {
public static final String EVENT_PREFIX = "event_";
public static final String SYSTEM_EVENT_MESSAGE_BASE = "event_system";
public static final int CONFIG_UPDATE_DELAY_MS = 2000;
public static final int NORM_TIMEOUT_MS = 120 * 1000;
public static final int NORM_TIMEOUT_MS = 300 * 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, I hate this logic but it's not your fault! It should be the other way around... default is shorter and then if you want longer it's a special case!

@noursaidi noursaidi requested a review from grafnu December 5, 2022 13:17
@grafnu grafnu closed this Jan 11, 2023
@grafnu
Copy link
Collaborator

grafnu commented Jan 11, 2023

Closing for now since it seems stale. Please re-open when it's ready to address again.

@noursaidi noursaidi reopened this Jan 13, 2023
@noursaidi noursaidi merged commit 0f13ffb into faucetsdn:master Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants