mirror of https://github.com/dapr/cli.git
Merge pull request #1212 from mukundansundar/merge_rel_1.10
partial merge rel 1.10
This commit is contained in:
commit
c1c0ff5193
|
@ -51,11 +51,11 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GOVER: 1.19.3
|
||||
DAPR_RUNTIME_PINNED_VERSION: 1.9.4
|
||||
DAPR_RUNTIME_PINNED_VERSION: 1.10.0-rc.4
|
||||
DAPR_DASHBOARD_PINNED_VERSION: 0.11.0
|
||||
DAPR_RUNTIME_LATEST_VERSION:
|
||||
DAPR_DASHBOARD_LATEST_VERSION:
|
||||
DAPR_TGZ: dapr-1.9.4.tgz
|
||||
DAPR_RUNTIME_LATEST_STABLE_VERSION:
|
||||
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
|
||||
DAPR_TGZ: dapr-1.10.0-rc.4.tgz
|
||||
strategy:
|
||||
fail-fast: false # Keep running if one leg fails.
|
||||
matrix:
|
||||
|
@ -131,37 +131,39 @@ jobs:
|
|||
- name: Free up some diskspace
|
||||
run: |
|
||||
docker image prune -a -f
|
||||
- name: Determine latest stable Dapr Runtime version
|
||||
- name: Determine latest Dapr Runtime version including Pre-releases
|
||||
if: github.base_ref == 'master'
|
||||
run: |
|
||||
export RUNTIME_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dapr/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
export RUNTIME_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dapr/releases | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
if [[ -z "$RUNTIME_VERSION" ]]; then
|
||||
echo "Could not fetch the latest Dapr Runtime version. Using default version $DAPR_RUNTIME_PINNED_VERSION"
|
||||
echo "DAPR_RUNTIME_LATEST_VERSION=$DAPR_RUNTIME_PINNED_VERSION" >> $GITHUB_ENV
|
||||
echo "Could not fetch the latest Dapr Runtime version. Using pinned version $DAPR_RUNTIME_PINNED_VERSION"
|
||||
else
|
||||
echo "Found $RUNTIME_VERSION"
|
||||
echo "DAPR_RUNTIME_LATEST_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
base_ref=${{ github.base_ref }}
|
||||
echo "Branch $base_ref"
|
||||
if [[ $base_ref = 'master' ]]; then
|
||||
echo "DAPR_RUNTIME_PINNED_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
echo "DAPR_RUNTIME_PINNED_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Determine latest Dapr Dashboard version including Pre-releases
|
||||
if: github.base_ref == 'master'
|
||||
run: |
|
||||
export DASHBOARD_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dashboard/releases | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
if [[ -z "$DASHBOARD_VERSION" ]]; then
|
||||
echo "Could not fetch the latest Dapr Dashboard version. Using pinned version $DAPR_DASHBOARD_PINNED_VERSION"
|
||||
else
|
||||
echo "Found $DASHBOARD_VERSION"
|
||||
echo "DAPR_DASHBOARD_PINNED_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Determine latest stable Dapr Runtime version
|
||||
run: |
|
||||
export LATEST_STABLE_RUNTIME_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dapr/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
echo "Found $LATEST_STABLE_RUNTIME_VERSION"
|
||||
echo "DAPR_RUNTIME_LATEST_STABLE_VERSION=$LATEST_STABLE_RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
- name: Determine latest stable Dapr Dashboard version
|
||||
run: |
|
||||
export DASHBOARD_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dashboard/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
if [[ -z "$DASHBOARD_VERSION" ]]; then
|
||||
echo "Could not fetch the latest Dapr Dashboard version. Using default version $DAPR_DASHBOARD_PINNED_VERSION"
|
||||
echo "DAPR_DASHBOARD_LATEST_VERSION=$DAPR_DASHBOARD_PINNED_VERSION" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Found $DASHBOARD_VERSION"
|
||||
echo "DAPR_DASHBOARD_LATEST_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
base_ref=${{ github.base_ref }}
|
||||
echo "Branch $base_ref"
|
||||
if [[ $base_ref = 'master' ]]; then
|
||||
echo "DAPR_DASHBOARD_PINNED_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
export LATEST_STABLE_DASHBOARD_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dashboard/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
echo "Found $LATEST_STABLE_DASHBOARD_VERSION"
|
||||
echo "DAPR_DASHBOARD_LATEST_STABLE_VERSION=$LATEST_STABLE_DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
- name: Run tests with GHCR
|
||||
# runs every 6hrs
|
||||
|
|
|
@ -40,10 +40,10 @@ jobs:
|
|||
GOARCH: ${{ matrix.target_arch }}
|
||||
GOPROXY: https://proxy.golang.org
|
||||
ARCHIVE_OUTDIR: dist/archives
|
||||
DAPR_RUNTIME_PINNED_VERSION: "1.9.4"
|
||||
DAPR_RUNTIME_PINNED_VERSION: "1.10.0-rc.4"
|
||||
DAPR_DASHBOARD_PINNED_VERSION: 0.11.0
|
||||
DAPR_RUNTIME_LATEST_VERSION:
|
||||
DAPR_DASHBOARD_LATEST_VERSION:
|
||||
DAPR_RUNTIME_LATEST_STABLE_VERSION:
|
||||
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
@ -78,41 +78,43 @@ jobs:
|
|||
podman machine init
|
||||
podman machine start
|
||||
echo "CONTAINER_RUNTIME=podman" >> $GITHUB_ENV
|
||||
- name: Determine latest stable Dapr Runtime version
|
||||
- name: Determine latest Dapr Runtime version including Pre-releases
|
||||
if: github.base_ref == 'master'
|
||||
run: |
|
||||
export RUNTIME_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dapr/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
export RUNTIME_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dapr/releases | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
if [[ -z "$RUNTIME_VERSION" ]]; then
|
||||
echo "Could not fetch the latest Dapr Runtime version. Using default version $DAPR_RUNTIME_PINNED_VERSION"
|
||||
echo "DAPR_RUNTIME_LATEST_VERSION=$DAPR_RUNTIME_PINNED_VERSION" >> $GITHUB_ENV
|
||||
echo "Could not fetch the latest Dapr Runtime version. Using pinned version $DAPR_RUNTIME_PINNED_VERSION"
|
||||
else
|
||||
echo "Found $RUNTIME_VERSION"
|
||||
echo "DAPR_RUNTIME_LATEST_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
base_ref=${{ github.base_ref }}
|
||||
echo "Branch $base_ref"
|
||||
if [[ $base_ref = 'master' ]]; then
|
||||
echo "DAPR_RUNTIME_PINNED_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
echo "DAPR_RUNTIME_PINNED_VERSION=$RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Determine latest Dapr Dashboard version including Pre-releases
|
||||
if: github.base_ref == 'master'
|
||||
run: |
|
||||
export DASHBOARD_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dashboard/releases | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
if [[ -z "$DASHBOARD_VERSION" ]]; then
|
||||
echo "Could not fetch the latest Dapr Dashboard version. Using pinned version $DAPR_DASHBOARD_PINNED_VERSION"
|
||||
else
|
||||
echo "Found $DASHBOARD_VERSION"
|
||||
echo "DAPR_DASHBOARD_PINNED_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Determine latest stable Dapr Runtime version
|
||||
run: |
|
||||
export LATEST_STABLE_RUNTIME_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dapr/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
echo "Found $LATEST_STABLE_RUNTIME_VERSION"
|
||||
echo "DAPR_RUNTIME_LATEST_STABLE_VERSION=$LATEST_STABLE_RUNTIME_VERSION" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
- name: Determine latest stable Dapr Dashboard version
|
||||
run: |
|
||||
export DASHBOARD_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dashboard/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
if [[ -z "$DASHBOARD_VERSION" ]]; then
|
||||
echo "Could not fetch the latest Dapr Dashboard version. Using default version $DAPR_DASHBOARD_PINNED_VERSION"
|
||||
echo "DAPR_DASHBOARD_LATEST_VERSION=$DAPR_DASHBOARD_PINNED_VERSION" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Found $DASHBOARD_VERSION"
|
||||
echo "DAPR_DASHBOARD_LATEST_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
base_ref=${{ github.base_ref }}
|
||||
echo "Branch $base_ref"
|
||||
if [[ $base_ref = 'master' ]]; then
|
||||
echo "DAPR_DASHBOARD_PINNED_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
export LATEST_STABLE_DASHBOARD_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/dapr/dashboard/releases/latest | grep tag_name | awk -F':' '{print $2}' | tr -d '", ' | sed '/-/! s/$/_/' | sort -V | sed 's/_$//' | tr -d 'v' | tail -1)
|
||||
echo "Found $LATEST_STABLE_DASHBOARD_VERSION"
|
||||
echo "DAPR_DASHBOARD_LATEST_STABLE_VERSION=$LATEST_STABLE_DASHBOARD_VERSION" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
- name: Set the test timeout - MacOS
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: echo "E2E_SH_TEST_TIMEOUT=20m" >> $GITHUB_ENV
|
||||
run: echo "E2E_SH_TEST_TIMEOUT=30m" >> $GITHUB_ENV
|
||||
- name: Run E2E tests with GHCR
|
||||
# runs every 6hrs
|
||||
if: github.event.schedule == '0 */6 * * *'
|
||||
|
|
|
@ -31,7 +31,7 @@ var BuildInfoCmd = &cobra.Command{
|
|||
dapr build-info
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
out, err := standalone.GetBuildInfo(daprPath, RootCmd.Version)
|
||||
out, err := standalone.GetBuildInfo(daprRuntimePath, cliVersion)
|
||||
if err != nil {
|
||||
print.FailureStatusEvent(os.Stderr, "Error getting build info: %s", err.Error())
|
||||
os.Exit(1)
|
||||
|
|
53
cmd/dapr.go
53
cmd/dapr.go
|
@ -30,15 +30,20 @@ var RootCmd = &cobra.Command{
|
|||
Use: "dapr",
|
||||
Short: "Dapr CLI",
|
||||
Long: `
|
||||
__
|
||||
__
|
||||
____/ /___ _____ _____
|
||||
/ __ / __ '/ __ \/ ___/
|
||||
/ /_/ / /_/ / /_/ / /
|
||||
\__,_/\__,_/ .___/_/
|
||||
/_/
|
||||
|
||||
/ /_/ / /_/ / /_/ / /
|
||||
\__,_/\__,_/ .___/_/
|
||||
/_/
|
||||
|
||||
===============================
|
||||
Distributed Application Runtime`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if versionFlag {
|
||||
printVersion()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
type daprVersion struct {
|
||||
|
@ -53,43 +58,44 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
daprVer daprVersion
|
||||
logAsJSON bool
|
||||
daprPath string
|
||||
cliVersion string
|
||||
versionFlag bool
|
||||
daprVer daprVersion
|
||||
logAsJSON bool
|
||||
daprRuntimePath string
|
||||
)
|
||||
|
||||
// Execute adds all child commands to the root command.
|
||||
func Execute(version, apiVersion string) {
|
||||
RootCmd.Version = version
|
||||
// Need to be set here as it is accessed in initConfig.
|
||||
cliVersion = version
|
||||
api.RuntimeAPIVersion = apiVersion
|
||||
|
||||
// err intentionally ignored since daprd may not yet be installed.
|
||||
runtimeVer, _ := standalone.GetRuntimeVersion(daprPath)
|
||||
|
||||
daprVer = daprVersion{
|
||||
CliVersion: version,
|
||||
RuntimeVersion: strings.ReplaceAll(runtimeVer, "\n", ""),
|
||||
}
|
||||
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
setVersion()
|
||||
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
func setVersion() {
|
||||
template := fmt.Sprintf(cliVersionTemplateString, daprVer.CliVersion, daprVer.RuntimeVersion)
|
||||
RootCmd.SetVersionTemplate(template)
|
||||
func printVersion() {
|
||||
fmt.Printf(cliVersionTemplateString, daprVer.CliVersion, daprVer.RuntimeVersion)
|
||||
}
|
||||
|
||||
// Function is called as a preRun initializer for each command executed.
|
||||
func initConfig() {
|
||||
if logAsJSON {
|
||||
print.EnableJSONFormat()
|
||||
}
|
||||
// err intentionally ignored since daprd may not yet be installed.
|
||||
runtimeVer, _ := standalone.GetRuntimeVersion(daprRuntimePath)
|
||||
|
||||
daprVer = daprVersion{
|
||||
// Set in Execute() method in this file before initConfig() is called by cmd.Execute().
|
||||
CliVersion: cliVersion,
|
||||
RuntimeVersion: strings.ReplaceAll(runtimeVer, "\n", ""),
|
||||
}
|
||||
|
||||
viper.SetEnvPrefix("dapr")
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
|
@ -97,6 +103,7 @@ func initConfig() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.PersistentFlags().StringVarP(&daprPath, "dapr-path", "", "", "The path to the dapr installation directory")
|
||||
RootCmd.Flags().BoolVarP(&versionFlag, "version", "v", false, "version for dapr")
|
||||
RootCmd.PersistentFlags().StringVarP(&daprRuntimePath, "runtime-path", "", "", "The path to the dapr runtime installation directory")
|
||||
RootCmd.PersistentFlags().BoolVarP(&logAsJSON, "log-as-json", "", false, "Log output in JSON format")
|
||||
}
|
||||
|
|
|
@ -62,14 +62,14 @@ var DashboardCmd = &cobra.Command{
|
|||
# Start dashboard locally
|
||||
dapr dashboard
|
||||
|
||||
# Start dashboard locally in a specified port
|
||||
# Start dashboard locally in a specified port
|
||||
dapr dashboard -p 9999
|
||||
|
||||
# Start dashboard locally on a random port which is free.
|
||||
dapr dashboard -p 0
|
||||
|
||||
# Port forward to dashboard in Kubernetes
|
||||
dapr dashboard -k
|
||||
# Port forward to dashboard in Kubernetes
|
||||
dapr dashboard -k
|
||||
|
||||
# Port forward to dashboard in Kubernetes on all addresses in a specified port
|
||||
dapr dashboard -k -p 9999 -a 0.0.0.0
|
||||
|
@ -82,7 +82,7 @@ dapr dashboard -k -p 0
|
|||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if dashboardVersionCmd {
|
||||
dashboardVer, err := standalone.GetDashboardVersion(daprPath)
|
||||
dashboardVer, err := standalone.GetDashboardVersion(daprRuntimePath)
|
||||
if err != nil {
|
||||
print.FailureStatusEvent(os.Stderr, "Failed to get Dapr install directory: %v", err)
|
||||
os.Exit(1)
|
||||
|
@ -194,7 +194,7 @@ dapr dashboard -k -p 0
|
|||
<-portForward.GetStop()
|
||||
} else {
|
||||
// Standalone mode.
|
||||
dashboardCmd, err := standalone.NewDashboardCmd(daprPath, dashboardLocalPort)
|
||||
dashboardCmd, err := standalone.NewDashboardCmd(daprRuntimePath, dashboardLocalPort)
|
||||
if err != nil {
|
||||
print.FailureStatusEvent(os.Stderr, "Failed to get Dapr install directory: %v", err)
|
||||
} else {
|
||||
|
|
13
cmd/init.go
13
cmd/init.go
|
@ -57,7 +57,7 @@ var InitCmd = &cobra.Command{
|
|||
dapr init
|
||||
|
||||
# Initialize Dapr in self-hosted mode with a provided docker image registry. Image looked up as <registry-url>/<image>.
|
||||
# Check docs or README for more information on the format of the image path that is required.
|
||||
# Check docs or README for more information on the format of the image path that is required.
|
||||
dapr init --image-registry <registry-url>
|
||||
|
||||
# Initialize Dapr in Kubernetes
|
||||
|
@ -81,8 +81,9 @@ dapr init --from-dir <path-to-directory>
|
|||
# Initialize dapr with a particular image variant. Allowed values: "mariner"
|
||||
dapr init --image-variant <variant>
|
||||
|
||||
# Initialize Dapr to non-default install directory (default is $HOME/.dapr)
|
||||
dapr init --dapr-path <path-to-install-directory>
|
||||
# Initialize Dapr inside a ".dapr" directory present in a non-default location
|
||||
# Folder .dapr will be created in folder pointed to by <path-to-install-directory>
|
||||
dapr init --runtime-path <path-to-install-directory>
|
||||
|
||||
# See more at: https://docs.dapr.io/getting-started/
|
||||
`,
|
||||
|
@ -95,8 +96,8 @@ dapr init --dapr-path <path-to-install-directory>
|
|||
imageRegistryURI := ""
|
||||
var err error
|
||||
|
||||
if len(strings.TrimSpace(daprPath)) != 0 {
|
||||
print.FailureStatusEvent(os.Stderr, "--dapr-path is only valid for self-hosted mode")
|
||||
if len(strings.TrimSpace(daprRuntimePath)) != 0 {
|
||||
print.FailureStatusEvent(os.Stderr, "--runtime-path is only valid for self-hosted mode")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
@ -150,7 +151,7 @@ dapr init --dapr-path <path-to-install-directory>
|
|||
print.FailureStatusEvent(os.Stdout, "Invalid container runtime. Supported values are docker and podman.")
|
||||
os.Exit(1)
|
||||
}
|
||||
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRegistryURI, fromDir, containerRuntime, imageVariant, daprPath)
|
||||
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRegistryURI, fromDir, containerRuntime, imageVariant, daprRuntimePath)
|
||||
if err != nil {
|
||||
print.FailureStatusEvent(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
|
|
30
cmd/run.go
30
cmd/run.go
|
@ -93,7 +93,7 @@ dapr run --app-id myapp
|
|||
dapr run --app-id myapp --app-port 3000 --app-protocol grpc -- go run main.go
|
||||
|
||||
# Run sidecar only specifying dapr runtime installation directory
|
||||
dapr run --app-id myapp --dapr-path /usr/local/dapr
|
||||
dapr run --app-id myapp --runtime-path /usr/local/dapr
|
||||
|
||||
# Run multiple apps by providing path of a run config file
|
||||
dapr run --run-file dapr.yaml
|
||||
|
@ -123,7 +123,7 @@ dapr run --run-file /path/to/directory
|
|||
fmt.Println(print.WhiteBold("WARNING: no application command found."))
|
||||
}
|
||||
|
||||
daprDirPath, err := standalone.GetDaprPath(daprPath)
|
||||
daprDirPath, err := standalone.GetDaprRuntimePath(daprRuntimePath)
|
||||
if err != nil {
|
||||
print.FailureStatusEvent(os.Stderr, "Failed to get Dapr install directory: %v", err)
|
||||
os.Exit(1)
|
||||
|
@ -171,7 +171,7 @@ dapr run --run-file /path/to/directory
|
|||
AppHealthThreshold: appHealthThreshold,
|
||||
EnableAPILogging: enableAPILogging,
|
||||
APIListenAddresses: apiListenAddresses,
|
||||
DaprdInstallPath: daprPath,
|
||||
DaprdInstallPath: daprRuntimePath,
|
||||
}
|
||||
output, err := runExec.NewOutput(&standalone.RunConfig{
|
||||
AppID: appID,
|
||||
|
@ -360,6 +360,14 @@ dapr run --run-file /path/to/directory
|
|||
}
|
||||
|
||||
if output.AppCMD != nil {
|
||||
if output.AppCMD.Process != nil {
|
||||
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Updating metadata for appPID: %d", output.AppCMD.Process.Pid))
|
||||
err = metadata.Put(output.DaprHTTPPort, "appPID", strconv.Itoa(output.AppCMD.Process.Pid), appID, unixDomainSocket)
|
||||
if err != nil {
|
||||
print.WarningStatusEvent(os.Stdout, "Could not update sidecar metadata for appPID: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
appCommand := strings.Join(args, " ")
|
||||
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Updating metadata for app command: %s", appCommand))
|
||||
err = metadata.Put(output.DaprHTTPPort, "appCommand", appCommand, appID, unixDomainSocket)
|
||||
|
@ -464,6 +472,8 @@ func executeRun(runFilePath string, apps []runfileconfig.App) (bool, error) {
|
|||
// This is done to provide a better grouping, which can be used to control all the proceses started by "dapr run -f".
|
||||
daprsyscall.CreateProcessGroupID()
|
||||
|
||||
print.WarningStatusEvent(os.Stdout, "This is a preview feature and subject to change in future releases.")
|
||||
|
||||
for _, app := range apps {
|
||||
print.StatusEvent(os.Stdout, print.LogInfo, "Validating config and starting app %q", app.RunConfig.AppID)
|
||||
// Set defaults if zero value provided in config yaml.
|
||||
|
@ -524,7 +534,12 @@ func executeRun(runFilePath string, apps []runfileconfig.App) (bool, error) {
|
|||
|
||||
if runState.AppCMD.Command != nil {
|
||||
putAppCommandInMeta(runConfig, runState)
|
||||
|
||||
if runState.AppCMD.Command.Process != nil {
|
||||
putAppProcessIDInMeta(runState)
|
||||
}
|
||||
}
|
||||
|
||||
print.StatusEvent(runState.DaprCMD.OutputWriter, print.LogSuccess, "You're up and running! Dapr logs will appear here.\n")
|
||||
logInformationalStatusToStdout(app)
|
||||
}
|
||||
|
@ -905,6 +920,14 @@ func putCLIProcessIDInMeta(runE *runExec.RunExec, pid int) {
|
|||
}
|
||||
}
|
||||
|
||||
func putAppProcessIDInMeta(runE *runExec.RunExec) {
|
||||
print.StatusEvent(runE.DaprCMD.OutputWriter, print.LogInfo, "Updating metadata for appPID: %d", runE.AppCMD.Command.Process.Pid)
|
||||
err := metadata.Put(runE.DaprHTTPPort, "appPID", strconv.Itoa(runE.AppCMD.Command.Process.Pid), runE.AppID, unixDomainSocket)
|
||||
if err != nil {
|
||||
print.StatusEvent(runE.DaprCMD.OutputWriter, print.LogWarning, "Could not update sidecar metadata for appPID: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// putAppCommandInMeta puts the app command in metadata so that it can be used by the CLI to stop the app.
|
||||
func putAppCommandInMeta(runConfig standalone.RunConfig, runE *runExec.RunExec) {
|
||||
appCommand := strings.Join(runConfig.Command, " ")
|
||||
|
@ -914,7 +937,6 @@ func putAppCommandInMeta(runConfig standalone.RunConfig, runE *runExec.RunExec)
|
|||
print.StatusEvent(runE.DaprCMD.OutputWriter, print.LogWarning, "Could not update sidecar metadata for appCommand: %s", err.Error())
|
||||
return
|
||||
}
|
||||
print.StatusEvent(runE.DaprCMD.OutputWriter, print.LogSuccess, "You're up and running! Dapr logs will appear here.\n")
|
||||
}
|
||||
|
||||
// putRunFilePathInMeta puts the absolute path of run file in metadata so that it can be used by the CLI to stop all apps started by this run file.
|
||||
|
|
|
@ -48,8 +48,9 @@ dapr uninstall --all
|
|||
# Uninstall from Kubernetes
|
||||
dapr uninstall -k
|
||||
|
||||
# Uninstall Dapr from non-default install directory (default is $HOME/.dapr)
|
||||
dapr uninstall --dapr-path <path-to-install-directory>
|
||||
# Uninstall Dapr from non-default install directory
|
||||
# This will remove the .dapr directory present in the path <path-to-install-directory>
|
||||
dapr uninstall --runtime-path <path-to-install-directory>
|
||||
`,
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
viper.BindPFlag("network", cmd.Flags().Lookup("network"))
|
||||
|
@ -59,8 +60,8 @@ dapr uninstall --dapr-path <path-to-install-directory>
|
|||
var err error
|
||||
|
||||
if uninstallKubernetes {
|
||||
if len(strings.TrimSpace(daprPath)) != 0 {
|
||||
print.FailureStatusEvent(os.Stderr, "--dapr-path is only valid for self-hosted mode")
|
||||
if len(strings.TrimSpace(daprRuntimePath)) != 0 {
|
||||
print.FailureStatusEvent(os.Stderr, "--runtime-path is only valid for self-hosted mode")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ dapr uninstall --dapr-path <path-to-install-directory>
|
|||
}
|
||||
print.InfoStatusEvent(os.Stdout, "Removing Dapr from your machine...")
|
||||
dockerNetwork := viper.GetString("network")
|
||||
err = standalone.Uninstall(uninstallAll, dockerNetwork, uninstallContainerRuntime, daprPath)
|
||||
err = standalone.Uninstall(uninstallAll, dockerNetwork, uninstallContainerRuntime, daprRuntimePath)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
151
go.mod
151
go.mod
|
@ -4,10 +4,10 @@ go 1.19
|
|||
|
||||
require (
|
||||
github.com/Azure/go-autorest/autorest v0.11.28 // indirect
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.21 // indirect
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.22 // indirect
|
||||
github.com/Pallinder/sillyname-go v0.0.0-20130730142914-97aeae9e6ba1
|
||||
github.com/briandowns/spinner v1.19.0
|
||||
github.com/dapr/dapr v1.9.0
|
||||
github.com/dapr/dapr v1.10.0-rc.4
|
||||
github.com/dapr/go-sdk v1.6.0
|
||||
github.com/docker/docker v20.10.20+incompatible
|
||||
github.com/fatih/color v1.13.0
|
||||
|
@ -20,17 +20,17 @@ require (
|
|||
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||
github.com/spf13/cobra v1.6.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.13.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec
|
||||
github.com/stretchr/testify v1.8.1
|
||||
golang.org/x/sys v0.4.1-0.20230105183443-b8be2fde2a9e
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
helm.sh/helm/v3 v3.10.3
|
||||
k8s.io/api v0.25.2
|
||||
k8s.io/apiextensions-apiserver v0.25.2
|
||||
k8s.io/apimachinery v0.25.2
|
||||
k8s.io/cli-runtime v0.25.2
|
||||
k8s.io/client-go v0.25.2
|
||||
k8s.io/api v0.26.1
|
||||
k8s.io/apiextensions-apiserver v0.26.1
|
||||
k8s.io/apimachinery v0.26.1
|
||||
k8s.io/cli-runtime v0.26.1
|
||||
k8s.io/client-go v0.26.1
|
||||
k8s.io/helm v2.16.10+incompatible
|
||||
sigs.k8s.io/yaml v1.3.0
|
||||
)
|
||||
|
@ -38,8 +38,9 @@ require (
|
|||
require github.com/evanphx/json-patch v5.6.0+incompatible
|
||||
|
||||
require (
|
||||
cloud.google.com/go/compute v1.6.1 // indirect
|
||||
contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect
|
||||
cloud.google.com/go/compute v1.14.0 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
|
||||
github.com/AdhityaRamadhanus/fasthttpcors v0.0.0-20170121111917-d4c07198763a // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
||||
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
|
||||
|
@ -54,20 +55,20 @@ require (
|
|||
github.com/Masterminds/squirrel v1.5.3 // indirect
|
||||
github.com/Microsoft/go-winio v0.5.1 // indirect
|
||||
github.com/Microsoft/hcsshim v0.9.3 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/PuerkitoBio/purell v1.2.0 // indirect
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed // indirect
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
|
||||
github.com/benbjohnson/clock v1.3.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/chai2010/gettext-go v1.0.2 // indirect
|
||||
github.com/containerd/containerd v1.6.6 // indirect
|
||||
github.com/containerd/continuity v0.2.2 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
|
||||
github.com/dapr/components-contrib v1.9.0-rc.5 // indirect
|
||||
github.com/dapr/kit v0.0.3-0.20220930182601-272e358ba6a7 // indirect
|
||||
github.com/dapr/components-contrib v1.10.0-rc.4 // indirect
|
||||
github.com/dapr/kit v0.0.4 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/docker/cli v20.10.17+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
|
@ -75,31 +76,32 @@ require (
|
|||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-metrics v0.0.1 // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
|
||||
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
|
||||
github.com/fasthttp/router v1.4.12 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||
github.com/fasthttp/router v1.4.15 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/ghodss/yaml v1.0.0 // indirect
|
||||
github.com/go-errors/errors v1.4.0 // indirect
|
||||
github.com/go-gorp/gorp/v3 v3.0.2 // indirect
|
||||
github.com/go-kit/log v0.2.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.5.1 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
||||
github.com/go-openapi/swag v0.19.14 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/btree v1.0.1 // indirect
|
||||
github.com/google/cel-go v0.12.5 // indirect
|
||||
github.com/google/cel-go v0.13.0 // indirect
|
||||
github.com/google/gnostic v0.5.7-v3refs // indirect
|
||||
github.com/google/go-cmp v0.5.8 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
|
@ -111,26 +113,28 @@ require (
|
|||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/huandu/xstrings v1.3.2 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/jhump/protoreflect v1.13.0 // indirect
|
||||
github.com/jhump/protoreflect v1.14.1 // indirect
|
||||
github.com/jmoiron/sqlx v1.3.5 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.15.11 // indirect
|
||||
github.com/klauspost/compress v1.15.14 // indirect
|
||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||
github.com/lib/pq v1.10.6 // indirect
|
||||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/mailru/easyjson v0.7.6 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/marusama/semaphore/v2 v2.5.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/microsoft/durabletask-go v0.1.3 // indirect
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
|
||||
|
@ -138,7 +142,7 @@ require (
|
|||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/moby/locker v1.0.1 // indirect
|
||||
github.com/moby/spdystream v0.2.0 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
|
||||
|
@ -147,75 +151,76 @@ require (
|
|||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
|
||||
github.com/opencontainers/runc v1.1.2 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.0 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.1 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.12.2 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.35.0 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/prometheus/statsd_exporter v0.22.3 // indirect
|
||||
github.com/prometheus/client_golang v1.14.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.39.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/prometheus/statsd_exporter v0.22.7 // indirect
|
||||
github.com/rubenv/sql-migrate v1.1.2 // indirect
|
||||
github.com/russross/blackfriday v2.0.0+incompatible // indirect
|
||||
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect
|
||||
github.com/shopspring/decimal v1.2.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/sony/gobreaker v0.4.2-0.20210216022020-dd874f9dd33b // indirect
|
||||
github.com/sony/gobreaker v0.5.0 // indirect
|
||||
github.com/spf13/afero v1.8.2 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/stoewer/go-strcase v1.2.0 // indirect
|
||||
github.com/stretchr/objx v0.4.0 // indirect
|
||||
github.com/stretchr/objx v0.5.0 // indirect
|
||||
github.com/subosito/gotenv v1.4.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||
github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.40.0 // indirect
|
||||
github.com/valyala/fasthttp v1.44.0 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
github.com/xlab/treeprint v1.1.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.4 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/otel v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.11.2 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be // indirect
|
||||
golang.org/x/net v0.0.0-20220927171203-f486391704dc // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230125214544-b3c2aaf6208d // indirect
|
||||
golang.org/x/net v0.5.0 // indirect
|
||||
golang.org/x/oauth2 v0.4.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/term v0.4.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220622171453-ea41d75dfa0f // indirect
|
||||
google.golang.org/grpc v1.48.0 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2 // indirect
|
||||
google.golang.org/grpc v1.52.3 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/apiserver v0.25.2 // indirect
|
||||
k8s.io/component-base v0.25.2 // indirect
|
||||
k8s.io/klog/v2 v2.70.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
|
||||
k8s.io/apiserver v0.26.1 // indirect
|
||||
k8s.io/component-base v0.26.1 // indirect
|
||||
k8s.io/klog/v2 v2.80.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
|
||||
k8s.io/kubectl v0.25.2 // indirect
|
||||
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
|
||||
k8s.io/utils v0.0.0-20230115233650-391b47cb4029 // indirect
|
||||
oras.land/oras-go v1.2.0 // indirect
|
||||
sigs.k8s.io/controller-runtime v0.11.0 // indirect
|
||||
sigs.k8s.io/controller-runtime v0.14.1 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
|
||||
sigs.k8s.io/kustomize/api v0.12.1 // indirect
|
||||
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
|
||||
|
@ -228,5 +233,7 @@ replace (
|
|||
github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d
|
||||
github.com/docker/docker => github.com/moby/moby v17.12.0-ce-rc1.0.20200618181300-9dc6525e6118+incompatible
|
||||
github.com/russross/blackfriday => github.com/russross/blackfriday v1.5.2
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.2
|
||||
k8s.io/client => github.com/kubernetes-client/go v0.0.0-20190928040339-c757968c4c36
|
||||
k8s.io/client-go => k8s.io/client-go v0.25.2
|
||||
)
|
||||
|
|
|
@ -130,7 +130,7 @@ func TestConfigurations(t *testing.T) {
|
|||
name: "Yaml one config",
|
||||
configName: "",
|
||||
outputFormat: "yaml",
|
||||
expectedOutput: "- name: appConfig\n namespace: default\n spec:\n apphttppipelinespec:\n handlers: []\n httppipelinespec:\n handlers: []\n tracingspec:\n samplingrate: \"\"\n stdout: false\n zipkin:\n endpointaddresss: \"\"\n otel:\n protocol: \"\"\n endpointAddress: \"\"\n isSecure: false\n metricspec:\n enabled: false\n mtlsspec:\n enabled: false\n workloadcertttl: \"\"\n allowedclockskew: \"\"\n secrets:\n scopes: []\n accesscontrolspec:\n defaultAction: \"\"\n trustDomain: \"\"\n policies: []\n nameresolutionspec:\n component: \"\"\n version: \"\"\n configuration:\n json:\n raw: []\n features: []\n apispec:\n allowed: []\n componentsspec: {}\n",
|
||||
expectedOutput: "- name: appConfig\n namespace: default\n spec:\n apphttppipelinespec:\n handlers: []\n httppipelinespec:\n handlers: []\n tracingspec:\n samplingrate: \"\"\n stdout: false\n zipkin:\n endpointaddresss: \"\"\n otel:\n protocol: \"\"\n endpointAddress: \"\"\n isSecure: false\n metricspec:\n enabled: false\n rules: []\n metricsspec:\n enabled: false\n rules: []\n mtlsspec:\n enabled: false\n workloadcertttl: \"\"\n allowedclockskew: \"\"\n secrets:\n scopes: []\n accesscontrolspec:\n defaultAction: \"\"\n trustDomain: \"\"\n policies: []\n nameresolutionspec:\n component: \"\"\n version: \"\"\n configuration:\n json:\n raw: []\n features: []\n apispec:\n allowed: []\n componentsspec: {}\n loggingspec:\n apiLogging:\n enabled: false\n obfuscateURLs: false\n omitHealthChecks: false\n",
|
||||
errString: "",
|
||||
errorExpected: false,
|
||||
k8sConfig: []v1alpha1.Configuration{
|
||||
|
@ -148,7 +148,7 @@ func TestConfigurations(t *testing.T) {
|
|||
name: "Yaml two configs",
|
||||
configName: "",
|
||||
outputFormat: "yaml",
|
||||
expectedOutput: "- name: appConfig1\n namespace: default\n spec:\n apphttppipelinespec:\n handlers: []\n httppipelinespec:\n handlers: []\n tracingspec:\n samplingrate: \"\"\n stdout: false\n zipkin:\n endpointaddresss: \"\"\n otel:\n protocol: \"\"\n endpointAddress: \"\"\n isSecure: false\n metricspec:\n enabled: false\n mtlsspec:\n enabled: false\n workloadcertttl: \"\"\n allowedclockskew: \"\"\n secrets:\n scopes: []\n accesscontrolspec:\n defaultAction: \"\"\n trustDomain: \"\"\n policies: []\n nameresolutionspec:\n component: \"\"\n version: \"\"\n configuration:\n json:\n raw: []\n features: []\n apispec:\n allowed: []\n componentsspec: {}\n- name: appConfig2\n namespace: default\n spec:\n apphttppipelinespec:\n handlers: []\n httppipelinespec:\n handlers: []\n tracingspec:\n samplingrate: \"\"\n stdout: false\n zipkin:\n endpointaddresss: \"\"\n otel:\n protocol: \"\"\n endpointAddress: \"\"\n isSecure: false\n metricspec:\n enabled: false\n mtlsspec:\n enabled: false\n workloadcertttl: \"\"\n allowedclockskew: \"\"\n secrets:\n scopes: []\n accesscontrolspec:\n defaultAction: \"\"\n trustDomain: \"\"\n policies: []\n nameresolutionspec:\n component: \"\"\n version: \"\"\n configuration:\n json:\n raw: []\n features: []\n apispec:\n allowed: []\n componentsspec: {}\n",
|
||||
expectedOutput: "- name: appConfig1\n namespace: default\n spec:\n apphttppipelinespec:\n handlers: []\n httppipelinespec:\n handlers: []\n tracingspec:\n samplingrate: \"\"\n stdout: false\n zipkin:\n endpointaddresss: \"\"\n otel:\n protocol: \"\"\n endpointAddress: \"\"\n isSecure: false\n metricspec:\n enabled: false\n rules: []\n metricsspec:\n enabled: false\n rules: []\n mtlsspec:\n enabled: false\n workloadcertttl: \"\"\n allowedclockskew: \"\"\n secrets:\n scopes: []\n accesscontrolspec:\n defaultAction: \"\"\n trustDomain: \"\"\n policies: []\n nameresolutionspec:\n component: \"\"\n version: \"\"\n configuration:\n json:\n raw: []\n features: []\n apispec:\n allowed: []\n componentsspec: {}\n loggingspec:\n apiLogging:\n enabled: false\n obfuscateURLs: false\n omitHealthChecks: false\n- name: appConfig2\n namespace: default\n spec:\n apphttppipelinespec:\n handlers: []\n httppipelinespec:\n handlers: []\n tracingspec:\n samplingrate: \"\"\n stdout: false\n zipkin:\n endpointaddresss: \"\"\n otel:\n protocol: \"\"\n endpointAddress: \"\"\n isSecure: false\n metricspec:\n enabled: false\n rules: []\n metricsspec:\n enabled: false\n rules: []\n mtlsspec:\n enabled: false\n workloadcertttl: \"\"\n allowedclockskew: \"\"\n secrets:\n scopes: []\n accesscontrolspec:\n defaultAction: \"\"\n trustDomain: \"\"\n policies: []\n nameresolutionspec:\n component: \"\"\n version: \"\"\n configuration:\n json:\n raw: []\n features: []\n apispec:\n allowed: []\n componentsspec: {}\n loggingspec:\n apiLogging:\n enabled: false\n obfuscateURLs: false\n omitHealthChecks: false\n",
|
||||
errString: "",
|
||||
errorExpected: false,
|
||||
k8sConfig: []v1alpha1.Configuration{
|
||||
|
@ -174,7 +174,7 @@ func TestConfigurations(t *testing.T) {
|
|||
name: "Json one config",
|
||||
configName: "",
|
||||
outputFormat: "json",
|
||||
expectedOutput: "[\n {\n \"name\": \"appConfig\",\n \"namespace\": \"default\",\n \"spec\": {\n \"appHttpPipeline\": {\n \"handlers\": null\n },\n \"httpPipeline\": {\n \"handlers\": null\n },\n \"tracing\": {\n \"samplingRate\": \"\",\n \"stdout\": false,\n \"zipkin\": {\n \"endpointAddress\": \"\"\n },\n \"otel\": {\n \"protocol\": \"\",\n \"endpointAddress\": \"\",\n \"isSecure\": false\n }\n },\n \"metric\": {\n \"enabled\": false\n },\n \"mtls\": {\n \"enabled\": false,\n \"workloadCertTTL\": \"\",\n \"allowedClockSkew\": \"\"\n },\n \"secrets\": {\n \"scopes\": null\n },\n \"accessControl\": {\n \"defaultAction\": \"\",\n \"trustDomain\": \"\",\n \"policies\": null\n },\n \"nameResolution\": {\n \"component\": \"\",\n \"version\": \"\",\n \"configuration\": null\n },\n \"api\": {},\n \"components\": {}\n }\n }\n]",
|
||||
expectedOutput: "[\n {\n \"name\": \"appConfig\",\n \"namespace\": \"default\",\n \"spec\": {\n \"appHttpPipeline\": {\n \"handlers\": null\n },\n \"httpPipeline\": {\n \"handlers\": null\n },\n \"tracing\": {\n \"samplingRate\": \"\",\n \"stdout\": false,\n \"zipkin\": {\n \"endpointAddress\": \"\"\n },\n \"otel\": {\n \"protocol\": \"\",\n \"endpointAddress\": \"\",\n \"isSecure\": false\n }\n },\n \"metric\": {\n \"enabled\": false,\n \"rules\": null\n },\n \"metrics\": {\n \"enabled\": false,\n \"rules\": null\n },\n \"mtls\": {\n \"enabled\": false,\n \"workloadCertTTL\": \"\",\n \"allowedClockSkew\": \"\"\n },\n \"secrets\": {\n \"scopes\": null\n },\n \"accessControl\": {\n \"defaultAction\": \"\",\n \"trustDomain\": \"\",\n \"policies\": null\n },\n \"nameResolution\": {\n \"component\": \"\",\n \"version\": \"\",\n \"configuration\": null\n },\n \"api\": {},\n \"components\": {},\n \"logging\": {\n \"apiLogging\": {\n \"enabled\": false,\n \"obfuscateURLs\": false,\n \"omitHealthChecks\": false\n }\n }\n }\n }\n]",
|
||||
errString: "",
|
||||
errorExpected: false,
|
||||
k8sConfig: []v1alpha1.Configuration{
|
||||
|
@ -192,7 +192,7 @@ func TestConfigurations(t *testing.T) {
|
|||
name: "Json two configs",
|
||||
configName: "",
|
||||
outputFormat: "json",
|
||||
expectedOutput: "[\n {\n \"name\": \"appConfig1\",\n \"namespace\": \"default\",\n \"spec\": {\n \"appHttpPipeline\": {\n \"handlers\": null\n },\n \"httpPipeline\": {\n \"handlers\": null\n },\n \"tracing\": {\n \"samplingRate\": \"\",\n \"stdout\": false,\n \"zipkin\": {\n \"endpointAddress\": \"\"\n },\n \"otel\": {\n \"protocol\": \"\",\n \"endpointAddress\": \"\",\n \"isSecure\": false\n }\n },\n \"metric\": {\n \"enabled\": false\n },\n \"mtls\": {\n \"enabled\": false,\n \"workloadCertTTL\": \"\",\n \"allowedClockSkew\": \"\"\n },\n \"secrets\": {\n \"scopes\": null\n },\n \"accessControl\": {\n \"defaultAction\": \"\",\n \"trustDomain\": \"\",\n \"policies\": null\n },\n \"nameResolution\": {\n \"component\": \"\",\n \"version\": \"\",\n \"configuration\": null\n },\n \"api\": {},\n \"components\": {}\n }\n },\n {\n \"name\": \"appConfig2\",\n \"namespace\": \"default\",\n \"spec\": {\n \"appHttpPipeline\": {\n \"handlers\": null\n },\n \"httpPipeline\": {\n \"handlers\": null\n },\n \"tracing\": {\n \"samplingRate\": \"\",\n \"stdout\": false,\n \"zipkin\": {\n \"endpointAddress\": \"\"\n },\n \"otel\": {\n \"protocol\": \"\",\n \"endpointAddress\": \"\",\n \"isSecure\": false\n }\n },\n \"metric\": {\n \"enabled\": false\n },\n \"mtls\": {\n \"enabled\": false,\n \"workloadCertTTL\": \"\",\n \"allowedClockSkew\": \"\"\n },\n \"secrets\": {\n \"scopes\": null\n },\n \"accessControl\": {\n \"defaultAction\": \"\",\n \"trustDomain\": \"\",\n \"policies\": null\n },\n \"nameResolution\": {\n \"component\": \"\",\n \"version\": \"\",\n \"configuration\": null\n },\n \"api\": {},\n \"components\": {}\n }\n }\n]",
|
||||
expectedOutput: "[\n {\n \"name\": \"appConfig1\",\n \"namespace\": \"default\",\n \"spec\": {\n \"appHttpPipeline\": {\n \"handlers\": null\n },\n \"httpPipeline\": {\n \"handlers\": null\n },\n \"tracing\": {\n \"samplingRate\": \"\",\n \"stdout\": false,\n \"zipkin\": {\n \"endpointAddress\": \"\"\n },\n \"otel\": {\n \"protocol\": \"\",\n \"endpointAddress\": \"\",\n \"isSecure\": false\n }\n },\n \"metric\": {\n \"enabled\": false,\n \"rules\": null\n },\n \"metrics\": {\n \"enabled\": false,\n \"rules\": null\n },\n \"mtls\": {\n \"enabled\": false,\n \"workloadCertTTL\": \"\",\n \"allowedClockSkew\": \"\"\n },\n \"secrets\": {\n \"scopes\": null\n },\n \"accessControl\": {\n \"defaultAction\": \"\",\n \"trustDomain\": \"\",\n \"policies\": null\n },\n \"nameResolution\": {\n \"component\": \"\",\n \"version\": \"\",\n \"configuration\": null\n },\n \"api\": {},\n \"components\": {},\n \"logging\": {\n \"apiLogging\": {\n \"enabled\": false,\n \"obfuscateURLs\": false,\n \"omitHealthChecks\": false\n }\n }\n }\n },\n {\n \"name\": \"appConfig2\",\n \"namespace\": \"default\",\n \"spec\": {\n \"appHttpPipeline\": {\n \"handlers\": null\n },\n \"httpPipeline\": {\n \"handlers\": null\n },\n \"tracing\": {\n \"samplingRate\": \"\",\n \"stdout\": false,\n \"zipkin\": {\n \"endpointAddress\": \"\"\n },\n \"otel\": {\n \"protocol\": \"\",\n \"endpointAddress\": \"\",\n \"isSecure\": false\n }\n },\n \"metric\": {\n \"enabled\": false,\n \"rules\": null\n },\n \"metrics\": {\n \"enabled\": false,\n \"rules\": null\n },\n \"mtls\": {\n \"enabled\": false,\n \"workloadCertTTL\": \"\",\n \"allowedClockSkew\": \"\"\n },\n \"secrets\": {\n \"scopes\": null\n },\n \"accessControl\": {\n \"defaultAction\": \"\",\n \"trustDomain\": \"\",\n \"policies\": null\n },\n \"nameResolution\": {\n \"component\": \"\",\n \"version\": \"\",\n \"configuration\": null\n },\n \"api\": {},\n \"components\": {},\n \"logging\": {\n \"apiLogging\": {\n \"enabled\": false,\n \"obfuscateURLs\": false,\n \"omitHealthChecks\": false\n }\n }\n }\n }\n]",
|
||||
errString: "",
|
||||
errorExpected: false,
|
||||
k8sConfig: []v1alpha1.Configuration{
|
||||
|
|
|
@ -74,7 +74,7 @@ func assertArgumentContains(t *testing.T, key string, expectedValue string, args
|
|||
}
|
||||
|
||||
func setupRun(t *testing.T) {
|
||||
myDaprPath, err := standalone.GetDaprPath("")
|
||||
myDaprPath, err := standalone.GetDaprRuntimePath("")
|
||||
assert.NoError(t, err)
|
||||
|
||||
componentsDir := standalone.GetDaprComponentsPath(myDaprPath)
|
||||
|
@ -87,7 +87,7 @@ func setupRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func tearDownRun(t *testing.T) {
|
||||
myDaprPath, err := standalone.GetDaprPath("")
|
||||
myDaprPath, err := standalone.GetDaprRuntimePath("")
|
||||
assert.NoError(t, err)
|
||||
|
||||
componentsDir := standalone.GetDaprComponentsPath(myDaprPath)
|
||||
|
@ -106,7 +106,7 @@ func assertCommonArgs(t *testing.T, basicConfig *standalone.RunConfig, output *R
|
|||
assert.Equal(t, 8000, output.DaprHTTPPort)
|
||||
assert.Equal(t, 50001, output.DaprGRPCPort)
|
||||
|
||||
daprPath, err := standalone.GetDaprPath("")
|
||||
daprPath, err := standalone.GetDaprRuntimePath("")
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Contains(t, output.DaprCMD.Args[0], "daprd")
|
||||
|
@ -168,7 +168,7 @@ func TestRun(t *testing.T) {
|
|||
// Setup the tearDown routine to run in the end.
|
||||
defer tearDownRun(t)
|
||||
|
||||
myDaprPath, err := standalone.GetDaprPath("")
|
||||
myDaprPath, err := standalone.GetDaprRuntimePath("")
|
||||
assert.NoError(t, err)
|
||||
|
||||
componentsDir := standalone.GetDaprComponentsPath(myDaprPath)
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"os"
|
||||
path_filepath "path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -28,19 +29,21 @@ const (
|
|||
defaultComponentsDirName = "components"
|
||||
)
|
||||
|
||||
// GetDaprPath returns the dapr installation path.
|
||||
// GetDaprRuntimePath returns the dapr runtime installation path.
|
||||
// daprRuntimePath is based on the --runtime-path command line flag.
|
||||
// The order of precedence is:
|
||||
// 1. From --dapr-path command line flag
|
||||
// 2. From DAPR_PATH environment variable
|
||||
// 3. $HOME/.dapr
|
||||
func GetDaprPath(inputInstallPath string) (string, error) {
|
||||
if inputInstallPath != "" {
|
||||
return inputInstallPath, nil
|
||||
// 1. From --runtime-path command line flag appended with `.dapr`
|
||||
// 2. From DAPR_RUNTIME_PATH environment variable appended with `.dapr`
|
||||
// 3. default $HOME/.dapr
|
||||
func GetDaprRuntimePath(daprRuntimePath string) (string, error) {
|
||||
runtimePath := strings.TrimSpace(daprRuntimePath)
|
||||
if runtimePath != "" {
|
||||
return path_filepath.Join(runtimePath, DefaultDaprDirName), nil
|
||||
}
|
||||
|
||||
envDaprDir := os.Getenv("DAPR_PATH")
|
||||
if envDaprDir != "" {
|
||||
return envDaprDir, nil
|
||||
envRuntimePath := strings.TrimSpace(os.Getenv("DAPR_RUNTIME_PATH"))
|
||||
if envRuntimePath != "" {
|
||||
return path_filepath.Join(envRuntimePath, DefaultDaprDirName), nil
|
||||
}
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
|
@ -64,7 +67,7 @@ func binaryFilePathWithDir(binaryDir string, binaryFilePrefix string) string {
|
|||
}
|
||||
|
||||
func lookupBinaryFilePath(inputInstallPath string, binaryFilePrefix string) (string, error) {
|
||||
daprPath, err := GetDaprPath(inputInstallPath)
|
||||
daprPath, err := GetDaprRuntimePath(inputInstallPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
Copyright 2023 The Dapr Authors
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package standalone
|
||||
|
||||
import (
|
||||
"os"
|
||||
path_filepath "path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetDaprPath(t *testing.T) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "error getting home dir")
|
||||
|
||||
t.Run("without flag value or env var", func(t *testing.T) {
|
||||
p, err := GetDaprRuntimePath("")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, p, path_filepath.Join(homeDir, DefaultDaprDirName), "path should be $HOME/.dapr")
|
||||
})
|
||||
|
||||
t.Run("check trim spaces", func(t *testing.T) {
|
||||
p, err := GetDaprRuntimePath(" ")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, path_filepath.Join(homeDir, DefaultDaprDirName), p, "path should be $HOME/.dapr")
|
||||
|
||||
t.Setenv("DAPR_RUNTIME_PATH", " ")
|
||||
p, err = GetDaprRuntimePath("")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, path_filepath.Join(homeDir, DefaultDaprDirName), p, "path should be $HOME/.dapr")
|
||||
})
|
||||
|
||||
t.Run("with flag value", func(t *testing.T) {
|
||||
input := path_filepath.Join("path", "to", "dapr")
|
||||
p, err := GetDaprRuntimePath(input)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, path_filepath.Join(input, ".dapr"), p, "path should be /path/to/dapr/.dapr")
|
||||
})
|
||||
|
||||
t.Run("with env var", func(t *testing.T) {
|
||||
input := path_filepath.Join("path", "to", "dapr")
|
||||
t.Setenv("DAPR_RUNTIME_PATH", input)
|
||||
p, err := GetDaprRuntimePath("")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, path_filepath.Join(input, ".dapr"), p, "path should be /path/to/dapr/.dapr")
|
||||
})
|
||||
|
||||
t.Run("with flag value and env var", func(t *testing.T) {
|
||||
input := path_filepath.Join("path", "to", "dapr")
|
||||
input2 := path_filepath.Join("path", "to", "dapr2")
|
||||
t.Setenv("DAPR_RUNTIME_PATH", input2)
|
||||
p, err := GetDaprRuntimePath(input)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, path_filepath.Join(input, ".dapr"), p, "path should be /path/to/dapr/.dapr")
|
||||
})
|
||||
}
|
|
@ -39,6 +39,7 @@ type ListOutput struct {
|
|||
Created string `csv:"CREATED" json:"created" yaml:"created"`
|
||||
DaprdPID int `csv:"DAPRD PID" json:"daprdPid" yaml:"daprdPid"`
|
||||
CliPID int `csv:"CLI PID" json:"cliPid" yaml:"cliPid"`
|
||||
AppPID int `csv:"APP PID" json:"appPid" yaml:"appPid"`
|
||||
MaxRequestBodySize int `csv:"-" json:"maxRequestBodySize" yaml:"maxRequestBodySize"` // Additional field, not displayed in table.
|
||||
HTTPReadBufferSize int `csv:"-" json:"httpReadBufferSize" yaml:"httpReadBufferSize"` // Additional field, not displayed in table.
|
||||
RunTemplatePath string `csv:"RUN_TEMPLATE_PATH" json:"runTemplatePath" yaml:"runTemplatePath"`
|
||||
|
@ -99,16 +100,23 @@ func List() ([]ListOutput, error) {
|
|||
|
||||
appID := argumentsMap["--app-id"]
|
||||
appCmd := ""
|
||||
appPIDString := ""
|
||||
cliPIDString := ""
|
||||
runTemplatePath := ""
|
||||
socket := argumentsMap["--unix-domain-socket"]
|
||||
appMetadata, err := metadata.Get(httpPort, appID, socket)
|
||||
if err == nil {
|
||||
appCmd = appMetadata.Extended["appCommand"]
|
||||
appPIDString = appMetadata.Extended["appPID"]
|
||||
cliPIDString = appMetadata.Extended["cliPID"]
|
||||
runTemplatePath = appMetadata.Extended["runTemplatePath"]
|
||||
}
|
||||
|
||||
appPID, err := strconv.Atoi(appPIDString)
|
||||
if err != nil {
|
||||
appPID = 0
|
||||
}
|
||||
|
||||
// Parse functions return an error on bad input.
|
||||
cliPID, err := strconv.Atoi(cliPIDString)
|
||||
if err != nil {
|
||||
|
@ -130,6 +138,7 @@ func List() ([]ListOutput, error) {
|
|||
DaprdPID: daprPID,
|
||||
CliPID: cliPID,
|
||||
AppID: appID,
|
||||
AppPID: appPID,
|
||||
HTTPPort: httpPort,
|
||||
GRPCPort: grpcPort,
|
||||
AppPort: appPort,
|
||||
|
|
|
@ -71,7 +71,7 @@ type SharedRunConfig struct {
|
|||
AppHealthTimeout int `arg:"app-health-probe-timeout" ifneq:"0" yaml:"appHealthProbeTimeout"`
|
||||
AppHealthThreshold int `arg:"app-health-threshold" ifneq:"0" yaml:"appHealthThreshold"`
|
||||
EnableAPILogging bool `arg:"enable-api-logging" yaml:"enableApiLogging"`
|
||||
DaprdInstallPath string `yaml:"daprPath"`
|
||||
DaprdInstallPath string `yaml:"runtimePath"`
|
||||
Env map[string]string `yaml:"env"`
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/dapr/cli/pkg/standalone"
|
||||
)
|
||||
|
@ -60,8 +61,7 @@ func (a *App) GetLogsDir() string {
|
|||
// CreateAppLogFile creates the log file, sets internal file handle
|
||||
// and returns error if any.
|
||||
func (a *App) CreateAppLogFile() error {
|
||||
logsPath := a.GetLogsDir()
|
||||
f, err := os.Create(filepath.Join(logsPath, getAppLogFileName()))
|
||||
f, err := a.createLogFile(appLogFileNamePrefix)
|
||||
if err == nil {
|
||||
a.AppLogWriteCloser = f
|
||||
a.AppLogFileName = f.Name()
|
||||
|
@ -72,8 +72,7 @@ func (a *App) CreateAppLogFile() error {
|
|||
// CreateDaprdLogFile creates the log file, sets internal file handle
|
||||
// and returns error if any.
|
||||
func (a *App) CreateDaprdLogFile() error {
|
||||
logsPath := a.GetLogsDir()
|
||||
f, err := os.Create(filepath.Join(logsPath, getDaprdLogFileName()))
|
||||
f, err := a.createLogFile(daprdLogFileNamePrefix)
|
||||
if err == nil {
|
||||
a.DaprdLogWriteCloser = f
|
||||
a.DaprdLogFileName = f.Name()
|
||||
|
@ -81,12 +80,13 @@ func (a *App) CreateDaprdLogFile() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func getAppLogFileName() string {
|
||||
return appLogFileNamePrefix + logFileExtension
|
||||
}
|
||||
|
||||
func getDaprdLogFileName() string {
|
||||
return daprdLogFileNamePrefix + logFileExtension
|
||||
// createLogFile creates the log file and returns the file handle and error if any.
|
||||
// It also adds the app ID as a prefix and the current timestamp to the file name as a suffix.
|
||||
func (a *App) createLogFile(logType string) (*os.File, error) {
|
||||
logsPath := a.GetLogsDir()
|
||||
fpath := filepath.Join(logsPath, a.AppID+"_"+logType+"_"+time.Now().Format("20060102150405")+logFileExtension)
|
||||
f, err := os.Create(fpath)
|
||||
return f, err
|
||||
}
|
||||
|
||||
func (a *App) CloseAppLogFile() error {
|
||||
|
|
|
@ -209,7 +209,7 @@ func (a *RunFileConfig) resolveResourcesFilePath(app *App) error {
|
|||
} else if len(strings.TrimSpace(a.Common.ResourcesPath)) > 0 {
|
||||
app.ResourcesPath = a.Common.ResourcesPath
|
||||
} else {
|
||||
daprDirPath, err := standalone.GetDaprPath(app.DaprdInstallPath)
|
||||
daprDirPath, err := standalone.GetDaprRuntimePath(app.DaprdInstallPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting dapr install path: %w", err)
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func (a *RunFileConfig) resolveConfigFilePath(app *App) error {
|
|||
} else if len(strings.TrimSpace(a.Common.ConfigFile)) > 0 {
|
||||
app.ConfigFile = a.Common.ConfigFile
|
||||
} else {
|
||||
daprDirPath, err := standalone.GetDaprPath(app.DaprdInstallPath)
|
||||
daprDirPath, err := standalone.GetDaprRuntimePath(app.DaprdInstallPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting dapr install path: %w", err)
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ func TestGetBasePathFromAbsPath(t *testing.T) {
|
|||
func getResourcesAndConfigFilePaths(t *testing.T, daprInstallPath string) []string {
|
||||
t.Helper()
|
||||
result := make([]string, 2)
|
||||
daprDirPath, err := standalone.GetDaprPath(daprInstallPath)
|
||||
daprDirPath, err := standalone.GetDaprRuntimePath(daprInstallPath)
|
||||
assert.NoError(t, err)
|
||||
result[0] = standalone.GetDaprComponentsPath(daprDirPath)
|
||||
result[1] = standalone.GetDaprConfigPath(daprDirPath)
|
||||
|
|
|
@ -215,7 +215,7 @@ func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMod
|
|||
|
||||
print.InfoStatusEvent(os.Stdout, "Installing runtime version %s", runtimeVersion)
|
||||
|
||||
installDir, err := GetDaprPath(daprInstallPath)
|
||||
installDir, err := GetDaprRuntimePath(daprInstallPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ func removeDir(dirPath string) error {
|
|||
func Uninstall(uninstallAll bool, dockerNetwork string, containerRuntime string, inputInstallPath string) error {
|
||||
var containerErrs []error
|
||||
inputInstallPath = strings.TrimSpace(inputInstallPath)
|
||||
installDir, err := GetDaprPath(inputInstallPath)
|
||||
installDir, err := GetDaprRuntimePath(inputInstallPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -80,8 +80,8 @@ func GetVersionsFromEnv(t *testing.T, latest bool) (string, string) {
|
|||
runtimeEnvVar := "DAPR_RUNTIME_PINNED_VERSION"
|
||||
dashboardEnvVar := "DAPR_DASHBOARD_PINNED_VERSION"
|
||||
if latest {
|
||||
runtimeEnvVar = "DAPR_RUNTIME_LATEST_VERSION"
|
||||
dashboardEnvVar = "DAPR_DASHBOARD_LATEST_VERSION"
|
||||
runtimeEnvVar = "DAPR_RUNTIME_LATEST_STABLE_VERSION"
|
||||
dashboardEnvVar = "DAPR_DASHBOARD_LATEST_STABLE_VERSION"
|
||||
}
|
||||
if runtimeVersion, ok := os.LookupEnv(runtimeEnvVar); ok {
|
||||
daprRuntimeVersion = runtimeVersion
|
||||
|
@ -329,7 +329,10 @@ func StatusTestOnInstallUpgrade(details VersionDetails, opts TestOptions) func(t
|
|||
require.Equal(t, "True", cols[2], "healthly field must be true")
|
||||
require.Equal(t, "Running", cols[3], "pods must be Running")
|
||||
require.Equal(t, toVerify[1], cols[4], "replicas must be equal")
|
||||
require.Equal(t, toVerify[0], cols[5], "versions must match")
|
||||
// TODO: Skip the dashboard version check for now until the helm chart is updated.
|
||||
if cols[0] != "dapr-dashboard" {
|
||||
require.Equal(t, toVerify[0], cols[5], "versions must match")
|
||||
}
|
||||
delete(notFound, cols[0])
|
||||
}
|
||||
}
|
||||
|
@ -708,6 +711,7 @@ func installTest(details VersionDetails, opts TestOptions) func(t *testing.T) {
|
|||
"--log-as-json",
|
||||
}
|
||||
if !details.UseDaprLatestVersion {
|
||||
// TODO: Pass dashboard-version also when charts are released.
|
||||
args = append(args, "--runtime-version", details.RuntimeVersion)
|
||||
}
|
||||
if opts.HAEnabled {
|
||||
|
@ -864,9 +868,9 @@ func validatePodsOnInstallUpgrade(t *testing.T, details VersionDetails) {
|
|||
require.NoError(t, err)
|
||||
|
||||
notFound := map[string]string{
|
||||
"sentry": details.RuntimeVersion,
|
||||
"sidecar": details.RuntimeVersion,
|
||||
"dashboard": details.DashboardVersion,
|
||||
"sentry": details.RuntimeVersion,
|
||||
"sidecar": details.RuntimeVersion,
|
||||
// "dashboard": details.DashboardVersion, TODO: enable when helm charts are updated.
|
||||
"placement": details.RuntimeVersion,
|
||||
"operator": details.RuntimeVersion,
|
||||
}
|
||||
|
@ -879,9 +883,9 @@ func validatePodsOnInstallUpgrade(t *testing.T, details VersionDetails) {
|
|||
}
|
||||
|
||||
prefixes := map[string]string{
|
||||
"sentry": "dapr-sentry-",
|
||||
"sidecar": "dapr-sidecar-injector-",
|
||||
"dashboard": "dapr-dashboard-",
|
||||
"sentry": "dapr-sentry-",
|
||||
"sidecar": "dapr-sidecar-injector-",
|
||||
// "dashboard": "dapr-dashboard-", TODO: enable when helm charts are updated.
|
||||
"placement": "dapr-placement-server-",
|
||||
"operator": "dapr-operator-",
|
||||
}
|
||||
|
|
|
@ -17,15 +17,20 @@ limitations under the License.
|
|||
package kubernetes_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/dapr/cli/tests/e2e/common"
|
||||
)
|
||||
|
||||
var (
|
||||
currentRuntimeVersion string
|
||||
currentDashboardVersion string
|
||||
currentVersionDetails common.VersionDetails
|
||||
currentRuntimeVersion string
|
||||
currentDashboardVersion string
|
||||
currentVersionDetails common.VersionDetails
|
||||
clusterRoles1_9_X = []string{"dapr-operator-admin", "dashboard-reader"}
|
||||
clusterRoleBindings1_9_X = []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"}
|
||||
clusterRoles1_10_X = []string{"dapr-dashboard", "dapr-injector", "dapr-operator-admin", "dapr-placement", "dapr-sentry"}
|
||||
clusterRoleBindings1_10_X = []string{"dapr-operator-admin", "dapr-dashboard", "dapr-injector", "dapr-placement", "dapr-sentry"}
|
||||
)
|
||||
|
||||
// ensureCleanEnv function needs to be called in every Test function.
|
||||
|
@ -36,12 +41,17 @@ func ensureCleanEnv(t *testing.T, useDaprLatestVersion bool) {
|
|||
currentVersionDetails = common.VersionDetails{
|
||||
RuntimeVersion: currentRuntimeVersion,
|
||||
DashboardVersion: currentDashboardVersion,
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io"},
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
ImageVariant: "",
|
||||
UseDaprLatestVersion: useDaprLatestVersion,
|
||||
}
|
||||
if strings.HasPrefix(currentRuntimeVersion, "1.9.") {
|
||||
currentVersionDetails.ClusterRoles = clusterRoles1_9_X
|
||||
currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_9_X
|
||||
} else {
|
||||
currentVersionDetails.ClusterRoles = clusterRoles1_10_X
|
||||
currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X
|
||||
}
|
||||
// Ensure a clean environment
|
||||
common.EnsureUninstall(true) // does not wait for pod deletion
|
||||
}
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
//go:build e2e && !template
|
||||
// +build e2e,!template
|
||||
|
||||
/*
|
||||
Copyright 2022 The Dapr Authors
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package standalone_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/dapr/cli/tests/e2e/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestStandaloneInitRunUninstallNonDefaultDaprPath covers init, version, run and uninstall with --runtime-path flag.
|
||||
func TestStandaloneInitRunUninstallNonDefaultDaprPath(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
t.Run("run with --runtime-path flag", func(t *testing.T) {
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-run-with-flag-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
daprRuntimeVersion, daprDashboardVersion := common.GetVersionsFromEnv(t, false)
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
"--runtime-path", daprPath,
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
// check version
|
||||
output, err = cmdVersion("", "--runtime-path", daprPath)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr version failed")
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[0], "edge")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
assert.Contains(t, lines[1], daprRuntimeVersion)
|
||||
|
||||
args = []string{
|
||||
"--runtime-path", daprPath,
|
||||
"--app-id", "run_with_dapr_runtime_path_flag",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
output, err = cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
|
||||
// Uninstall Dapr at the end of the test since it's being installed in a non-default location.
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr from custom path flag", "--runtime-path", daprPath)
|
||||
customDaprPath := filepath.Join(daprPath, ".dapr")
|
||||
assert.NoDirExists(t, customDaprPath)
|
||||
assert.DirExists(t, daprPath)
|
||||
// Check the directory is empty.
|
||||
f, err := os.ReadDir(daprPath)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, f, 0)
|
||||
})
|
||||
|
||||
t.Run("run with custom runtime path env var", func(t *testing.T) {
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-run-with-env-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
t.Setenv("DAPR_RUNTIME_PATH", daprPath)
|
||||
|
||||
daprRuntimeVersion, daprDashboardVersion := common.GetVersionsFromEnv(t, false)
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
// check version
|
||||
output, err = cmdVersion("", "--runtime-path", daprPath)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr version failed")
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[0], "edge")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
assert.Contains(t, lines[1], daprRuntimeVersion)
|
||||
|
||||
args = []string{
|
||||
"--app-id", "run_with_dapr_runtime_path_flag",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
output, err = cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
|
||||
// Uninstall Dapr at the end of the test since it's being installed in a non-default location.
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr from custom env var path")
|
||||
customDaprPath := filepath.Join(daprPath, ".dapr")
|
||||
assert.NoDirExists(t, customDaprPath)
|
||||
assert.DirExists(t, daprPath)
|
||||
// Check the directory is empty.
|
||||
f, err := os.ReadDir(daprPath)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, f, 0)
|
||||
})
|
||||
|
||||
t.Run("run with both runtime path flag and env var", func(t *testing.T) {
|
||||
daprPathEnv, err := os.MkdirTemp("", "dapr-e2e-run-with-envflag-1-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPathEnv) // clean up
|
||||
|
||||
daprPathFlag, err := os.MkdirTemp("", "dapr-e2e-run-with-envflag-2-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPathFlag) // clean up
|
||||
|
||||
t.Setenv("DAPR_RUNTIME_PATH", daprPathEnv)
|
||||
|
||||
daprRuntimeVersion, daprDashboardVersion := common.GetVersionsFromEnv(t, false)
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
"--runtime-path", daprPathFlag,
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
// check version
|
||||
output, err = cmdVersion("", "--runtime-path", daprPathFlag)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr version failed")
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[0], "edge")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
assert.Contains(t, lines[1], daprRuntimeVersion)
|
||||
|
||||
args = []string{
|
||||
"--runtime-path", daprPathFlag,
|
||||
"--app-id", "run_with_dapr_runtime_path_flag",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
flagDaprdBinPath := filepath.Join(daprPathFlag, ".dapr", "bin", "daprd")
|
||||
if runtime.GOOS == "windows" {
|
||||
flagDaprdBinPath += ".exe"
|
||||
}
|
||||
assert.FileExists(t, flagDaprdBinPath)
|
||||
|
||||
output, err = cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoDirExists(t, defaultDaprPath)
|
||||
|
||||
envDaprBinPath := filepath.Join(daprPathEnv, ".dapr", "bin")
|
||||
assert.NoDirExists(t, envDaprBinPath)
|
||||
|
||||
// Uninstall Dapr at the end of the test since it's being installed in a non-default location.
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr from custom path flag", "--runtime-path", daprPathFlag)
|
||||
customDaprPath := filepath.Join(daprPathFlag, ".dapr")
|
||||
assert.NoDirExists(t, customDaprPath)
|
||||
assert.DirExists(t, daprPathFlag)
|
||||
// Check the directory is empty.
|
||||
f, err := os.ReadDir(daprPathFlag)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, f, 0)
|
||||
})
|
||||
}
|
|
@ -36,6 +36,11 @@ import (
|
|||
func TestStandaloneInit(t *testing.T) {
|
||||
daprRuntimeVersion, daprDashboardVersion := common.GetVersionsFromEnv(t, false)
|
||||
|
||||
t.Cleanup(func() {
|
||||
// remove dapr installation after all tests in this function.
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
})
|
||||
|
||||
t.Run("init with invalid private registry", func(t *testing.T) {
|
||||
if isSlimMode() {
|
||||
t.Skip("Skipping init with private registry test because of slim installation")
|
||||
|
@ -45,6 +50,7 @@ func TestStandaloneInit(t *testing.T) {
|
|||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
"--image-registry", "smplregistry.io/owner",
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
|
@ -61,6 +67,7 @@ func TestStandaloneInit(t *testing.T) {
|
|||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
"--image-registry", "localhost:5000",
|
||||
"--from-dir", "./local-dir",
|
||||
}
|
||||
|
@ -74,6 +81,7 @@ func TestStandaloneInit(t *testing.T) {
|
|||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
"--container-runtime", "invalid",
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
|
@ -87,6 +95,7 @@ func TestStandaloneInit(t *testing.T) {
|
|||
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
t.Log(output)
|
||||
|
@ -110,6 +119,7 @@ func TestStandaloneInit(t *testing.T) {
|
|||
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
"--image-variant", "mariner",
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
|
@ -128,67 +138,6 @@ func TestStandaloneInit(t *testing.T) {
|
|||
verifyConfigs(t, daprPath)
|
||||
})
|
||||
|
||||
t.Run("init with --dapr-path flag", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-init-with-flag-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion, "--dapr-path", daprPath)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
verifyContainers(t, daprRuntimeVersion)
|
||||
verifyBinaries(t, daprPath, daprRuntimeVersion, daprDashboardVersion)
|
||||
verifyConfigs(t, daprPath)
|
||||
})
|
||||
|
||||
t.Run("init with DAPR_PATH env var", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-init-with-env-var-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
t.Setenv("DAPR_PATH", daprPath)
|
||||
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
verifyContainers(t, daprRuntimeVersion)
|
||||
verifyBinaries(t, daprPath, daprRuntimeVersion, daprDashboardVersion)
|
||||
verifyConfigs(t, daprPath)
|
||||
})
|
||||
|
||||
t.Run("init with --dapr-path flag and DAPR_PATH env var", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath1, err := os.MkdirTemp("", "dapr-e2e-init-with-flag-and-env-1-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath1) // clean up
|
||||
daprPath2, err := os.MkdirTemp("", "dapr-e2e-init-with-flag-and-env-2-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath2) // clean up
|
||||
|
||||
t.Setenv("DAPR_PATH", daprPath1)
|
||||
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion, "--dapr-path", daprPath2)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
verifyContainers(t, daprRuntimeVersion)
|
||||
verifyBinaries(t, daprPath2, daprRuntimeVersion, daprDashboardVersion)
|
||||
verifyConfigs(t, daprPath2)
|
||||
})
|
||||
|
||||
t.Run("init without runtime-version flag", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
|
|
@ -30,7 +30,6 @@ import (
|
|||
|
||||
func TestStandaloneInvoke(t *testing.T) {
|
||||
ensureDaprInstallation(t)
|
||||
|
||||
s := daprHttp.NewService(":9987")
|
||||
|
||||
err := s.AddServiceInvocationHandler("/test", func(ctx context.Context, e *common.InvocationEvent) (*common.Content, error) {
|
||||
|
|
|
@ -33,7 +33,6 @@ import (
|
|||
|
||||
func TestStandaloneList(t *testing.T) {
|
||||
ensureDaprInstallation(t)
|
||||
|
||||
executeAgainstRunningDapr(t, func() {
|
||||
output, err := cmdList("")
|
||||
t.Log(output)
|
||||
|
@ -124,7 +123,7 @@ func listOutputCheck(t *testing.T, output string, isCli bool) {
|
|||
// only one app is runnning at this time
|
||||
fields := strings.Fields(lines[0])
|
||||
// Fields splits on space, so Created time field might be split again
|
||||
assert.GreaterOrEqual(t, len(fields), 4, "expected at least 4 fields in components output")
|
||||
assert.GreaterOrEqual(t, len(fields), 10, "expected at least 10 fields in components output")
|
||||
if isCli {
|
||||
assert.Equal(t, "dapr_e2e_list", fields[0], "expected name to match")
|
||||
} else {
|
||||
|
@ -133,6 +132,7 @@ func listOutputCheck(t *testing.T, output string, isCli bool) {
|
|||
assert.Equal(t, "3555", fields[1], "expected http port to match")
|
||||
assert.Equal(t, "4555", fields[2], "expected grpc port to match")
|
||||
assert.Equal(t, "0", fields[3], "expected app port to match")
|
||||
assert.NotEmpty(t, fields[9], "expected an app PID (a real value or zero)")
|
||||
}
|
||||
|
||||
func listJsonOutputCheck(t *testing.T, output string) {
|
||||
|
@ -147,6 +147,7 @@ func listJsonOutputCheck(t *testing.T, output string) {
|
|||
assert.Equal(t, 3555, int(result[0]["httpPort"].(float64)), "expected http port to match")
|
||||
assert.Equal(t, 4555, int(result[0]["grpcPort"].(float64)), "expected grpc port to match")
|
||||
assert.Equal(t, 0, int(result[0]["appPort"].(float64)), "expected app port to match")
|
||||
assert.GreaterOrEqual(t, int(result[0]["appPid"].(float64)), 0, "expected an app PID (a real value or zero)")
|
||||
}
|
||||
|
||||
func listYamlOutputCheck(t *testing.T, output string) {
|
||||
|
@ -161,4 +162,5 @@ func listYamlOutputCheck(t *testing.T, output string) {
|
|||
assert.Equal(t, 3555, result[0]["httpPort"], "expected http port to match")
|
||||
assert.Equal(t, 4555, result[0]["grpcPort"], "expected grpc port to match")
|
||||
assert.Equal(t, 0, result[0]["appPort"], "expected app port to match")
|
||||
assert.GreaterOrEqual(t, result[0]["appPid"], 0, "expected an app PID (a real value or zero)")
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import (
|
|||
|
||||
func TestStandalonePublish(t *testing.T) {
|
||||
ensureDaprInstallation(t)
|
||||
|
||||
sub := &common.Subscription{
|
||||
PubsubName: "pubsub",
|
||||
Topic: "sample",
|
||||
|
|
|
@ -70,13 +70,13 @@ func TestRunWithTemplateFile(t *testing.T) {
|
|||
require.NoError(t, err, "run failed")
|
||||
// Deterministic output for template file, so we can assert line by line
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 4, "expected at least 4 lines in output of starting two apps")
|
||||
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[2], "Writing log files to directory")
|
||||
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[4], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[5], "Writing log files to directory")
|
||||
assert.Contains(t, lines[5], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.GreaterOrEqual(t, len(lines), 5, "expected at least 5 lines in output of starting two apps")
|
||||
assert.Contains(t, lines[2], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[3], "Writing log files to directory")
|
||||
assert.Contains(t, lines[3], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[5], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[6], "Writing log files to directory")
|
||||
assert.Contains(t, lines[6], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.Contains(t, output, "Received signal to stop Dapr and app processes. Shutting down Dapr and app processes.")
|
||||
appTestOutput := AppTestOutput{
|
||||
appID: "processor",
|
||||
|
@ -120,15 +120,16 @@ func TestRunWithTemplateFile(t *testing.T) {
|
|||
require.NoError(t, err, "run failed")
|
||||
// Deterministic output for template file, so we can assert line by line
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 6, "expected at least 6 lines in output of starting two apps")
|
||||
assert.Contains(t, lines[0], "Validating config and starting app \"processor\"")
|
||||
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[2], "Writing log files to directory")
|
||||
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[3], "Validating config and starting app \"emit-metrics\"")
|
||||
assert.Contains(t, lines[4], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[5], "Writing log files to directory")
|
||||
assert.Contains(t, lines[5], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.GreaterOrEqual(t, len(lines), 7, "expected at least 7 lines in output of starting two apps")
|
||||
assert.Contains(t, lines[0], "This is a preview feature and subject to change in future releases.")
|
||||
assert.Contains(t, lines[1], "Validating config and starting app \"processor\"")
|
||||
assert.Contains(t, lines[2], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[3], "Writing log files to directory")
|
||||
assert.Contains(t, lines[3], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[4], "Validating config and starting app \"emit-metrics\"")
|
||||
assert.Contains(t, lines[5], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[6], "Writing log files to directory")
|
||||
assert.Contains(t, lines[6], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.Contains(t, output, "Received signal to stop Dapr and app processes. Shutting down Dapr and app processes.")
|
||||
appTestOutput := AppTestOutput{
|
||||
appID: "processor",
|
||||
|
@ -177,13 +178,13 @@ func TestRunWithTemplateFile(t *testing.T) {
|
|||
require.NoError(t, err, "run failed")
|
||||
// Deterministic output for template file, so we can assert line by line
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 6, "expected at least 6 lines in output of starting two apps")
|
||||
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[2], "Writing log files to directory")
|
||||
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[4], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[5], "Writing log files to directory")
|
||||
assert.Contains(t, lines[5], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.GreaterOrEqual(t, len(lines), 7, "expected at least 7 lines in output of starting two apps")
|
||||
assert.Contains(t, lines[2], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[3], "Writing log files to directory")
|
||||
assert.Contains(t, lines[3], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[5], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[6], "Writing log files to directory")
|
||||
assert.Contains(t, lines[6], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.Contains(t, output, "Received signal to stop Dapr and app processes. Shutting down Dapr and app processes.")
|
||||
appTestOutput := AppTestOutput{
|
||||
appID: "processor",
|
||||
|
@ -228,14 +229,14 @@ func TestRunWithTemplateFile(t *testing.T) {
|
|||
require.NoError(t, err, "run failed")
|
||||
// Deterministic output for template file, so we can assert line by line
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 7, "expected at least 7 lines in output of starting two apps with one app not having a command")
|
||||
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[2], "Writing log files to directory")
|
||||
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[4], "No application command found for app \"emit-metrics\" present in")
|
||||
assert.Contains(t, lines[5], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[6], "Writing log files to directory")
|
||||
assert.Contains(t, lines[6], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.GreaterOrEqual(t, len(lines), 8, "expected at least 8 lines in output of starting two apps with one app not having a command")
|
||||
assert.Contains(t, lines[2], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[3], "Writing log files to directory")
|
||||
assert.Contains(t, lines[3], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[5], "No application command found for app \"emit-metrics\" present in")
|
||||
assert.Contains(t, lines[6], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
|
||||
assert.Contains(t, lines[7], "Writing log files to directory")
|
||||
assert.Contains(t, lines[7], "tests/apps/emit-metrics/.dapr/logs")
|
||||
assert.Contains(t, output, "Received signal to stop Dapr and app processes. Shutting down Dapr and app processes.")
|
||||
appTestOutput := AppTestOutput{
|
||||
appID: "processor",
|
||||
|
@ -280,11 +281,11 @@ func TestRunWithTemplateFile(t *testing.T) {
|
|||
require.Error(t, err, "run must fail")
|
||||
// Deterministic output for template file, so we can assert line by line
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 5, "expected at least 5 lines in output of starting two apps with last app having an empty command")
|
||||
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[2], "Writing log files to directory")
|
||||
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[4], "Error starting Dapr and app (\"emit-metrics\"): exec: no command")
|
||||
assert.GreaterOrEqual(t, len(lines), 6, "expected at least 6 lines in output of starting two apps with last app having an empty command")
|
||||
assert.Contains(t, lines[2], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
|
||||
assert.Contains(t, lines[3], "Writing log files to directory")
|
||||
assert.Contains(t, lines[3], "tests/apps/processor/.dapr/logs")
|
||||
assert.Contains(t, lines[5], "Error starting Dapr and app (\"emit-metrics\"): exec: no command")
|
||||
appTestOutput := AppTestOutput{
|
||||
appID: "processor",
|
||||
baseLogDirPath: "../../apps/processor/.dapr/logs",
|
||||
|
|
|
@ -18,20 +18,19 @@ package standalone_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/dapr/cli/tests/e2e/common"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestStandaloneRun(t *testing.T) {
|
||||
ensureDaprInstallation(t)
|
||||
|
||||
t.Cleanup(func() {
|
||||
// remove dapr installation after all tests in this function.
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
})
|
||||
for _, path := range getSocketCases() {
|
||||
t.Run(fmt.Sprintf("normal exit, socket: %s", path), func(t *testing.T) {
|
||||
output, err := cmdRun(path, "--", "bash", "-c", "echo test")
|
||||
|
@ -91,7 +90,10 @@ func TestStandaloneRun(t *testing.T) {
|
|||
output, err := cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "level=info msg=\"HTTP API Called: PUT /v1.0/metadata/appCommand")
|
||||
assert.Contains(t, output, "level=info msg=\"HTTP API Called\" app_id=enableApiLogging_info")
|
||||
assert.Contains(t, output, "method=\"PUT /v1.0/metadata/appCommand\"")
|
||||
assert.Contains(t, output, "method=\"PUT /v1.0/metadata/cliPID\"")
|
||||
assert.Contains(t, output, "method=\"PUT /v1.0/metadata/appPID\"")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
})
|
||||
|
@ -107,7 +109,28 @@ func TestStandaloneRun(t *testing.T) {
|
|||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
assert.NotContains(t, output, "level=info msg=\"HTTP API Called: PUT /v1.0/metadata/appCommand\"")
|
||||
assert.NotContains(t, output, "level=info msg=\"HTTP API Called\" app_id=enableApiLogging_info")
|
||||
assert.NotContains(t, output, "method=\"PUT /v1.0/metadata/appCommand\"")
|
||||
assert.NotContains(t, output, "method=\"PUT /v1.0/metadata/cliPID\"")
|
||||
assert.NotContains(t, output, "method=\"PUT /v1.0/metadata/appPID\"")
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("check enableAPILogging with obfuscation through dapr config file"), func(t *testing.T) {
|
||||
args := []string{
|
||||
"--app-id", "enableApiLogging_info",
|
||||
"--config", "../testdata/config.yaml",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
output, err := cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
assert.Contains(t, output, "level=info msg=\"HTTP API Called\" app_id=enableApiLogging_info")
|
||||
assert.Contains(t, output, "method=\"PUT /v1.0/metadata/{key}\"")
|
||||
assert.Contains(t, output, "method=\"PUT /v1.0/metadata/{key}\"")
|
||||
assert.Contains(t, output, "method=\"PUT /v1.0/metadata/{key}\"")
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("check run with log JSON enabled"), func(t *testing.T) {
|
||||
|
@ -158,127 +181,3 @@ func TestStandaloneRun(t *testing.T) {
|
|||
require.Contains(t, output, "The id for your application, used for service discovery", "expected usage to be printed")
|
||||
})
|
||||
}
|
||||
|
||||
func TestStandaloneRunNonDefaultDaprPath(t *testing.T) {
|
||||
// Uninstall Dapr at the end of the test since it's being installed in a non-default location.
|
||||
t.Cleanup(func() {
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
})
|
||||
|
||||
t.Run("run with flag", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-run-with-flag-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion, "--dapr-path", daprPath)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
args := []string{
|
||||
"--dapr-path", daprPath,
|
||||
"--app-id", "run_with_dapr_path_flag",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
output, err = cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
})
|
||||
|
||||
t.Run("run with env var", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-run-with-env-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
t.Setenv("DAPR_PATH", daprPath)
|
||||
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
args := []string{
|
||||
"--app-id", "run_with_dapr_path_flag",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
output, err = cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
})
|
||||
|
||||
t.Run("run with both flag and env var", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPathForEnv, err := os.MkdirTemp("", "dapr-e2e-run-with-envflag-1-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPathForEnv) // clean up
|
||||
|
||||
daprPathForFlag, err := os.MkdirTemp("", "dapr-e2e-run-with-envflag-2-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPathForFlag) // clean up
|
||||
|
||||
t.Setenv("DAPR_PATH", daprPathForEnv)
|
||||
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion, "--dapr-path", daprPathForFlag)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
args := []string{
|
||||
"--dapr-path", daprPathForFlag,
|
||||
"--app-id", "run_with_dapr_path_flag",
|
||||
"--", "bash", "-c", "echo 'test'",
|
||||
}
|
||||
|
||||
flagDaprdBinPath := filepath.Join(daprPathForFlag, "bin", "daprd")
|
||||
if runtime.GOOS == "windows" {
|
||||
flagDaprdBinPath += ".exe"
|
||||
}
|
||||
assert.FileExists(t, flagDaprdBinPath)
|
||||
|
||||
output, err = cmdRun("", args...)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "run failed")
|
||||
assert.Contains(t, output, "Exited App successfully")
|
||||
assert.Contains(t, output, "Exited Dapr successfully")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
|
||||
envDaprBinPath := filepath.Join(daprPathForEnv, "bin")
|
||||
assert.NoFileExists(t, envDaprBinPath)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
|
||||
func TestStandaloneStop(t *testing.T) {
|
||||
ensureDaprInstallation(t)
|
||||
|
||||
executeAgainstRunningDapr(t, func() {
|
||||
t.Run("stop", func(t *testing.T) {
|
||||
output, err := cmdStopWithAppID("dapr_e2e_stop")
|
||||
|
|
|
@ -125,7 +125,7 @@ func executeAgainstRunningDapr(t *testing.T, f func(), daprArgs ...string) {
|
|||
// ensureDaprInstallation ensures that Dapr is installed.
|
||||
// If Dapr is not installed, a new installation is attempted.
|
||||
func ensureDaprInstallation(t *testing.T) {
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
daprRuntimeVersion, daprDashboardVersion := common.GetVersionsFromEnv(t, false)
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
|
@ -134,6 +134,7 @@ func ensureDaprInstallation(t *testing.T) {
|
|||
if os.IsNotExist(err) {
|
||||
args := []string{
|
||||
"--runtime-version", daprRuntimeVersion,
|
||||
"--dashboard-version", daprDashboardVersion,
|
||||
}
|
||||
output, err := cmdInit(args...)
|
||||
require.NoError(t, err, "failed to install dapr:%v", output)
|
||||
|
|
|
@ -18,20 +18,16 @@ package standalone_test
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/dapr/cli/tests/e2e/common"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestStandaloneVersion(t *testing.T) {
|
||||
ensureDaprInstallation(t)
|
||||
|
||||
t.Run("version", func(t *testing.T) {
|
||||
output, err := cmdVersion("")
|
||||
t.Log(output)
|
||||
|
@ -39,7 +35,10 @@ func TestStandaloneVersion(t *testing.T) {
|
|||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[0], "edge")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
runtimeVer, _ := common.GetVersionsFromEnv(t, false)
|
||||
assert.Contains(t, lines[1], runtimeVer)
|
||||
})
|
||||
|
||||
t.Run("version json", func(t *testing.T) {
|
||||
|
@ -49,105 +48,8 @@ func TestStandaloneVersion(t *testing.T) {
|
|||
var result map[string]interface{}
|
||||
err = json.Unmarshal([]byte(output), &result)
|
||||
assert.NoError(t, err, "output was not valid JSON")
|
||||
})
|
||||
}
|
||||
|
||||
func TestStandaloneVersionNonDefaultDaprPath(t *testing.T) {
|
||||
t.Run("version with flag", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-ver-with-flag-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion, "--dapr-path", daprPath)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
output, err = cmdVersion("", "--dapr-path", daprPath)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr version failed")
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
})
|
||||
|
||||
t.Run("version with env var", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath, err := os.MkdirTemp("", "dapr-e2e-ver-with-env-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath) // clean up
|
||||
|
||||
t.Setenv("DAPR_PATH", daprPath)
|
||||
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
output, err = cmdVersion("")
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr version failed")
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
})
|
||||
|
||||
t.Run("version with both flag and env var", func(t *testing.T) {
|
||||
// Ensure a clean environment
|
||||
must(t, cmdUninstall, "failed to uninstall Dapr")
|
||||
|
||||
daprPath1, err := os.MkdirTemp("", "dapr-e2e-ver-with-both-flag-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath1) // clean up
|
||||
|
||||
daprPath2, err := os.MkdirTemp("", "dapr-e2e-ver-with-both-env-*")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(daprPath2) // clean up
|
||||
|
||||
t.Setenv("DAPR_PATH", daprPath2)
|
||||
|
||||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t, false)
|
||||
output, err := cmdInit("--runtime-version", daprRuntimeVersion, "--dapr-path", daprPath1)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "init failed")
|
||||
assert.Contains(t, output, "Success! Dapr is up and running.")
|
||||
|
||||
output, err = cmdVersion("", "--dapr-path", daprPath1)
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr version failed")
|
||||
lines := strings.Split(output, "\n")
|
||||
assert.GreaterOrEqual(t, len(lines), 2, "expected at least 2 fields in components outptu")
|
||||
assert.Contains(t, lines[0], "CLI version")
|
||||
assert.Contains(t, lines[1], "Runtime version")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
require.NoError(t, err, "failed to get user home directory")
|
||||
|
||||
defaultDaprPath := filepath.Join(homeDir, ".dapr")
|
||||
assert.NoFileExists(t, defaultDaprPath)
|
||||
|
||||
envDaprBinPath := filepath.Join(daprPath2, "bin")
|
||||
assert.NoFileExists(t, envDaprBinPath)
|
||||
assert.Contains(t, result["Cli version"], "edge")
|
||||
runtimeVer, _ := common.GetVersionsFromEnv(t, false)
|
||||
assert.Contains(t, result["Runtime version"], runtimeVer)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: daprConfig
|
||||
spec:
|
||||
logging:
|
||||
apiLogging:
|
||||
enabled: true
|
||||
obfuscateURLs: true
|
|
@ -37,7 +37,7 @@ var supportedUpgradePaths = []upgradePath{
|
|||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
next: common.VersionDetails{
|
||||
RuntimeVersion: "1.8.4",
|
||||
RuntimeVersion: "1.8.7",
|
||||
DashboardVersion: "0.10.0",
|
||||
ImageVariant: "mariner",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
|
@ -47,14 +47,14 @@ var supportedUpgradePaths = []upgradePath{
|
|||
},
|
||||
{
|
||||
previous: common.VersionDetails{
|
||||
RuntimeVersion: "1.7.4",
|
||||
RuntimeVersion: "1.7.6",
|
||||
DashboardVersion: "0.10.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
next: common.VersionDetails{
|
||||
RuntimeVersion: "1.8.0",
|
||||
RuntimeVersion: "1.8.7",
|
||||
DashboardVersion: "0.10.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
|
@ -63,47 +63,31 @@ var supportedUpgradePaths = []upgradePath{
|
|||
},
|
||||
{
|
||||
previous: common.VersionDetails{
|
||||
RuntimeVersion: "1.6.0",
|
||||
DashboardVersion: "0.9.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io"},
|
||||
},
|
||||
next: common.VersionDetails{
|
||||
RuntimeVersion: "1.7.0",
|
||||
DashboardVersion: "0.10.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
},
|
||||
// test downgrade.
|
||||
{
|
||||
previous: common.VersionDetails{
|
||||
RuntimeVersion: "1.9.0",
|
||||
RuntimeVersion: "1.9.5",
|
||||
DashboardVersion: "0.11.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
next: common.VersionDetails{
|
||||
RuntimeVersion: "1.8.4",
|
||||
DashboardVersion: "0.10.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
RuntimeVersion: "1.10.0-rc.4",
|
||||
DashboardVersion: "0.11.0",
|
||||
ClusterRoles: []string{"dapr-dashboard", "dapr-injector", "dapr-operator-admin", "dapr-placement", "dapr-sentry"},
|
||||
ClusterRoleBindings: []string{"dapr-operator-admin", "dapr-dashboard", "dapr-injector", "dapr-placement", "dapr-sentry"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
},
|
||||
// test downgrade.
|
||||
{
|
||||
previous: common.VersionDetails{
|
||||
RuntimeVersion: "1.8.4",
|
||||
DashboardVersion: "0.10.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
RuntimeVersion: "1.10.0-rc.4",
|
||||
DashboardVersion: "0.11.0",
|
||||
ClusterRoles: []string{"dapr-dashboard", "dapr-injector", "dapr-operator-admin", "dapr-placement", "dapr-sentry"},
|
||||
ClusterRoleBindings: []string{"dapr-operator-admin", "dapr-dashboard", "dapr-injector", "dapr-placement", "dapr-sentry"},
|
||||
CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io"},
|
||||
},
|
||||
next: common.VersionDetails{
|
||||
RuntimeVersion: "1.9.0",
|
||||
RuntimeVersion: "1.9.5",
|
||||
DashboardVersion: "0.11.0",
|
||||
ClusterRoles: []string{"dapr-operator-admin", "dashboard-reader"},
|
||||
ClusterRoleBindings: []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"},
|
||||
|
|
Loading…
Reference in New Issue