Exemple #1
0
        public void Test_DeployUpgrade()
        {
            Console.WriteLine("Testing deploy upgrade...");

            var version = File.ReadAllText(ProjectDirectory + "/full-version.txt").Trim();

            var branch = new BranchDetector(ProjectDirectory).Branch;

            Console.WriteLine("  Version: " + version);
            Console.WriteLine("  Branch: " + branch);

            var deployment = GetDeploymentInfo(branch);

            Console.WriteLine("  Host: " + deployment.Ssh.Host);
            Console.WriteLine("  SSH Username: "******"  SSH Password: hidden (length " + (String.IsNullOrEmpty(deployment.Ssh.Password) ? deployment.Ssh.Password.Length : 0) + ")");
            Console.WriteLine("  SSH Port: " + deployment.Ssh.Port);

            Console.WriteLine("  MQTT Host: " + deployment.Mqtt.Host);
            Console.WriteLine("  MQTT Username: "******"  MQTT Password: hidden (length " + (String.IsNullOrEmpty(deployment.Mqtt.Password) ? deployment.Mqtt.Password.Length : 0) + ")");
            Console.WriteLine("  MQTT Port: " + deployment.Mqtt.Port);

            var ssh = new SshHelper(deployment.Ssh);

            ssh.UseSshPass = true;

            var manager = new DeploymentManager(deployment, branch, version);

            manager.CreateReleaseZipAndPushToHost(ProjectDirectory, deployment, ssh);

            if (!manager.IsInstalledOnTarget())
            {
                Assert.Fail("Can't upgrade when GrowSense is not currently installed.");
            }

            // TODO: Remove if not needed. Used for debugging
            //manager.Ssh.Execute("echo helloworld");
            //manager.Ssh.Execute("sudo echo hello > /usr/local/GrowSense/Installer/hello.txt");

            manager.DownloadAndLaunchUpgrade();

            manager.SetConfigValues();

            Console.WriteLine("Setting supervisor settings...");
            manager.Ssh.Execute("echo 10 > supervisor-status-check-frequency.txt && echo 10 > supervisor-docker-check-frequency.txt && echo 10 > supervisor-mqtt-check-frequency.txt");

            Console.WriteLine("Deploy upgrade successful.");
        }
Exemple #2
0
        public void Test_DeployInstall()
        {
            Console.WriteLine("Testing deploy install...");

            var version = File.ReadAllText(ProjectDirectory + "/full-version.txt").Trim();

            var branch = new BranchDetector(ProjectDirectory).Branch;


            Console.WriteLine("  Version: " + version);
            Console.WriteLine("  Branch: " + branch);

            var deployment = GetDeploymentInfo(branch);


            Console.WriteLine("  Username: "******"  Password: hidden (length " + (String.IsNullOrEmpty(deployment.Password) ? deployment.Password.Length : 0) + ")");

            Console.WriteLine("  SSH Host: " + deployment.Ssh.Host);
            Console.WriteLine("  SSH Username: "******"  SSH Password: hidden (length " + (String.IsNullOrEmpty(deployment.Ssh.Password) ? deployment.Ssh.Password.Length : 0) + ")");
            Console.WriteLine("  SSH Port: " + deployment.Ssh.Port);

            Console.WriteLine("  MQTT Host: " + deployment.Mqtt.Host);
            Console.WriteLine("  MQTT Username: "******"  MQTT Password: hidden (length " + (String.IsNullOrEmpty(deployment.Mqtt.Password) ? deployment.Mqtt.Password.Length : 0) + ")");
            Console.WriteLine("  MQTT Port: " + deployment.Mqtt.Port);

            var ssh = new SshHelper(deployment.Ssh);

            ssh.UseSshPass = true;

            var manager = new DeploymentManager(deployment, branch, version);

            manager.CreateReleaseZipAndPushToHost(ProjectDirectory, deployment, ssh);

            if (manager.IsInstalledOnTarget())
            {
                manager.WaitForUnlock();

                Console.WriteLine("Renaming GrowSense devices to ensure the name is set correctly after installation...");

                // TODO: Fix and reimplement
                //   manager.RenameDevice("irrigatorW1", "NewIrrigatorW");
                //   manager.RenameDevice("illuminator1", "NewIlluminator");
            }
            else
            {
                manager.Ssh.CreateDirectory("/usr/local/GrowSense/Index");
            }


            Console.WriteLine("");
            Console.WriteLine("Adding GrowSense remotes...");
            manager.AddRemotes();

            // TODO: Remove if not needed. Used for debugging
            //manager.Ssh.Execute("echo helloworld");
            //manager.Ssh.Execute("sudo echo hello > /usr/local/GrowSense/Installer/hello.txt");

            manager.DownloadAndLaunchInstall();

            manager.SetConfigValues();

            Console.WriteLine("Setting supervisor settings...");
            manager.Ssh.Execute("echo 10 > supervisor-status-check-frequency.txt && echo 10 > supervisor-docker-check-frequency.txt && echo 10 > supervisor-mqtt-check-frequency.txt");

            Console.WriteLine("Deploy installation successful.");
        }