Search in sources :

Example 1 with UFLoggingConfig

use of bio.terra.cli.serialization.userfacing.UFLoggingConfig in project terra-cli by DataBiosphere.

the class Config method getValueList.

@Test
@DisplayName("config get and list always match")
void getValueList() throws IOException {
    // toggle each config value and make sure config get and list always match.
    // server and workspace config properties are not included here because they are covered by
    // tests above.
    // `terra config set browser MANUAL`
    TestCommand.runCommandExpectSuccess("config", "set", "browser", "MANUAL");
    // `terra config get browser`
    BrowserLaunchOption browser = TestCommand.runAndParseCommandExpectSuccess(BrowserLaunchOption.class, "config", "get", "browser");
    assertEquals(BrowserLaunchOption.MANUAL, browser, "get reflects set for browser");
    // `terra config list`
    UFConfig config = TestCommand.runAndParseCommandExpectSuccess(UFConfig.class, "config", "list");
    assertEquals(BrowserLaunchOption.MANUAL, config.browserLaunchOption, "list reflects set for browser");
    // `terra config set app-launch LOCAL_PROCESS`
    TestCommand.runCommandExpectSuccess("config", "set", "app-launch", "LOCAL_PROCESS");
    // `terra config get app-launch`
    CommandRunnerOption appLaunch = TestCommand.runAndParseCommandExpectSuccess(CommandRunnerOption.class, "config", "get", "app-launch");
    assertEquals(CommandRunnerOption.LOCAL_PROCESS, appLaunch, "get reflects set for app-launch");
    // `terra config list`
    config = TestCommand.runAndParseCommandExpectSuccess(UFConfig.class, "config", "list");
    assertEquals(CommandRunnerOption.LOCAL_PROCESS, config.commandRunnerOption, "list reflects set for app-launch");
    // `terra config set image --image=badimageid123`
    String imageId = "badimageid123";
    TestCommand.runCommandExpectSuccess("config", "set", "image", "--image=" + imageId);
    // `terra config get image`
    String image = TestCommand.runAndParseCommandExpectSuccess(String.class, "config", "get", "image");
    assertEquals(imageId, image, "get reflects set for image");
    // `terra config list`
    config = TestCommand.runAndParseCommandExpectSuccess(UFConfig.class, "config", "list");
    assertEquals(imageId, config.dockerImageId, "list reflects set for image");
    // `terra config set resource-limit --max=3`
    TestCommand.runCommandExpectSuccess("config", "set", "resource-limit", "--max=3");
    // `terra config get resource-limit`
    int resourceLimit = TestCommand.runAndParseCommandExpectSuccess(Integer.class, "config", "get", "resource-limit");
    assertEquals(3, resourceLimit, "get reflects set for resource-limit");
    // `terra config list`
    config = TestCommand.runAndParseCommandExpectSuccess(UFConfig.class, "config", "list");
    assertEquals(3, config.resourcesCacheSize, "list reflects set for resource-limit");
    // `terra config set logging --console --level=ERROR`
    TestCommand.runCommandExpectSuccess("config", "set", "logging", "--console", "--level=ERROR");
    // `terra config set logging --file --level=TRACE`
    TestCommand.runCommandExpectSuccess("config", "set", "logging", "--file", "--level=TRACE");
    // `terra config get logging`
    UFLoggingConfig logging = TestCommand.runAndParseCommandExpectSuccess(UFLoggingConfig.class, "config", "get", "logging");
    assertEquals(Logger.LogLevel.ERROR, logging.consoleLoggingLevel, "get reflects set for console logging");
    assertEquals(Logger.LogLevel.TRACE, logging.fileLoggingLevel, "get reflects set for file logging");
    // `terra config list`
    config = TestCommand.runAndParseCommandExpectSuccess(UFConfig.class, "config", "list");
    assertEquals(Logger.LogLevel.ERROR, config.consoleLoggingLevel, "list reflects set for console logging");
    assertEquals(Logger.LogLevel.TRACE, config.fileLoggingLevel, "list reflects set for file logging");
}
Also used : CommandRunnerOption(bio.terra.cli.businessobject.Config.CommandRunnerOption) UFLoggingConfig(bio.terra.cli.serialization.userfacing.UFLoggingConfig) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BrowserLaunchOption(bio.terra.cli.businessobject.Config.BrowserLaunchOption) UFConfig(bio.terra.cli.serialization.userfacing.UFConfig) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with UFLoggingConfig

use of bio.terra.cli.serialization.userfacing.UFLoggingConfig in project terra-cli by DataBiosphere.

the class Logging method execute.

/**
 * Return the logging level properties of the global context.
 */
@Override
protected void execute() {
    UFLoggingConfig loggingLevels = new UFLoggingConfig.Builder().consoleLoggingLevel(Context.getConfig().getConsoleLoggingLevel()).fileLoggingLevel(Context.getConfig().getFileLoggingLevel()).build();
    formatOption.printReturnValue(loggingLevels, Logging::printText);
}
Also used : UFLoggingConfig(bio.terra.cli.serialization.userfacing.UFLoggingConfig)

Aggregations

UFLoggingConfig (bio.terra.cli.serialization.userfacing.UFLoggingConfig)2 BrowserLaunchOption (bio.terra.cli.businessobject.Config.BrowserLaunchOption)1 CommandRunnerOption (bio.terra.cli.businessobject.Config.CommandRunnerOption)1 UFConfig (bio.terra.cli.serialization.userfacing.UFConfig)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1