示例#1
0
 static void WipeBucket(ControllerConfiguration context)
 {
     using (var client = new Amazon.S3.AmazonS3Client(context.AwsAccessKeyId, context.AwsSecretAccessKey))
     {
         int batchSize = 100;
         int count = batchSize;
         while (count == batchSize)
         {
             using (var listResponse = client.ListObjects(new Amazon.S3.Model.ListObjectsRequest()
             {
                 BucketName = context.BucketName,
                 MaxKeys = batchSize,
             }))
             {
                 count = listResponse.S3Objects.Count;
                 Parallel.ForEach(listResponse.S3Objects, s3obj =>
                     {
                         using (var delResponse = client.DeleteObject(new Amazon.S3.Model.DeleteObjectRequest()
                         {
                             BucketName = context.BucketName,
                             Key = s3obj.Key,
                         })) { }
                     });
             }
         }
     }
 }
        public static void Run(ControllerConfiguration context, Guid targetKey, Guid appKey, Guid versionKey)
        {
            var targetAppVersionsController = new TargetAppVersions(context);

            var notSet1 = targetAppVersionsController.GetTargetAppVersion(targetKey, appKey);
            Debug.Assert(notSet1.HasValue == false);

            var notSet2 = targetAppVersionsController.TargetAppVersionChanged(targetKey, appKey, Guid.Empty);
            Debug.Assert(notSet2 == VersionCheckResult.NotSet);

            // Set
            targetAppVersionsController.SetTargetAppVersion(targetKey, appKey, versionKey);

            var remoteVersion = targetAppVersionsController.GetTargetAppVersion(targetKey, appKey);
            Debug.Assert(remoteVersion.HasValue);
            Debug.Assert(remoteVersion.Value == versionKey);

            // Check same
            var same = targetAppVersionsController.TargetAppVersionChanged(targetKey, appKey, versionKey);
            Debug.Assert(same == VersionCheckResult.NotChanged);

            // Check different
            var different = targetAppVersionsController.TargetAppVersionChanged(targetKey, appKey, Guid.NewGuid());
            Debug.Assert(different == VersionCheckResult.Changed);

            // Set null
            targetAppVersionsController.SetTargetAppVersion(targetKey, appKey, null);
            var notSet3 = targetAppVersionsController.TargetAppVersionChanged(targetKey, appKey, versionKey);
            Debug.Assert(notSet3 == VersionCheckResult.NotSet);

            // Reset
            targetAppVersionsController.SetTargetAppVersion(targetKey, appKey, versionKey);
        }
示例#3
0
        public static Target Run(ControllerConfiguration context, Guid groupKey)
        {
            var targetsController = new Targets(context);

            var searchEmpty = targetsController.SearchGroupTargets(groupKey);
            Debug.Assert(searchEmpty.TotalCount == 0);
            Debug.Assert(searchEmpty.Targets.Count() == 0);

            var testTarget = new Target() { Name = "Test Target", GroupKey = groupKey };
            targetsController.CreateTarget(testTarget);
            var createdTarget = targetsController.GetTarget(testTarget.Key);
            Debug.Assert(createdTarget.Name == testTarget.Name);
            Debug.Assert(createdTarget.GroupKey == testTarget.GroupKey);

            var searchSingle = targetsController.SearchGroupTargets(groupKey);
            Debug.Assert(searchSingle.TotalCount == 1);
            Debug.Assert(searchSingle.Targets.Count() == 1);
            Debug.Assert(searchSingle.Targets.First().Key == createdTarget.Key);
            Debug.Assert(searchSingle.Targets.First().Name == createdTarget.Name);

            createdTarget.Tags.Add("Foo", "Bar");
            targetsController.UpdateTarget(createdTarget);

            var taggedTarget = targetsController.GetTarget(testTarget.Key);
            Debug.Assert(taggedTarget.GroupKey == createdTarget.GroupKey);
            Debug.Assert(taggedTarget.Tags.ContainsKey("Foo"));
            Debug.Assert(taggedTarget.Tags["Foo"] == "Bar");
            var searchUpdated = targetsController.SearchGroupTargets(groupKey);
            Debug.Assert(searchUpdated.TotalCount == 1);
            Debug.Assert(searchUpdated.Targets.Count() == 1);
            Debug.Assert(searchUpdated.Targets.First().Key == createdTarget.Key);
            Debug.Assert(searchUpdated.Targets.First().Name == createdTarget.Name);

            taggedTarget.Name = "Updated Test Target";
            targetsController.UpdateTarget(taggedTarget);

            var renamedTarget = targetsController.GetTarget(testTarget.Key);
            Debug.Assert(renamedTarget.Name == taggedTarget.Name);
            Debug.Assert(renamedTarget.GroupKey == taggedTarget.GroupKey);
            var searchRenamed = targetsController.SearchGroupTargets(groupKey);
            Debug.Assert(searchRenamed.TotalCount == 1);
            Debug.Assert(searchRenamed.Targets.Count() == 1);
            Debug.Assert(searchRenamed.Targets.First().Key == taggedTarget.Key);
            Debug.Assert(searchRenamed.Targets.First().Name == taggedTarget.Name);

            Searching(groupKey, targetsController, createdTarget);

            targetsController.UpdateTarget(testTarget);
            var searchReset = targetsController.SearchGroupTargets(groupKey);
            Debug.Assert(searchReset.TotalCount == 1);
            Debug.Assert(searchReset.Targets.Count() == 1);
            Debug.Assert(searchReset.Targets.First().Key == testTarget.Key);
            Debug.Assert(searchReset.Targets.First().Name == testTarget.Name);

            // Create default test target.
            targetsController.CreateTarget(new Target() { Key = new Guid("2c50a0af-bc66-41f5-bf52-498118217d12"), GroupKey = new Guid("5615c002-2d9a-46c4-a9a3-26b2b19cd790"), Name = "Test App Server" });

            return testTarget;
        }
