package com.atlassian.bitbucket.mesh.test.cluster;

import org.slf4j.event.Level;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation that can be used on test classes and/or methods which needs a cluster of Mesh nodes to be
 * provisioned and configured.
 *
 * @see MeshClusterTestExecutionListener
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface MeshCluster {

    /**
     * Configures whether Mesh nodes require provisioning and authentication or not. By default, authentication is
     * not enabled because it makes the {@link MeshControlPlane} easier to implement. It should only be enabled if
     * the control plane in use supports it.
     *
     * @return {@code true} if the cluster nodes should require provisioning and authentication; otherwise,
     *         {@code false} to run nodes with authentication disabled
     */
    boolean authenticationEnabled() default false;

    /**
     * Configures log forwarding from the provisioned nodes to stdout.
     *
     * @return the minimum log level that should be forwarded
     */
    Level logLevel() default Level.WARN;

    /**
     * @return the number of shards per node to provision
     */
    int shardsPerNode() default 1;

    /**
     * @return the number of nodes in the cluster
     */
    int size() default -1;

    /**
     * This is an alias for {@link #size()}. If both {@code value} and {@code size} are defined, {@code size} wins.
     *
     * @return the number of nodes in the cluster
     */
    int value() default 3;
}
