-
Notifications
You must be signed in to change notification settings - Fork 205
Rename components
directory to resources
under .dapr directory
#1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
pravinpushkar
wants to merge
38
commits into
dapr:master
Choose a base branch
from
pravinpushkar:feat/resources_dir
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
bd3657f
set dapr run defaults precedence
pravinpushkar 4e6d8b5
dapr init create resources dir and moves existing components content …
pravinpushkar 8358a21
modify tests
pravinpushkar c3f41e9
fix test
pravinpushkar 6affa75
fix tests
pravinpushkar 1b421b0
add tests
pravinpushkar 0363365
trigger pr checks
pravinpushkar d9caa15
Update pkg/standalone/common.go
pravinpushkar 2007ed5
Apply suggestions from code review
pravinpushkar bf0e7ff
review comments
pravinpushkar d8422a7
review comments
pravinpushkar e73ec7d
fix error handle on path not present
pravinpushkar 093239b
fix tests
pravinpushkar 5df0795
trigger pr checks
pravinpushkar 125ebc8
readme changes and some more messages today
pravinpushkar 3b55cd5
trigger pr checks
pravinpushkar 3c8020b
Update README.md
pravinpushkar ff6ce5d
update readme
pravinpushkar 5334d15
Typo
shubham1172 57cfa8a
Type (2)
shubham1172 15a894c
Merge branch 'master' into feat/resources_dir
mukundansundar a4c5f81
few more refactoring
pravinpushkar 03d190a
Merge branch 'master' into feat/resources_dir
mukundansundar 5a624af
fix review comment and failing merge
pravinpushkar 3989aad
make symlink
pravinpushkar 0749c5c
Merge branch 'master' into feat/resources_dir
pravinpushkar 4a421d5
fix tests
pravinpushkar f73af11
review comments
pravinpushkar e7ccf04
fix tests
pravinpushkar 771b256
some more refactor
pravinpushkar c5646d4
merge master and fix conflicts
pravinpushkar 968b5ca
fix tests
pravinpushkar ed1169c
change few uninstall to uninstallAll and add cleanup in upgrade test
pravinpushkar 5871ad4
Merge branch 'master' into feat/resources_dir
mukundansundar 771d423
Merge branch 'master' into feat/resources_dir
shubham1172 e471c28
fix conflicts & merge master
pravinpushkar e2794b0
Merge branch 'master' into feat/resources_dir
pravinpushkar d605587
lint fix
pravinpushkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
tests/e2e/standalone/componentsDir_to_resourcesDir_mig_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
//go:build e2e | ||
shubham1172 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// +build e2e | ||
|
||
/* | ||
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 ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/dapr/cli/tests/e2e/common" | ||
"github.com/dapr/cli/tests/e2e/spawn" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var ( | ||
// DefaultComponentsDirPath is the default components directory path. | ||
defaultComponentsDirPath = "" | ||
defaultResourcesDirPath = "" | ||
) | ||
|
||
func TestCompToResrcDirMig(t *testing.T) { | ||
homeDir, err := os.UserHomeDir() | ||
assert.NoError(t, err, "cannot get user home directory") | ||
defaultComponentsDirPath = filepath.Join(homeDir, ".dapr", "components") | ||
defaultResourcesDirPath = filepath.Join(homeDir, ".dapr", "resources") | ||
// Ensure a clean environment. | ||
must(t, cmdUninstall, "failed to uninstall Dapr") | ||
|
||
// install dapr. | ||
ensureDaprInstallation(t) | ||
|
||
// rename resources to components dir. | ||
renameResourcesDir(t) | ||
|
||
// dapr run should work with only components dir. | ||
checkDaprRunPrecedenceTest(t, true) | ||
|
||
// dapr uninstall without --all flag should work. | ||
uninstallWithoutAllFlag(t) | ||
|
||
// dapr init should duplicate files from components dir to resources dir. | ||
initTest(t) | ||
|
||
// copy a in memomy state store component to resources dir. | ||
copyInMemStateStore(t) | ||
|
||
// check dapr run precedence order, resources dir 1st then components dir. | ||
checkDaprRunPrecedenceTest(t, false) | ||
} | ||
|
||
func copyInMemStateStore(t *testing.T) { | ||
filePath := filepath.Join("../testdata/resources", "test-statestore.yaml") | ||
content, err := os.ReadFile(filePath) | ||
assert.NoError(t, err, "cannot read testdata/resources/test-statestore.yaml file") | ||
err = os.WriteFile(filepath.Join(defaultResourcesDirPath, "test-statestore.yaml"), content, 0644) | ||
assert.NoError(t, err, "cannot write testdata/resources/test-statestore.yaml file to resources directory") | ||
} | ||
|
||
func initTest(t *testing.T) { | ||
daprRuntimeVersion, _ := common.GetVersionsFromEnv(t) | ||
|
||
output, err := cmdInit(daprRuntimeVersion) | ||
t.Log(output) | ||
require.NoError(t, err, "init failed") | ||
assert.Contains(t, output, "Success! Dapr is up and running.") | ||
|
||
homeDir, err := os.UserHomeDir() | ||
require.NoError(t, err, "failed to get user home directory") | ||
|
||
daprPath := filepath.Join(homeDir, ".dapr") | ||
require.DirExists(t, daprPath, "Directory %s does not exist", daprPath) | ||
require.DirExists(t, defaultComponentsDirPath, "Components dir does not exist") | ||
require.DirExists(t, defaultResourcesDirPath, "Resources dir does not exist") | ||
} | ||
|
||
func checkDaprRunPrecedenceTest(t *testing.T, onlyCompDirPresent bool) { | ||
args := []string{ | ||
"--app-id", "testapp", | ||
"--", "bash", "-c", "echo 'test'", | ||
} | ||
output, err := cmdRun("", args...) | ||
t.Log(output) | ||
require.NoError(t, err, "run failed") | ||
if onlyCompDirPresent { | ||
assert.NotContains(t, output, "component loaded. name: test-statestore, type: state.in-memory/v1") | ||
} else { | ||
assert.Contains(t, output, "component loaded. name: test-statestore, type: state.in-memory/v1") | ||
} | ||
assert.Contains(t, output, "Exited App successfully") | ||
assert.Contains(t, output, "Exited Dapr successfully") | ||
} | ||
|
||
func uninstallWithoutAllFlag(t *testing.T) { | ||
uninstallArgs := []string{"uninstall"} | ||
daprContainerRuntime := containerRuntime() | ||
|
||
// Add --container-runtime flag only if daprContainerRuntime is not empty, or overridden via args. | ||
// This is only valid for non-slim mode. | ||
if !isSlimMode() && daprContainerRuntime != "" { | ||
uninstallArgs = append(uninstallArgs, "--container-runtime", daprContainerRuntime) | ||
} | ||
_, error := spawn.Command(common.GetDaprPath(), uninstallArgs...) | ||
if error != nil { | ||
assert.NoError(t, error, "failed to uninstall Dapr") | ||
} | ||
} | ||
|
||
func renameResourcesDir(t *testing.T) { | ||
err := os.Rename(defaultResourcesDirPath, defaultComponentsDirPath) | ||
if err != nil { | ||
mesg := fmt.Sprintf("pre-req to TestCompToResrcDirMig failed. error renaming components dir to resources dir: %s", err) | ||
assert.NoError(t, err, mesg) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.