|
| 1 | +// Copyright © Microsoft <[email protected]> |
| 2 | +// |
| 3 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | +// of this software and associated documentation files (the "Software"), to deal |
| 5 | +// in the Software without restriction, including without limitation the rights |
| 6 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | +// copies of the Software, and to permit persons to whom the Software is |
| 8 | +// furnished to do so, subject to the following conditions: |
| 9 | +// |
| 10 | +// The above copyright notice and this permission notice shall be included in |
| 11 | +// all copies or substantial portions of the Software. |
| 12 | +// |
| 13 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | +// THE SOFTWARE. |
| 20 | + |
| 21 | +package e2etest |
| 22 | + |
| 23 | +import ( |
| 24 | + "time" |
| 25 | + |
| 26 | + "github.com/Azure/azure-storage-azcopy/v10/common" |
| 27 | +) |
| 28 | + |
| 29 | +func init() { |
| 30 | + suiteManager.RegisterSuite(&FlagsFunctionalitySuite{}) |
| 31 | +} |
| 32 | + |
| 33 | +type FlagsFunctionalitySuite struct{} |
| 34 | + |
| 35 | +// @brief This test verifies that when the --log-level is set to NONE, |
| 36 | +// AzCopy does not display the "Log files located" message on the console. |
| 37 | +func (s *FlagsFunctionalitySuite) Scenario_LogLevelNone(svm *ScenarioVariationManager) { |
| 38 | + azCopyVerb := ResolveVariation(svm, []AzCopyVerb{AzCopyVerbCopy, AzCopyVerbSync}) // Calculate verb early to create the destination object early |
| 39 | + // Scale up from service to object |
| 40 | + dstObj := CreateResource[ContainerResourceManager](svm, GetRootResource(svm, ResolveVariation(svm, []common.Location{common.ELocation.Local(), common.ELocation.Blob(), common.ELocation.File(), common.ELocation.BlobFS()})), ResourceDefinitionContainer{}).GetObject(svm, "test", common.EEntityType.File()) |
| 41 | + |
| 42 | + // The object must exist already if we're syncing. |
| 43 | + if azCopyVerb == AzCopyVerbSync { |
| 44 | + dstObj.Create(svm, NewZeroObjectContentContainer(0), ObjectProperties{}) |
| 45 | + |
| 46 | + if !svm.Dryrun() { |
| 47 | + // Make sure the LMT is in the past |
| 48 | + time.Sleep(time.Second * 10) |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + body := NewRandomObjectContentContainer(SizeFromString("10K")) |
| 53 | + // Scale up from service to object |
| 54 | + srcObj := CreateResource[ObjectResourceManager](svm, GetRootResource(svm, ResolveVariation(svm, []common.Location{ /*common.ELocation.Local(), */ common.ELocation.Blob() /*, common.ELocation.File(), common.ELocation.BlobFS()*/})), ResourceDefinitionObject{ |
| 55 | + ObjectName: pointerTo("test"), |
| 56 | + Body: body, |
| 57 | + }) |
| 58 | + |
| 59 | + // no local->local |
| 60 | + if srcObj.Location().IsLocal() && dstObj.Location().IsLocal() { |
| 61 | + svm.InvalidateScenario() |
| 62 | + return |
| 63 | + } |
| 64 | + |
| 65 | + sasOpts := GenericAccountSignatureValues{} |
| 66 | + logLevel := common.LogLevel.None(common.LogNone) |
| 67 | + outputType := common.EOutputFormat.Text() |
| 68 | + |
| 69 | + stdOut, _ := RunAzCopy( |
| 70 | + svm, |
| 71 | + AzCopyCommand{ |
| 72 | + Verb: azCopyVerb, |
| 73 | + Targets: []ResourceManager{ |
| 74 | + TryApplySpecificAuthType(srcObj, EExplicitCredentialType.SASToken(), svm, CreateAzCopyTargetOptions{ |
| 75 | + SASTokenOptions: sasOpts, |
| 76 | + }), |
| 77 | + TryApplySpecificAuthType(dstObj, EExplicitCredentialType.SASToken(), svm, CreateAzCopyTargetOptions{ |
| 78 | + SASTokenOptions: sasOpts, |
| 79 | + }), |
| 80 | + }, |
| 81 | + Flags: CopyFlags{ |
| 82 | + CopySyncCommonFlags: CopySyncCommonFlags{ |
| 83 | + Recursive: pointerTo(true), |
| 84 | + GlobalFlags: GlobalFlags{ |
| 85 | + LogLevel: &logLevel, |
| 86 | + OutputType: &outputType, |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | + }) |
| 91 | + ValidateMessageOutput(svm, stdOut, "Log file is located at", false) |
| 92 | +} |
0 commit comments