Skip to content

Commit

Permalink
test(uat): log rotation with minimum log level setting
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo committed Nov 16, 2023
1 parent ad0abce commit 212328c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public long totalSizeInBytes() {
public boolean hasExceededDiskUsage() {
return this.maxBytes
.map((val) -> this.totalSizeInBytes() > val)
.orElseGet(() -> false);
.orElse(false);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion uat/codebuild/uat_linux_buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ phases:
- mvn -U -ntp verify -DskipTests=true
- mvn -U -ntp clean verify -f uat/pom.xml
- java -Dggc.archive=/tmp/greengrass-nucleus-latest.zip
-Dtags='LogManager&!unstable' -Dggc.install.root=$CODEBUILD_SRC_DIR -Dggc.log.level=INFO -Daws.region=us-west-2
-Dtags='MyTest&LogManager&!unstable' -Dggc.install.root=$CODEBUILD_SRC_DIR -Dggc.log.level=INFO -Daws.region=us-west-2
-jar uat/testing-features/target/greengrass-log-manager-testing-features.jar

artifacts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ private static List<String> generateRandomMessages(int n, int length) {
List<String> msgs = new ArrayList<>();
for (int i = 0; i < n; i++) {
// TODO: Improves this as this is not how the logger writes the logs
msgs.add(RANDOM_STRING_GENERATOR.generate(length));
String message = RANDOM_STRING_GENERATOR.generate(length);
msgs.add("{\"level\": \"INFO\", \"message\": \"" + message + "\"}");
}
return msgs;
}
Expand Down Expand Up @@ -168,4 +169,4 @@ public void verifyActiveFile(String componentName, String directoryAlias) {
List<File> sortedFileList = getComponentLogFiles(componentName, logsDirectory);
assertEquals(1, sortedFileList.size());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ Feature: Greengrass V2 LogManager
And I verify 100 logs for UserComponentX of type UserComponent have been uploaded to Cloudwatch within 120 seconds
And I verify the rotated files are deleted and that the active log file is present for component UserComponentX on directory UserComponentXLogDirectory

@MyTest
Scenario: LogManager-1-T3: As a customer I can configure the logs uploader to delete log oldest log files to keep the
disk space limit specified on the configuration
Given 10 temporary rotated log files for component UserComponentB have been created
Given 15 temporary rotated log files for component UserComponentB have been created
And 5 temporary rotated log files for component aws.greengrass.Nucleus have been created
And 5 temporary rotated log files for component UserComponentA have been created
Given I create a Greengrass deployment with components
Expand All @@ -166,7 +167,10 @@ Feature: Greengrass V2 LogManager
"logFileRegex": "UserComponentB_(.)+.log",
"logFileDirectoryPath": "${UserComponentBLogDirectory}",
"diskSpaceLimit":"100",
"diskSpaceLimitUnit":"KB"
"diskSpaceLimitUnit":"KB",
"minimumLogLevel": "INFO",
"uploadToCloudWatch": "true",
"deleteLogFileAfterCloudUpload": "false"
}
},
"systemLogsConfiguration": {
Expand All @@ -177,15 +181,15 @@ Feature: Greengrass V2 LogManager
"deleteLogFileAfterCloudUpload": "true"
}
},
"periodicUploadIntervalSec": "500"
"periodicUploadIntervalSec": "0.1"
}
}
"""
And I deploy the Greengrass deployment configuration
Then the Greengrass deployment is COMPLETED on the device after 3 minutes
Then I verify the aws.greengrass.LogManager component is RUNNING using the greengrass-cli
And I wait 5 seconds
Then I verify that 10 log files for component UserComponentB are still available
Then I verify that 15 log files for component UserComponentB are still available

@network
Scenario: LogManager-1-T4: As a developer, logs uploader will handle network interruptions gracefully and upload logs from the last uploaded log after network resumes
Expand Down

0 comments on commit 212328c

Please sign in to comment.