示例#4
0
        static void Main(string[] args)
        {
            // TODO: Point this at a test bucket (everything will be deleted from here).
            var context = new ControllerConfiguration()
            {
                AwsAccessKeyId = "ZXXXXXXXXXZXZXZXZXZX",
                AwsSecretAccessKey = "AWWWWWWWAWAWWWWWWWWAWAWAWAWWWWWWWAWAWAWA",
                BucketName = "YOUR_TEST_BUCKET_NAME",
            };

            // Wipe pull folder.
            System.IO.DirectoryInfo pullFolder = new System.IO.DirectoryInfo(Program.STR_PULL_FOLDER);
            if (pullFolder.Exists)
                pullFolder.Delete(true);

            WipeBucket(context);

            var group = GroupTests.Run(context);
            var app = AppTests.Run(context, group.Key);
            var version = VersionTests.Run(context, app.Key);
            VersionFileTests.Run(context, version.Key);
            var target = TargetTests.Run(context, group.Key);
            TargetAppTests.Run(context, target.Key, app.Key);
            TargetAppVersionTests.Run(context, target.Key, app.Key, version.Key);
            var instance = InstanceTests.Run(context, target.Key);
            LogTests.Run(context, instance.Key);

            // TODO: Remove these hard coded paths (used for testing the command line tools to do an actual push).
            var deploymentConfig = new DeploymentConfiguration()
            {
                AwsAccessKeyId = context.AwsAccessKeyId,
                AwsSecretAccessKey = context.AwsSecretAccessKey,
                BucketName = context.BucketName,
                CheckFrequency = TimeSpan.FromSeconds(10),
                DeploymentDirectory = @"C:\PlywoodTesting\ServiceDeployment",
                TargetKey = target.Key,
            };
            File.WriteAllText(@"C:\PlywoodTesting\TestConfig.txt", Utils.Serialisation.Serialise(deploymentConfig));
            File.WriteAllText(@"C:\PlywoodTesting\PlyTestApps\Test App\.appkey", app.Key.ToString("N"));
        }
