MCPcopy
hub / github.com/dgraph-io/dgraph / Upgrade

Method Upgrade

dgraphtest/local_cluster.go:904–994  ·  view source on GitHub ↗

Upgrades the cluster to the provided dgraph version

(version string, strategy UpgradeStrategy)

Source from the content-addressed store, hash-verified

902
903// Upgrades the cluster to the provided dgraph version
904func (c *LocalCluster) Upgrade(version string, strategy UpgradeStrategy) error {
905 if version == c.conf.version {
906 return fmt.Errorf("cannot upgrade to the same version")
907 }
908
909 log.Printf("[INFO] upgrading the cluster from [%v] to [%v] using [%v]", c.conf.version, version, strategy)
910 switch strategy {
911 case BackupRestore:
912 hc, err := c.HTTPClient()
913 if err != nil {
914 return err
915 }
916 if c.conf.acl {
917 if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil {
918 return errors.Wrapf(err, "error during login before upgrade")
919 }
920 }
921 if err := hc.Backup(c, true, DefaultBackupDir); err != nil {
922 return errors.Wrap(err, "error taking backup during upgrade")
923 }
924 if err := c.Stop(); err != nil {
925 return err
926 }
927 c.conf.version = version
928 if err := c.recreateContainers(); err != nil {
929 return err
930 }
931 if err := c.Start(); err != nil {
932 return err
933 }
934
935 hc, err = c.HTTPClient()
936 if err != nil {
937 return errors.Wrapf(err, "error creating HTTP client after upgrade")
938 }
939 if c.conf.acl {
940 if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil {
941 return errors.Wrapf(err, "error during login after upgrade")
942 }
943 }
944 if err := hc.Restore(c, DefaultBackupDir, "", 0, 1); err != nil {
945 return errors.Wrap(err, "error doing restore during upgrade")
946 }
947 if err := dgraphapi.WaitForRestore(c); err != nil {
948 return errors.Wrap(err, "error waiting for restore to complete")
949 }
950 return nil
951
952 case ExportImport:
953 hc, err := c.HTTPClient()
954 if err != nil {
955 return err
956 }
957 if c.conf.acl {
958 if err := hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace); err != nil {
959 return errors.Wrapf(err, "error during login before upgrade")
960 }
961 }

Callers 4

TestCountReverseIndexFunction · 0.95
TestMainFunction · 0.95

Calls 12

HTTPClientMethod · 0.95
StopMethod · 0.95
recreateContainersMethod · 0.95
StartMethod · 0.95
LiveLoadFromExportMethod · 0.95
setupBeforeClusterMethod · 0.95
WaitForRestoreFunction · 0.92
LoginIntoNamespaceMethod · 0.80
BackupMethod · 0.65
RestoreMethod · 0.65
ExportMethod · 0.65
ErrorfMethod · 0.45

Tested by 4

TestCountReverseIndexFunction · 0.76
TestMainFunction · 0.76