plugin_relx.mk 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # Relx plugin.
  2. #
  3. # Sleeps when interacting with relx script are necessary after start and upgrade
  4. # as both of those interactions are not synchronized.
  5. RELX_CASES = rel relup start-stop tar
  6. RELX_TARGETS = $(addprefix relx-,$(RELX_CASES))
  7. .PHONY: relx $(RELX_TARGETS)
  8. relx: $(RELX_TARGETS)
  9. relx-rel: build clean
  10. $i "Bootstrap a new release named $(APP)"
  11. $t mkdir $(APP)/
  12. $t cp ../erlang.mk $(APP)/
  13. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
  14. $i "Build the release"
  15. $t $(MAKE) -C $(APP) $v
  16. $i "Check that relx was downloaded"
  17. $t test -f $(APP)/.erlang.mk/relx
  18. $i "Check that the release was built"
  19. $t test -d $(APP)/_rel
  20. $t test -d $(APP)/_rel/$(APP)_release
  21. $t test -d $(APP)/_rel/$(APP)_release/bin
  22. $t test -d $(APP)/_rel/$(APP)_release/lib
  23. $t test -d $(APP)/_rel/$(APP)_release/releases
  24. $t test -d $(APP)/_rel/$(APP)_release/releases/1
  25. $i "Clean the application"
  26. $t $(MAKE) -C $(APP) clean $v
  27. $i "Check that the release still exists"
  28. $t test -d $(APP)/_rel
  29. $t test -d $(APP)/_rel/$(APP)_release
  30. $t test -d $(APP)/_rel/$(APP)_release/bin
  31. $t test -d $(APP)/_rel/$(APP)_release/lib
  32. $t test -d $(APP)/_rel/$(APP)_release/releases
  33. $t test -d $(APP)/_rel/$(APP)_release/releases/1
  34. $i "Distclean the application"
  35. $t $(MAKE) -C $(APP) distclean $v
  36. $i "Check that the output directory was removed entirely"
  37. $t test ! -d $(APP)/_rel/
  38. relx-relup: build clean
  39. $i "Bootstrap a new release named $(APP)"
  40. $t mkdir $(APP)/
  41. $t cp ../erlang.mk $(APP)/
  42. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
  43. $i "Set the initial application version"
  44. ifeq ($(LEGACY),1)
  45. $t sed -i.bak s/"{vsn, \"0.1.0\"}"/"{vsn, \"1\"}"/ $(APP)/src/$(APP).app.src
  46. else
  47. $t echo "PROJECT_VERSION = 1" >> $(APP)/Makefile
  48. endif
  49. $i "Generate a test module"
  50. $t printf "%s\n"\
  51. "-module(test)." \
  52. "-export([test/0])." \
  53. "test() -> old." > $(APP)/src/test.erl
  54. $i "Build the initial release as a tarball"
  55. $t $(MAKE) -C $(APP) $v
  56. $i "Update the test module"
  57. $t sed -i.bak s/"test() -> old."/"test() -> new."/ $(APP)/src/test.erl
  58. $i "Bump the application version"
  59. ifeq ($(LEGACY),1)
  60. $t sed -i.bak s/"{vsn, \"1\"}"/"{vsn, \"2\"}"/ $(APP)/src/$(APP).app.src
  61. else
  62. $t sed -i.bak s/"PROJECT_VERSION = 1"/"PROJECT_VERSION = 2"/ $(APP)/Makefile
  63. endif
  64. $i "Generate a .appup for the application"
  65. $t printf "%s\n" \
  66. "{\"2\","\
  67. " [{\"1\", [{load_module, test}]}],"\
  68. " [{\"1\", [{load_module, test}]}]"\
  69. "}." > $(APP)/ebin/$(APP).appup
  70. $i "Bump the release version"
  71. $t sed -i.bak s/"1"/"2"/ $(APP)/relx.config
  72. $i "Build a new release with a relup as a tarball"
  73. $t $(MAKE) -C $(APP) relup $v
  74. $i "Test that both releases are available"
  75. $t test -f $(APP)/_rel/$(APP)_release/$(APP)_release-1.tar.gz
  76. $t test -f $(APP)/_rel/$(APP)_release/$(APP)_release-2.tar.gz
  77. $i "Unpack initial release"
  78. $t mkdir $(APP)/tmp
  79. $t tar -xzf $(APP)/_rel/$(APP)_release/$(APP)_release-1.tar.gz -C $(APP)/tmp
  80. $i "Start initial release and confirm it runs the old code"
  81. ifeq ($(PLATFORM),msys2)
  82. $t $(APP)/tmp/bin/$(APP)_release.cmd install $v
  83. $t $(APP)/tmp/bin/$(APP)_release.cmd start $v
  84. $t sleep 1
  85. $t test `$(APP)/tmp/bin/$(APP)_release.cmd rpcterms test test` = old
  86. else
  87. $t $(APP)/tmp/bin/$(APP)_release start $v
  88. $t sleep 1
  89. $t test `$(APP)/tmp/bin/$(APP)_release rpcterms test test` = old
  90. endif
  91. $i "Move the relup tarball to the release directory"
  92. $t mkdir $(APP)/tmp/releases/2
  93. $t mv $(APP)/_rel/$(APP)_release/$(APP)_release-2.tar.gz $(APP)/tmp/releases/2/$(APP)_release.tar.gz
  94. $i "Upgrade the release and confirm it runs the new code"
  95. ifeq ($(PLATFORM),msys2)
  96. $t $(APP)/tmp/bin/$(APP)_release.cmd upgrade "2/$(APP)_release" $v
  97. $t sleep 1
  98. $t test `$(APP)/tmp/bin/$(APP)_release.cmd rpcterms test test` = new
  99. $i "Stop the release"
  100. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd stop $v
  101. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd uninstall $v
  102. else
  103. $i "Upgrade running release"
  104. $t $(APP)/tmp/bin/$(APP)_release upgrade "2/$(APP)_release" $v
  105. $t sleep 1
  106. $t test `$(APP)/tmp/bin/$(APP)_release rpcterms test test` = new
  107. $i "Stop the release"
  108. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  109. endif
  110. relx-start-stop: build clean
  111. $i "Bootstrap a new release named $(APP)"
  112. $t mkdir $(APP)/
  113. $t cp ../erlang.mk $(APP)/
  114. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
  115. $i "Build the release"
  116. $t $(MAKE) -C $(APP) $v
  117. ifeq ($(PLATFORM),msys2)
  118. $i "Install and start the release"
  119. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd install $v
  120. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd start $v
  121. $t sleep 1
  122. $i "Ping the release"
  123. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd ping $v
  124. $i "Stop and uninstall the release"
  125. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd stop $v
  126. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd uninstall $v
  127. $i "Check that further pings get no replies"
  128. $t ! $(APP)/_rel/$(APP)_release/bin/$(APP)_release.cmd ping $v
  129. else
  130. $i "Start the release"
  131. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  132. $t sleep 1
  133. $i "Ping the release"
  134. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release ping $v
  135. $i "Stop the release"
  136. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  137. $i "Check that further pings get no replies"
  138. $t ! $(APP)/_rel/$(APP)_release/bin/$(APP)_release ping $v
  139. endif
  140. relx-tar: build clean
  141. $i "Bootstrap a new release named $(APP)"
  142. $t mkdir $(APP)/
  143. $t cp ../erlang.mk $(APP)/
  144. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
  145. $i "Build the release as a tarball"
  146. $t $(MAKE) -C $(APP) $v
  147. $i "Check that tarball exists"
  148. $t test -f $(APP)/_rel/$(APP)_release/$(APP)_release-1.tar.gz