示例#5
0
        public static void Run(ControllerConfiguration context, Guid targetKey, Guid appKey)
        {
            var targetAppsController = new TargetApps(context);

            var noApps = targetAppsController.GetTargetAppKeys(targetKey);
            Debug.Assert(noApps.Count() == 0);

            targetAppsController.AddApp(targetKey, appKey);
            var oneApp = targetAppsController.GetTargetAppKeys(targetKey);
            Debug.Assert(oneApp.Count() == 1);
            Debug.Assert(oneApp.Single() == appKey);

            targetAppsController.RemoveApp(targetKey, appKey);
            var removedApp = targetAppsController.GetTargetAppKeys(targetKey);
            Debug.Assert(removedApp.Count() == 0);

            targetAppsController.AddApp(targetKey, appKey);

            // Add Plywood and Sawmill to default test server.
            targetAppsController.AddApp(new Guid("2c50a0af-bc66-41f5-bf52-498118217d12"), new Guid("8b245840-96be-4c9b-889e-06985fc63498"));
            targetAppsController.AddApp(new Guid("2c50a0af-bc66-41f5-bf52-498118217d12"), new Guid("6eaf852b-5b91-4ce6-9e74-ce57ee2aef9d"));
        }
        public static void Run(ControllerConfiguration context, Guid versionKey)
        {
            var versionsController = new Versions(context);

            System.IO.DirectoryInfo pushFolder = new System.IO.DirectoryInfo(Program.STR_PUSH_FOLDER);
            System.IO.DirectoryInfo pullFolder = new System.IO.DirectoryInfo(Program.STR_PULL_FOLDER);
            versionsController.PushVersion(pushFolder, versionKey);

            if (!pullFolder.Exists)
            {
                pullFolder.Create();
                pullFolder.Refresh();
            }

            versionsController.PullVersion(versionKey, pullFolder);

            pullFolder.Refresh();
            var pulledFiles = pullFolder.GetFiles("*", System.IO.SearchOption.AllDirectories);
            Debug.Assert(pulledFiles.Length == 2);
            Debug.Assert(pulledFiles.Any(f => f.FullName == String.Format(@"{0}\Subfolder\AnImage.bmp", Program.STR_PULL_FOLDER)));
            Debug.Assert(pulledFiles.Any(f => f.FullName == String.Format(@"{0}\README.txt", Program.STR_PULL_FOLDER)));
        }
示例#7
0
        public static App Run(ControllerConfiguration context, Guid groupKey)
        {
            var appsController = new Apps(context);

            var searchEmpty = appsController.SearchGroupApps(groupKey);
            Debug.Assert(searchEmpty.TotalCount == 0);
            Debug.Assert(searchEmpty.Apps.Count() == 0);

            var testApp = new App() { Name = "Test App", GroupKey = groupKey, DeploymentDirectory = "TestApp" };
            appsController.CreateApp(testApp);
            var createdApp = appsController.GetApp(testApp.Key);
            Debug.Assert(createdApp.Name == testApp.Name);
            Debug.Assert(createdApp.GroupKey == testApp.GroupKey);

            var searchSingle = appsController.SearchGroupApps(groupKey);
            Debug.Assert(searchSingle.TotalCount == 1);
            Debug.Assert(searchSingle.Apps.Count() == 1);
            Debug.Assert(searchSingle.Apps.First().Key == createdApp.Key);
            Debug.Assert(searchSingle.Apps.First().Name == createdApp.Name);

            createdApp.Tags.Add("Foo", "Bar");
            appsController.UpdateApp(createdApp);

            var taggedApp = appsController.GetApp(testApp.Key);
            Debug.Assert(taggedApp.GroupKey == createdApp.GroupKey);
            Debug.Assert(taggedApp.Tags.ContainsKey("Foo"));
            Debug.Assert(taggedApp.Tags["Foo"] == "Bar");
            var searchUpdated = appsController.SearchGroupApps(groupKey);
            Debug.Assert(searchUpdated.TotalCount == 1);
            Debug.Assert(searchUpdated.Apps.Count() == 1);
            Debug.Assert(searchUpdated.Apps.First().Key == createdApp.Key);
            Debug.Assert(searchUpdated.Apps.First().Name == createdApp.Name);

            taggedApp.Name = "Updated Test App";
            appsController.UpdateApp(taggedApp);

            var renamedApp = appsController.GetApp(testApp.Key);
            Debug.Assert(renamedApp.Name == taggedApp.Name);
            Debug.Assert(renamedApp.GroupKey == taggedApp.GroupKey);
            var searchRenamed = appsController.SearchGroupApps(groupKey);
            Debug.Assert(searchRenamed.TotalCount == 1);
            Debug.Assert(searchRenamed.Apps.Count() == 1);
            Debug.Assert(searchRenamed.Apps.First().Key == taggedApp.Key);
            Debug.Assert(searchRenamed.Apps.First().Name == taggedApp.Name);

            Searching(groupKey, appsController, createdApp);

            var searchDeleted = appsController.SearchGroupApps(groupKey);
            Debug.Assert(searchDeleted.TotalCount == 1);
            Debug.Assert(searchDeleted.Apps.Count() == 1);
            Debug.Assert(searchDeleted.Apps.First().Key == taggedApp.Key);
            Debug.Assert(searchDeleted.Apps.First().Name == taggedApp.Name);

            appsController.UpdateApp(testApp);
            var searchReset = appsController.SearchGroupApps(groupKey);
            Debug.Assert(searchReset.TotalCount == 1);
            Debug.Assert(searchReset.Apps.Count() == 1);
            Debug.Assert(searchReset.Apps.First().Key == testApp.Key);
            Debug.Assert(searchReset.Apps.First().Name == testApp.Name);

            // Create default test apps.
            appsController.CreateApp(new App() { Key = new Guid("8b245840-96be-4c9b-889e-06985fc63498"), GroupKey = new Guid("5615c002-2d9a-46c4-a9a3-26b2b19cd790"), Name = "Plywood Toolkit", DeploymentDirectory = "PlywoodToolkit", MajorVersion = "0.1", Revision = 11 });
            appsController.CreateApp(new App() { Key = new Guid("6eaf852b-5b91-4ce6-9e74-ce57ee2aef9d"), GroupKey = new Guid("5615c002-2d9a-46c4-a9a3-26b2b19cd790"), Name = "Sawmill Test", DeploymentDirectory = "SawmillTest", MajorVersion = "0.1", Revision = 1 });

            return testApp;
        }
示例#8
0
 public Targets(ControllerConfiguration context)
     : base(context)
 {
 }
示例#9
0
 public ControllerBase(ControllerConfiguration context)
 {
     _Context = context;
 }
示例#10
0
 public ControllerBase()
 {
     // Load context from configuration.
     _Context = Configuration.AppSettings.LoadControllerConfiguration();
 }
示例#11
0
 public Versions(ControllerConfiguration context)
     : base(context)
 {
 }
示例#12
0
        public static Group Run(ControllerConfiguration context)
        {
            var groupsController = new Groups(context);

            var searchEmpty = groupsController.SearchGroups();
            Debug.Assert(searchEmpty.TotalCount == 0);
            Debug.Assert(searchEmpty.Groups.Count() == 0);

            var testGroup = new Group() { Name = "Test Group" };
            groupsController.CreateGroup(testGroup);
            var createdGroup = groupsController.GetGroup(testGroup.Key);
            Debug.Assert(createdGroup.Name == testGroup.Name);

            var searchSingle = groupsController.SearchGroups();
            Debug.Assert(searchSingle.TotalCount == 1);
            Debug.Assert(searchSingle.Groups.Count() == 1);
            Debug.Assert(searchSingle.Groups.First().Key == createdGroup.Key);
            Debug.Assert(searchSingle.Groups.First().Name == createdGroup.Name);

            createdGroup.Tags.Add("Foo", "Bar");
            groupsController.UpdateGroup(createdGroup);

            var taggedGroup = groupsController.GetGroup(testGroup.Key);
            Debug.Assert(taggedGroup.Tags.ContainsKey("Foo"));
            Debug.Assert(taggedGroup.Tags["Foo"] == "Bar");
            var searchUpdated = groupsController.SearchGroups();
            Debug.Assert(searchUpdated.TotalCount == 1);
            Debug.Assert(searchUpdated.Groups.Count() == 1);
            Debug.Assert(searchUpdated.Groups.First().Key == createdGroup.Key);
            Debug.Assert(searchUpdated.Groups.First().Name == createdGroup.Name);

            taggedGroup.Name = "Updated Test Group";
            groupsController.UpdateGroup(taggedGroup);

            var renamedGroup = groupsController.GetGroup(testGroup.Key);
            Debug.Assert(renamedGroup.Name == taggedGroup.Name);
            var searchRenamed = groupsController.SearchGroups();
            Debug.Assert(searchRenamed.TotalCount == 1);
            Debug.Assert(searchRenamed.Groups.Count() == 1);
            Debug.Assert(searchRenamed.Groups.First().Key == taggedGroup.Key);
            Debug.Assert(searchRenamed.Groups.First().Name == taggedGroup.Name);

            var aSecondGroup = new Group() { Name = "A Second Group" };
            groupsController.CreateGroup(aSecondGroup);
            var zThirdGroup = new Group() { Name = "Z Third Group" };
            groupsController.CreateGroup(zThirdGroup);

            var search1 = groupsController.SearchGroups();
            Debug.Assert(search1.TotalCount == 3);
            Debug.Assert(search1.Groups.Count() == 3);
            Debug.Assert(search1.Groups.ElementAt(0).Key == aSecondGroup.Key);
            Debug.Assert(search1.Groups.ElementAt(1).Key == createdGroup.Key);
            Debug.Assert(search1.Groups.ElementAt(2).Key == zThirdGroup.Key);

            var search2 = groupsController.SearchGroups("Updated");
            Debug.Assert(search2.TotalCount == 1);
            Debug.Assert(search2.Groups.Count() == 1);
            Debug.Assert(search2.Groups.ElementAt(0).Key == createdGroup.Key);

            var search3 = groupsController.SearchGroups(pageSize: 1);
            Debug.Assert(search3.TotalCount == 3);
            Debug.Assert(search3.Groups.Count() == 1);
            Debug.Assert(search3.Groups.ElementAt(0).Key == aSecondGroup.Key);

            var search4 = groupsController.SearchGroups(pageSize: 2);
            Debug.Assert(search4.TotalCount == 3);
            Debug.Assert(search4.Groups.Count() == 2);
            Debug.Assert(search4.Groups.ElementAt(0).Key == aSecondGroup.Key);
            Debug.Assert(search4.Groups.ElementAt(1).Key == createdGroup.Key);

            var search5 = groupsController.SearchGroups(offset: 1);
            Debug.Assert(search5.TotalCount == 3);
            Debug.Assert(search5.Groups.Count() == 2);
            Debug.Assert(search5.Groups.ElementAt(0).Key == createdGroup.Key);
            Debug.Assert(search5.Groups.ElementAt(1).Key == zThirdGroup.Key);

            var search6 = groupsController.SearchGroups(offset: 1, pageSize: 1);
            Debug.Assert(search6.TotalCount == 3);
            Debug.Assert(search6.Groups.Count() == 1);
            Debug.Assert(search6.Groups.ElementAt(0).Key == createdGroup.Key);

            groupsController.DeleteGroup(aSecondGroup.Key);
            groupsController.DeleteGroup(zThirdGroup.Key);

            var searchDeleted = groupsController.SearchGroups();
            Debug.Assert(searchDeleted.TotalCount == 1);
            Debug.Assert(searchDeleted.Groups.Count() == 1);
            Debug.Assert(searchDeleted.Groups.First().Key == taggedGroup.Key);
            Debug.Assert(searchDeleted.Groups.First().Name == taggedGroup.Name);

            groupsController.UpdateGroup(testGroup);
            var searchReset = groupsController.SearchGroups();
            Debug.Assert(searchReset.TotalCount == 1);
            Debug.Assert(searchReset.Groups.Count() == 1);
            Debug.Assert(searchReset.Groups.First().Key == testGroup.Key);
            Debug.Assert(searchReset.Groups.First().Name == testGroup.Name);

            // Create default shared group.
            groupsController.CreateGroup(new Group() { Key = new Guid("5615c002-2d9a-46c4-a9a3-26b2b19cd790"), Name = "Shared" });

            return testGroup;
        }
示例#13
0
 public Logs(ControllerConfiguration context)
     : base(context)
 {
 }
示例#14
0
 public TargetAppVersions(ControllerConfiguration context)
     : base(context)
 {
 }
示例#15
0
 public Groups(ControllerConfiguration context)
     : base(context)
 {
 }
示例#16
0
 public Instances(ControllerConfiguration context)
     : base(context)
 {
 }
示例#17
0
        public static Plywood.Version Run(ControllerConfiguration context, Guid appKey)
        {
            var versionsController = new Versions(context);

            var searchEmpty = versionsController.SearchAppVersions(appKey);
            Debug.Assert(searchEmpty.TotalCount == 0);
            Debug.Assert(searchEmpty.Versions.Count() == 0);

            var testVersion = new Plywood.Version() { VersionNumber = "0.0.1", Comment = "Test Version", AppKey = appKey };
            versionsController.CreateVersion(testVersion);
            var createdVersion = versionsController.GetVersion(testVersion.Key);
            Debug.Assert(createdVersion.VersionNumber == testVersion.VersionNumber);
            Debug.Assert(createdVersion.Comment == testVersion.Comment);
            Debug.Assert(DateTimeEquals(createdVersion.Timestamp, testVersion.Timestamp));
            Debug.Assert(createdVersion.GroupKey == testVersion.GroupKey);

            var searchSingle = versionsController.SearchAppVersions(appKey);
            Debug.Assert(searchSingle.TotalCount == 1);
            Debug.Assert(searchSingle.Versions.Count() == 1);
            Debug.Assert(searchSingle.Versions.First().Key == createdVersion.Key);
            Debug.Assert(searchSingle.Versions.First().VersionNumber == createdVersion.VersionNumber);
            Debug.Assert(searchSingle.Versions.First().Comment == createdVersion.Comment);
            Debug.Assert(DateTimeEquals(searchSingle.Versions.First().Timestamp, createdVersion.Timestamp));

            createdVersion.Tags.Add("Foo", "Bar");
            versionsController.UpdateVersion(createdVersion);

            var taggedVersion = versionsController.GetVersion(testVersion.Key);
            Debug.Assert(taggedVersion.GroupKey == createdVersion.GroupKey);
            Debug.Assert(taggedVersion.Tags.ContainsKey("Foo"));
            Debug.Assert(taggedVersion.Tags["Foo"] == "Bar");
            var searchUpdated = versionsController.SearchAppVersions(appKey);
            Debug.Assert(searchUpdated.TotalCount == 1);
            Debug.Assert(searchUpdated.Versions.Count() == 1);
            Debug.Assert(searchUpdated.Versions.First().Key == createdVersion.Key);
            Debug.Assert(searchUpdated.Versions.First().VersionNumber == createdVersion.VersionNumber);
            Debug.Assert(searchUpdated.Versions.First().Comment == createdVersion.Comment);
            Debug.Assert(DateTimeEquals(searchUpdated.Versions.First().Timestamp, createdVersion.Timestamp));

            taggedVersion.VersionNumber = "0.0.2";
            taggedVersion.Comment = "Updated Test Version";
            versionsController.UpdateVersion(taggedVersion);

            var renamedVersion = versionsController.GetVersion(testVersion.Key);
            Debug.Assert(renamedVersion.VersionNumber == taggedVersion.VersionNumber);
            Debug.Assert(renamedVersion.Comment == taggedVersion.Comment);
            Debug.Assert(DateTimeEquals(renamedVersion.Timestamp, taggedVersion.Timestamp));
            Debug.Assert(renamedVersion.GroupKey == taggedVersion.GroupKey);
            var searchRenamed = versionsController.SearchAppVersions(appKey);
            Debug.Assert(searchRenamed.TotalCount == 1);
            Debug.Assert(searchRenamed.Versions.Count() == 1);
            Debug.Assert(searchRenamed.Versions.First().Key == taggedVersion.Key);
            Debug.Assert(searchRenamed.Versions.First().VersionNumber == taggedVersion.VersionNumber);
            Debug.Assert(searchRenamed.Versions.First().Comment == taggedVersion.Comment);
            Debug.Assert(DateTimeEquals(searchRenamed.Versions.First().Timestamp, taggedVersion.Timestamp));

            Searching(appKey, versionsController, createdVersion);

            versionsController.UpdateVersion(testVersion);
            var searchReset = versionsController.SearchAppVersions(appKey);
            Debug.Assert(searchReset.TotalCount == 1);
            Debug.Assert(searchReset.Versions.Count() == 1);
            Debug.Assert(searchReset.Versions.First().Key == testVersion.Key);
            Debug.Assert(searchReset.Versions.First().VersionNumber == testVersion.VersionNumber);
            Debug.Assert(searchReset.Versions.First().Comment == testVersion.Comment);
            Debug.Assert(DateTimeEquals(searchReset.Versions.First().Timestamp, testVersion.Timestamp));

            return testVersion;
        }